diff --git a/autoload.php b/autoload.php index c295b2ea75..e61c472fb1 100644 --- a/autoload.php +++ b/autoload.php @@ -210,7 +210,7 @@ public static function determineLoadedClass($classesBeforeLoad, $classesAfterLoa // That way, at the end, only the "main" class just included will remain. $newClasses = array_reduce( $newClasses, - function ($remaining, $current) { + static function ($remaining, $current) { return array_diff($remaining, class_parents($current)); }, $newClasses diff --git a/src/Reports/Summary.php b/src/Reports/Summary.php index 165ad64b0c..1b048e6796 100644 --- a/src/Reports/Summary.php +++ b/src/Reports/Summary.php @@ -98,7 +98,7 @@ public function generate( uksort( $reportFiles, - function ($keyA, $keyB) { + static function ($keyA, $keyB) { $pathPartsA = explode(DIRECTORY_SEPARATOR, $keyA); $pathPartsB = explode(DIRECTORY_SEPARATOR, $keyB); diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php index d9528dccf8..c6d0e34806 100644 --- a/src/Sniffs/AbstractPatternSniff.php +++ b/src/Sniffs/AbstractPatternSniff.php @@ -744,17 +744,17 @@ protected function registerSupplementary() }//end registerSupplementary() - /** - * Processes any tokens registered with registerSupplementary(). - * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where to - * process the skip. - * @param int $stackPtr The position in the tokens stack to - * process. - * - * @return void - * @see registerSupplementary() - */ + /** + * Processes any tokens registered with registerSupplementary(). + * + * @param \PHP_CodeSniffer\Files\File $phpcsFile The PHP_CodeSniffer file where to + * process the skip. + * @param int $stackPtr The position in the tokens stack to + * process. + * + * @return void + * @see registerSupplementary() + */ protected function processSupplementary(File $phpcsFile, $stackPtr) { diff --git a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php index d6fe2e8253..34b43e5d17 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php @@ -195,7 +195,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) // Skip constructor and destructor. $methodName = $phpcsFile->getDeclarationName($stackPtr); - $isSpecialMethod = in_array($methodName, $this->specialMethods, true); + $isSpecialMethod = in_array($methodName, $this->specialMethods, true); $return = null; foreach ($tokens[$commentStart]['comment_tags'] as $tag) { diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index c7003faaf2..254c4143b1 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -67,7 +67,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) // Skip constructor and destructor. $methodName = $phpcsFile->getDeclarationName($stackPtr); - $isSpecialMethod = in_array($methodName, $this->specialMethods, true); + $isSpecialMethod = in_array($methodName, $this->specialMethods, true); if ($return !== null) { $content = $tokens[($return + 2)]['content']; @@ -781,7 +781,7 @@ protected function checkInheritdoc(File $phpcsFile, $stackPtr, $commentStart) T_DOC_COMMENT_STAR, ]; for ($i = $commentStart; $i <= $tokens[$commentStart]['comment_closer']; $i++) { - if (in_array($tokens[$i]['code'], $allowedTokens) === false) { + if (in_array($tokens[$i]['code'], $allowedTokens, true) === false) { $trimmedContent = strtolower(trim($tokens[$i]['content'])); if ($trimmedContent === '{@inheritdoc}') { diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index 055c41604d..2f8d0737f5 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -127,7 +127,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr) return; } - // Support both a var type and a description. + // Support both a var type and a description. preg_match('`^((?:\|?(?:array\([^\)]*\)|[\\\\a-z0-9\[\]]+))*)( .*)?`i', $tokens[($foundVar + 2)]['content'], $varParts); if (isset($varParts[1]) === false) { return; diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index f1b9044f10..eac7c20bef 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -68,7 +68,7 @@ public function process(File $phpcsFile, $stackPtr) $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true); // Allow for PHP 8.4+ fully qualified use of exit/die. - if ($tokens[$stackPtr]['code'] === \T_EXIT && $tokens[$prev]['code'] === \T_NS_SEPARATOR) { + if ($tokens[$stackPtr]['code'] === T_EXIT && $tokens[$prev]['code'] === T_NS_SEPARATOR) { $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true); } diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php index 3eff4e0fff..159aece6b3 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php @@ -63,9 +63,9 @@ public function process(File $phpcsFile, $stackPtr) $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($openBrace + 1), null, true); if ($nextContent === $tokens[$stackPtr]['scope_closer']) { - // The next bit of content is the closing brace, so this - // is an empty function and should have a blank line - // between the opening and closing braces. + // The next bit of content is the closing brace, so this + // is an empty function and should have a blank line + // between the opening and closing braces. return; } diff --git a/src/Util/Cache.php b/src/Util/Cache.php index 408de96e7d..e0ee9c8b4b 100644 --- a/src/Util/Cache.php +++ b/src/Util/Cache.php @@ -105,7 +105,7 @@ public static function load(Ruleset $ruleset, Config $config) ); $filter = new RecursiveCallbackFilterIterator( $di, - function ($file, $key, $iterator) { + static function ($file, $key, $iterator) { // Skip non-php files. $filename = $file->getFilename(); if ($file->isFile() === true && substr($filename, -4) !== '.php') { diff --git a/src/Util/MessageCollector.php b/src/Util/MessageCollector.php index 6db9414c18..bd9991c49a 100644 --- a/src/Util/MessageCollector.php +++ b/src/Util/MessageCollector.php @@ -298,7 +298,7 @@ private function arrayColumn(array $input, $columnKey) } // PHP 5.4. - $callback = function ($row) use ($columnKey) { + $callback = static function ($row) use ($columnKey) { return $row[$columnKey]; }; diff --git a/tests/Core/Tokenizers/PHP/DNFTypesTest.php b/tests/Core/Tokenizers/PHP/DNFTypesTest.php index 312df1b378..9e17d4d134 100644 --- a/tests/Core/Tokenizers/PHP/DNFTypesTest.php +++ b/tests/Core/Tokenizers/PHP/DNFTypesTest.php @@ -451,16 +451,16 @@ public static function dataDNFTypeParentheses() 'testMarker' => '/* testDNFTypeWithPHP84FinalKeywordAndStatic */', ], 'OO property type: asymmetric visibility, private(set)' => [ - 'testMarker' => '/* testDNFTypePropertyWithPrivateSet */', + 'testMarker' => '/* testDNFTypePropertyWithPrivateSet */', ], 'OO property type: asymmetric vis, public private(set)' => [ - 'testMarker' => '/* testDNFTypePropertyWithPublicPrivateSet */', + 'testMarker' => '/* testDNFTypePropertyWithPublicPrivateSet */', ], 'OO property type: asymmetric visibility, protected(set)' => [ - 'testMarker' => '/* testDNFTypePropertyWithProtectedSet */', + 'testMarker' => '/* testDNFTypePropertyWithProtectedSet */', ], 'OO property type: asymmetric vis, public protected(set)' => [ - 'testMarker' => '/* testDNFTypePropertyWithPublicProtectedSet */', + 'testMarker' => '/* testDNFTypePropertyWithPublicProtectedSet */', ], 'OO property type: with only abstract keyword' => [ 'testMarker' => '/* testDNFTypeWithPHP84AbstractKeyword */',