-
Notifications
You must be signed in to change notification settings - Fork 3
Add GitHub Action for PHP Code Style checks #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fcabb8c
add GitHub Action for PHP Code Style checks using PHP CodeSniffer
RobinTheHood d8f6322
Testing GitHub Action with PHP 8.4
Tomcraft1980 98e0c2d
Merge branch 'main' into chore/add-php-file-linting-action
RobinTheHood 90aeb9f
Update PHP Code Style check to ignore warnings on exit
RobinTheHood d7bf650
Revert "Update PHP Code Style check to ignore warnings on exit"
Tomcraft1980 9e97a8a
Fix: A require statement must not appear between namespace/use declar…
Tomcraft1980 833985a
Fix: Delete require_once as we use Composer-Autoloader
Tomcraft1980 2bd4db3
Revert "Fix: Delete require_once as we use Composer-Autoloader"
Tomcraft1980 f5bc0d7
Fix: Trenne Definitionen und Logik
Tomcraft1980 7d209fe
add f72054d after resolving conflict
Tomcraft1980 014f46a
Merge branch 'main' into chore/add-php-file-linting-action
Tomcraft1980 098e76a
Fix line length of 120 characters
Tomcraft1980 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Name der GitHub Action, der im Actions-Tab angezeigt wird | ||
| name: PHP Code Style | ||
|
|
||
| # Trigger: Wird bei jedem Push zu einem Pull Request ausgeführt | ||
| on: | ||
| pull_request: | ||
| branches: [ main ] # Nur PRs zum main-Branch | ||
|
|
||
| jobs: | ||
| phpcs: | ||
| runs-on: ubuntu-latest # Ubuntu Linux Container | ||
|
|
||
| steps: | ||
| # Schritt 1: Code aus dem Repository laden | ||
| # Hier verwenden wir eine vorgefertigte Action von GitHub | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| # Schritt 2: PHP installieren und phpcs einrichten | ||
| # Hier verwenden wir eine vorgefertigte Action von shivammathur | ||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: '8.4' # PHP Version | ||
| tools: phpcs # PHP CodeSniffer installieren | ||
|
|
||
| # Schritt 3: Code-Style prüfen mit PSR-12 Standard | ||
| # phpcs = PHP CodeSniffer prüft den Code auf Style-Fehler | ||
| # --standard=PSR12 = Verwendet den PSR-12 Coding Standard | ||
| # *.php = Prüft alle PHP-Dateien im Hauptverzeichnis | ||
| # admin/*.php = Prüft alle PHP-Dateien im admin-Ordner | ||
| # includes/*.php = Prüft alle PHP-Dateien im includes-Ordner | ||
| - name: Check PHP Code Style (PSR-12) | ||
| run: phpcs --standard=PSR12 *.php admin/*.php includes/*.php | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| use App\Service\MailSender; | ||
|
|
||
| /** | ||
| * Erstellt die E-Mail-Nachricht | ||
| * | ||
| * @return string Die formatierte E-Mail-Nachricht | ||
| */ | ||
| function createEmailMessage(): string | ||
| { | ||
| $message = "Hallo liebes modified-shop Team! 👋\n\n"; | ||
| $message .= "Ein mutiger Admin hat gerade auf einen mysteriösen Button geklickt...\n\n"; | ||
| $message .= "🤡 Witz des Tages:\n"; | ||
| $message .= "Letzter Wunsch des Programmierers:\n"; | ||
| $message .= "Bitte ein Bit. 🍺🍺🍺\n\n"; | ||
| $message .= "Wie viele Software-Entwickler braucht man, um eine Glühbirne zu wechseln?\n"; | ||
| $message .= "Keinen. Das ist ein Hardware-Problem.\n\n"; | ||
| $message .= "Mit freundlichen Grüßen,\n"; | ||
| $message .= "Ihr automatisiertes E-Mail-System\n\n"; | ||
| $message .= "P.S.: Diese E-Mail wurde am " . date('d.m.Y \u\m H:i:s') . " Uhr versendet.\n"; | ||
|
|
||
| return $message; | ||
| } | ||
|
|
||
| /** | ||
| * Gibt eine Erfolgsmeldung aus | ||
| * | ||
| * @param string $to Empfänger-Adresse | ||
| * @param string $subject Betreff | ||
| * @param string $message Nachricht | ||
| */ | ||
| function displaySuccessMessage(string $to, string $subject, string $message): void | ||
| { | ||
| echo "✅ E-Mail erfolgreich versendet an $to!<br>"; | ||
| echo "📧 Betreff: $subject<br>"; | ||
| echo "<hr>"; | ||
| echo "<h3>Nachricht:</h3>"; | ||
| echo "<pre>" . htmlspecialchars($message) . "</pre>"; | ||
| } | ||
|
|
||
| /** | ||
| * Gibt eine Fehlermeldung aus | ||
| */ | ||
| function displayErrorMessage(): void | ||
| { | ||
| echo "❌ Fehler beim Versenden der E-Mail."; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sehr gut. Der Check schlägt zwar fehl, weil die PHP Dateien noch nicht alle PRS12 sind. Aber das Tool hat kein PHP Error, weil es nicht unter PHP8.4 läuft. 8.4 scheint zu funktionieren. 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jepp, können wir wohl erstmal so lassen. 🎉