diff --git a/ptscs/Sniffs/PSR12/FileHeaderSniff.php b/ptscs/Sniffs/PSR12/FileHeaderSniff.php index 990d351..bdfea02 100644 --- a/ptscs/Sniffs/PSR12/FileHeaderSniff.php +++ b/ptscs/Sniffs/PSR12/FileHeaderSniff.php @@ -19,9 +19,9 @@ final class FileHeaderSniff implements Sniff /** * Returns an array of tokens this test wants to listen for. * - * @return array + * @return int[] */ - public function register() + public function register(): array { return [\T_OPEN_TAG]; } @@ -33,9 +33,8 @@ public function register() * @param int $stackPtr The position of the current * token in the stack. * - * @return int|null */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, $stackPtr): ?int { $tokens = $phpcsFile->getTokens(); @@ -49,7 +48,7 @@ public function process(File $phpcsFile, $stackPtr) $headerLines = $this->getHeaderLines($phpcsFile, $openTag); if (empty($headerLines) === true && $openTag === $stackPtr) { // No content in the file. - return; + return null; } $possibleHeaders[$openTag] = $headerLines; @@ -123,7 +122,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return array */ - public function getHeaderLines(File $phpcsFile, $stackPtr) + public function getHeaderLines(File $phpcsFile, $stackPtr): array { $tokens = $phpcsFile->getTokens(); @@ -276,12 +275,9 @@ public function getHeaderLines(File $phpcsFile, $stackPtr) * Check the spacing and grouping of the statements inside each header block. * * @param File $phpcsFile The file being scanned. - * @param array $headerLines Header information, as sourced - * from getHeaderLines(). - * - * @return int|null + * @param array $headerLines Header information, as sourced from getHeaderLines(). */ - public function processHeaderLines(File $phpcsFile, $headerLines) + public function processHeaderLines(File $phpcsFile, $headerLines): void { $tokens = $phpcsFile->getTokens(); diff --git a/ptscs/ruleset.xml b/ptscs/ruleset.xml index 5c226fc..84f0e62 100644 --- a/ptscs/ruleset.xml +++ b/ptscs/ruleset.xml @@ -194,6 +194,11 @@ + + + + +