From cd8b2e70c427a1bf468bd0f25aeddd28d2aa84ad Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 3 Aug 2024 13:57:17 +0530 Subject: [PATCH 1/2] Add sniff for arrow functions. --- .github/workflows/ci.yml | 8 ++++---- CakePHP/ruleset.xml | 1 + docs/README.md | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 75cc169..4075523 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,14 +15,14 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['8.1', '8.2'] + php-version: ['8.1', '8.2', '8.3'] dependencies: ['highest'] include: - php-version: '8.1' dependencies: 'lowest' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -31,7 +31,7 @@ jobs: coverage: none - name: Composer install - uses: ramsey/composer-install@v2 + uses: ramsey/composer-install@v3 with: dependency-versions: ${{ matrix.dependencies }} composer-options: --ignore-platform-reqs @@ -54,7 +54,7 @@ jobs: coverage: none - name: Composer install - uses: ramsey/composer-install@v2 + uses: ramsey/composer-install@v3 with: composer-options: --ignore-platform-reqs diff --git a/CakePHP/ruleset.xml b/CakePHP/ruleset.xml index af3f227..dfe2ecd 100644 --- a/CakePHP/ruleset.xml +++ b/CakePHP/ruleset.xml @@ -216,6 +216,7 @@ + diff --git a/docs/README.md b/docs/README.md index aba42c7..6aed4e1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ # CakePHP ruleset -The CakePHP standard contains 143 sniffs +The CakePHP standard contains 144 sniffs CakePHP (20 sniffs) ------------------- @@ -95,7 +95,7 @@ PSR2 (9 sniffs) - PSR2.Methods.FunctionClosingBrace - PSR2.Methods.MethodDeclaration -SlevomatCodingStandard (39 sniffs) +SlevomatCodingStandard (40 sniffs) ---------------------------------- - SlevomatCodingStandard.Arrays.TrailingArrayComma - SlevomatCodingStandard.Classes.ClassConstantVisibility @@ -113,6 +113,7 @@ SlevomatCodingStandard (39 sniffs) - SlevomatCodingStandard.ControlStructures.NewWithParentheses - SlevomatCodingStandard.ControlStructures.RequireNullCoalesceOperator - SlevomatCodingStandard.Exceptions.DeadCatch +- SlevomatCodingStandard.Functions.ArrowFunctionDeclaration - SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses - SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation - SlevomatCodingStandard.Namespaces.NamespaceDeclaration From 2876076bbdbd6cbf9ccacaa0dd883d0139a97d47 Mon Sep 17 00:00:00 2001 From: ADmad Date: Sat, 3 Aug 2024 18:55:34 +0530 Subject: [PATCH 2/2] Update dependencies. composer install now works without having to ignore platform dependencies. --- .github/workflows/ci.yml | 3 -- .../Sniffs/Classes/ReturnTypeHintSniff.php | 2 +- ...fixed => ReturnTypeHintUnitTest.inc.fixed} | 3 -- composer.json | 6 ++-- docs/README.md | 28 +++++++++---------- 5 files changed, 18 insertions(+), 24 deletions(-) rename CakePHP/Tests/Classes/{ReturnTypeHintUnitTestinc.fixed => ReturnTypeHintUnitTest.inc.fixed} (85%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4075523..4a98bd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,6 @@ jobs: uses: ramsey/composer-install@v3 with: dependency-versions: ${{ matrix.dependencies }} - composer-options: --ignore-platform-reqs - name: Run PHPUnit run: composer phpunit @@ -55,8 +54,6 @@ jobs: - name: Composer install uses: ramsey/composer-install@v3 - with: - composer-options: --ignore-platform-reqs - name: Run PHP CodeSniffer run: vendor/bin/phpcs --report=checkstyle | cs2pr diff --git a/CakePHP/Sniffs/Classes/ReturnTypeHintSniff.php b/CakePHP/Sniffs/Classes/ReturnTypeHintSniff.php index 9f1764c..52ea811 100644 --- a/CakePHP/Sniffs/Classes/ReturnTypeHintSniff.php +++ b/CakePHP/Sniffs/Classes/ReturnTypeHintSniff.php @@ -58,7 +58,7 @@ public function process(File $phpcsFile, $stackPtr) // We skip for interface methods if (empty($tokens[$stackPtr]['scope_opener']) || empty($tokens[$stackPtr]['scope_closer'])) { - return []; + return; } $returnTokenCode = $tokens[$startIndex]['code']; diff --git a/CakePHP/Tests/Classes/ReturnTypeHintUnitTestinc.fixed b/CakePHP/Tests/Classes/ReturnTypeHintUnitTest.inc.fixed similarity index 85% rename from CakePHP/Tests/Classes/ReturnTypeHintUnitTestinc.fixed rename to CakePHP/Tests/Classes/ReturnTypeHintUnitTest.inc.fixed index e433764..bbdd97a 100644 --- a/CakePHP/Tests/Classes/ReturnTypeHintUnitTestinc.fixed +++ b/CakePHP/Tests/Classes/ReturnTypeHintUnitTest.inc.fixed @@ -1,9 +1,6 @@ =8.1.0", "phpstan/phpdoc-parser": "^1.4.5", - "slevomat/coding-standard": "^8.4", - "squizlabs/php_codesniffer": "^3.7.1" + "slevomat/coding-standard": "^8.15", + "squizlabs/php_codesniffer": "^3.9" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^9.3.4" }, "autoload": { "psr-4": { diff --git a/docs/README.md b/docs/README.md index 6aed4e1..ade369b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -54,7 +54,7 @@ Generic (25 sniffs) - Generic.WhiteSpace.ScopeIndent PEAR (1 sniff) ---------------- +-------------- - PEAR.Functions.ValidDefaultValue PSR1 (3 sniffs) @@ -63,6 +63,18 @@ PSR1 (3 sniffs) - PSR1.Files.SideEffects - PSR1.Methods.CamelCapsMethodName +PSR2 (9 sniffs) +--------------- +- PSR2.Classes.ClassDeclaration +- PSR2.Classes.PropertyDeclaration +- PSR2.ControlStructures.ElseIfDeclaration +- PSR2.ControlStructures.SwitchDeclaration +- PSR2.Files.ClosingTag +- PSR2.Files.EndFileNewline +- PSR2.Methods.FunctionCallSignature +- PSR2.Methods.FunctionClosingBrace +- PSR2.Methods.MethodDeclaration + PSR12 (17 sniffs) ----------------- - PSR12.Classes.AnonClassDeclaration @@ -83,18 +95,6 @@ PSR12 (17 sniffs) - PSR12.Properties.ConstantVisibility - PSR12.Traits.UseDeclaration -PSR2 (9 sniffs) ---------------- -- PSR2.Classes.ClassDeclaration -- PSR2.Classes.PropertyDeclaration -- PSR2.ControlStructures.ElseIfDeclaration -- PSR2.ControlStructures.SwitchDeclaration -- PSR2.Files.ClosingTag -- PSR2.Files.EndFileNewline -- PSR2.Methods.FunctionCallSignature -- PSR2.Methods.FunctionClosingBrace -- PSR2.Methods.MethodDeclaration - SlevomatCodingStandard (40 sniffs) ---------------------------------- - SlevomatCodingStandard.Arrays.TrailingArrayComma @@ -170,5 +170,5 @@ Squiz (28 sniffs) - Squiz.WhiteSpace.SuperfluousWhitespace Zend (1 sniff) ---------------- +-------------- - Zend.NamingConventions.ValidVariableName \ No newline at end of file