From bffa7c052bffc0f7afc43130cc1dfab76dad51fe Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 18 Sep 2025 09:36:20 +0200 Subject: [PATCH 1/5] Update sniffs to PHPCS v4. --- PSR2R/Sniffs/Commenting/DocBlockParamSniff.php | 2 +- PSR2R/Sniffs/Methods/MethodDeclarationSniff.php | 2 +- .../NoInlineFullyQualifiedClassNameSniff.php | 2 +- PSR2R/Tools/Traits/SignatureTrait.php | 2 +- PSR2R/ruleset.xml | 1 + composer.json | 11 ++++++----- phpcs.xml | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/PSR2R/Sniffs/Commenting/DocBlockParamSniff.php b/PSR2R/Sniffs/Commenting/DocBlockParamSniff.php index c94be51..e0231d0 100644 --- a/PSR2R/Sniffs/Commenting/DocBlockParamSniff.php +++ b/PSR2R/Sniffs/Commenting/DocBlockParamSniff.php @@ -145,7 +145,7 @@ private function getMethodSignature(File $phpCsFile, int $stackPtr): array { while ($nextVariableIndex = $phpCsFile->findNext(T_VARIABLE, $i + 1, $endIndex)) { $typehint = $default = null; $possibleTypeHint = - $phpCsFile->findPrevious([T_ARRAY_HINT, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3); + $phpCsFile->findPrevious([T_ARRAY, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3); if ($possibleTypeHint) { $typehint = $possibleTypeHint; } diff --git a/PSR2R/Sniffs/Methods/MethodDeclarationSniff.php b/PSR2R/Sniffs/Methods/MethodDeclarationSniff.php index b937878..787b978 100644 --- a/PSR2R/Sniffs/Methods/MethodDeclarationSniff.php +++ b/PSR2R/Sniffs/Methods/MethodDeclarationSniff.php @@ -51,7 +51,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop $tokens = $phpcsFile->getTokens(); $methodName = $phpcsFile->getDeclarationName($stackPtr); - if ($methodName === null) { + if (!$methodName) { // Ignore closures. return; } diff --git a/PSR2R/Sniffs/Namespaces/NoInlineFullyQualifiedClassNameSniff.php b/PSR2R/Sniffs/Namespaces/NoInlineFullyQualifiedClassNameSniff.php index 633f65f..2a00883 100644 --- a/PSR2R/Sniffs/Namespaces/NoInlineFullyQualifiedClassNameSniff.php +++ b/PSR2R/Sniffs/Namespaces/NoInlineFullyQualifiedClassNameSniff.php @@ -772,7 +772,7 @@ protected function checkUseForReturnTypeHint(File $phpcsFile, int $stackPtr): vo $extractedUseStatement = ''; $lastSeparatorIndex = null; while (true) { - if (!$this->isGivenKind([T_NS_SEPARATOR, T_STRING, T_RETURN_TYPE], $tokens[$j])) { + if (!$this->isGivenKind([T_NS_SEPARATOR, T_STRING], $tokens[$j])) { break; } diff --git a/PSR2R/Tools/Traits/SignatureTrait.php b/PSR2R/Tools/Traits/SignatureTrait.php index 4efe116..a9a8595 100644 --- a/PSR2R/Tools/Traits/SignatureTrait.php +++ b/PSR2R/Tools/Traits/SignatureTrait.php @@ -25,7 +25,7 @@ protected function getMethodSignature(File $phpCsFile, int $stackPtr): array { $i = $startIndex; while ($nextVariableIndex = $phpCsFile->findNext(T_VARIABLE, $i + 1, $endIndex)) { $typehintIndex = $defaultIndex = $default = null; - $possibleTypeHint = $phpCsFile->findPrevious([T_ARRAY_HINT, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3); + $possibleTypeHint = $phpCsFile->findPrevious([T_ARRAY, T_CALLABLE], $nextVariableIndex - 1, $nextVariableIndex - 3); if ($possibleTypeHint) { $typehintIndex = $possibleTypeHint; } diff --git a/PSR2R/ruleset.xml b/PSR2R/ruleset.xml index 245730c..c08464c 100644 --- a/PSR2R/ruleset.xml +++ b/PSR2R/ruleset.xml @@ -18,6 +18,7 @@ \.json + diff --git a/composer.json b/composer.json index b04793e..2131c43 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,14 @@ ], "require": { "php": ">=8.1", - "php-collective/code-sniffer": "^0.3.0", - "slevomat/coding-standard": "^8.16.0", - "squizlabs/php_codesniffer": "^3.7.0" + "php-collective/code-sniffer": "dev-next", + "slevomat/coding-standard": "dev-phpcs4", + "squizlabs/php_codesniffer": "^4.0.0" }, "require-dev": { "phpunit/phpunit": "^10.3 || ^11.5 || ^12.0", - "phpstan/phpstan": "^2.1.0" + "phpstan/phpstan": "^2.1.0", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0" }, "autoload": { "psr-4": { @@ -32,7 +33,7 @@ } }, "prefer-stable": true, - "minimum-stability": "stable", + "minimum-stability": "dev", "bin": [ "bin/tokenize", "bin/sniff" diff --git a/phpcs.xml b/phpcs.xml index 007c9c6..f6effd8 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,6 +1,6 @@ - + From 8ac432dd09e51a20f1db31f25113167b85071b0d Mon Sep 17 00:00:00 2001 From: mscherer Date: Thu, 18 Sep 2025 11:09:04 +0200 Subject: [PATCH 2/5] Update sniffs to PHPCS v4. --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 2131c43..6064c55 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,6 @@ "require": { "php": ">=8.1", "php-collective/code-sniffer": "dev-next", - "slevomat/coding-standard": "dev-phpcs4", "squizlabs/php_codesniffer": "^4.0.0" }, "require-dev": { From 8262d99e80aa56196fe2399714a533d0c586de3a Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Tue, 30 Sep 2025 01:22:53 +0200 Subject: [PATCH 3/5] Update php-collective/code-sniffer version to dev-master --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6064c55..bd9a9f6 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "php": ">=8.1", - "php-collective/code-sniffer": "dev-next", + "php-collective/code-sniffer": "dev-master", "squizlabs/php_codesniffer": "^4.0.0" }, "require-dev": { From 2c465b46e58a3aee538153ee9cf5963e4c5318ba Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 30 Sep 2025 01:31:21 +0200 Subject: [PATCH 4/5] Update sniffs to PHPCS v4. --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index bd9a9f6..3fc80ae 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "php": ">=8.1", - "php-collective/code-sniffer": "dev-master", + "php-collective/code-sniffer": "^0.4", "squizlabs/php_codesniffer": "^4.0.0" }, "require-dev": { @@ -32,7 +32,7 @@ } }, "prefer-stable": true, - "minimum-stability": "dev", + "minimum-stability": "stable", "bin": [ "bin/tokenize", "bin/sniff" From 6fab75df40640d2c6cb6a898e5fd6d8492bbee86 Mon Sep 17 00:00:00 2001 From: mscherer Date: Tue, 30 Sep 2025 01:32:22 +0200 Subject: [PATCH 5/5] Update sniffs to PHPCS v4. --- phpcs.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index f6effd8..143cb77 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,7 +1,5 @@ - - PSR2R/