Skip to content

Commit

Permalink
Merge pull request #2896 from briannesbitt/feature/phpcs-update
Browse files Browse the repository at this point in the history
Update phpcs version
  • Loading branch information
kylekatarnls authored Dec 7, 2023
2 parents 87baf0e + ab0c435 commit 6264c67
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 3 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ jobs:
- name: Checkout the code
uses: actions/checkout@v4

- name: Ignore comments in switch
run: php tests/remove-comments-in-switch.php

- name: Check for code style violation with PHP-CS-Fixer
uses: OskarStark/php-cs-fixer-ga@3.7.0
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --diff --dry-run
2 changes: 1 addition & 1 deletion tests/Laravel/laravel-10.x.multi-tester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ projects:
install:
- composer require psr/log:2.0.0 --no-update
- composer update --prefer-dist --no-interaction --prefer-stable
- echo -e "\nREDIS_HOST=127.0.0.1\nREDIS_PORT=6379" >> .env
- echo -e "\nREDIS_HOST=\"127.0.0.1\"\nREDIS_PORT=6379" >> .env
2 changes: 1 addition & 1 deletion tests/Laravel/laravel-master.multi-tester.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ projects:
success_only: true
install:
- composer update --prefer-dist --no-interaction --prefer-stable
- echo -e "\nREDIS_HOST=127.0.0.1\nREDIS_PORT=6379" >> .env
- echo -e "\nREDIS_HOST=\"127.0.0.1\"\nREDIS_PORT=6379" >> .env
43 changes: 43 additions & 0 deletions tests/remove-comments-in-switch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

/**
* This file is part of the Carbon package.
*
* (c) Brian Nesbitt <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$files = [
__DIR__.'/../src/Carbon/Traits/Date.php',
__DIR__.'/../src/Carbon/Traits/Units.php',
__DIR__.'/../src/Carbon/Lang/fr.php',
];

$comments = [
'// @property',
'// @call ',
'// Words with feminine grammatical gender: semaine',
];

foreach ($files as $file) {
$contents = str_replace("\r", '', file_get_contents($file));
$newContents = implode("\n", array_filter(explode("\n", $contents), static function ($line) use ($comments) {
$code = trim($line);

foreach ($comments as $comment) {
if (str_starts_with($code, $comment)) {
return false;
}
}

return true;
}));

if ($newContents !== $contents) {
file_put_contents($file, $newContents);
}
}

0 comments on commit 6264c67

Please sign in to comment.