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..3fc80ae 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,13 @@ ], "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": "^0.4", + "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": { diff --git a/phpcs.xml b/phpcs.xml index 007c9c6..143cb77 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,7 +1,5 @@ - - PSR2R/