From 743e2ad7ec70611e5511ed4258c73152782f8721 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:52:52 +0200 Subject: [PATCH 01/15] 4.0 | PHPCS Framework classes: add parameter types --- autoload.php | 12 ++++++------ scripts/build-phar.php | 2 +- src/Config.php | 36 ++++++++++++++++++------------------ src/Fixer.php | 22 +++++++++++----------- src/Reporter.php | 10 +++++----- src/Ruleset.php | 19 ++++++++++--------- src/Runner.php | 10 +++++----- tests/ConfigDouble.php | 6 +++--- 8 files changed, 59 insertions(+), 58 deletions(-) diff --git a/autoload.php b/autoload.php index 3f39599746..fb47464e6b 100644 --- a/autoload.php +++ b/autoload.php @@ -65,7 +65,7 @@ class Autoload * * @return bool */ - public static function load($className) + public static function load(string $className) { // Include the composer autoloader if there is one, but re-register it // so this autoloader runs before the composer one as we need to include @@ -151,7 +151,7 @@ public static function load($className) * * @return string The fully qualified name of the class in the loaded file. */ - public static function loadFile($path) + public static function loadFile(string $path) { if (strpos(__DIR__, 'phar://') !== 0) { $path = realpath($path); @@ -195,7 +195,7 @@ public static function loadFile($path) * * @return string The fully qualified name of the class in the loaded file. */ - public static function determineLoadedClass($classesBeforeLoad, $classesAfterLoad) + public static function determineLoadedClass(array $classesBeforeLoad, array $classesAfterLoad) { $className = null; @@ -256,7 +256,7 @@ static function ($remaining, $current) { * * @return void */ - public static function addSearchPath($path, $nsPrefix='') + public static function addSearchPath(string $path, string $nsPrefix='') { self::$searchPaths[$path] = rtrim(trim((string) $nsPrefix), '\\'); @@ -283,7 +283,7 @@ public static function getSearchPaths() * @throws \Exception If the file path has not been loaded. * @return string */ - public static function getLoadedClassName($path) + public static function getLoadedClassName(string $path) { if (isset(self::$loadedClasses[$path]) === false) { throw new Exception("Cannot get class name for $path; file has not been included"); @@ -302,7 +302,7 @@ public static function getLoadedClassName($path) * @throws \Exception If the class name has not been loaded. * @return string */ - public static function getLoadedFileName($className) + public static function getLoadedFileName(string $className) { if (isset(self::$loadedFiles[$className]) === false) { throw new Exception("Cannot get file name for $className; class has not been included"); diff --git a/scripts/build-phar.php b/scripts/build-phar.php index fb18d89e30..84deb18382 100644 --- a/scripts/build-phar.php +++ b/scripts/build-phar.php @@ -46,7 +46,7 @@ * * @throws \PHP_CodeSniffer\Exceptions\RuntimeException When tokenizer errors are encountered. */ -function stripWhitespaceAndComments($fullpath, $config) +function stripWhitespaceAndComments(string $fullpath, Config $config) { $contents = file_get_contents($fullpath); diff --git a/src/Config.php b/src/Config.php index 818a1a1c77..ebd8e0511a 100644 --- a/src/Config.php +++ b/src/Config.php @@ -252,7 +252,7 @@ class Config * @return mixed * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid. */ - public function __get($name) + public function __get(string $name) { if (array_key_exists($name, $this->settings) === false) { throw new RuntimeException("ERROR: unable to get value of property \"$name\""); @@ -288,7 +288,7 @@ public function __get($name) * @return void * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid. */ - public function __set($name, $value) + public function __set(string $name, $value) { if (array_key_exists($name, $this->settings) === false) { throw new RuntimeException("Can't __set() $name; setting doesn't exist"); @@ -359,7 +359,7 @@ public function __set($name, $value) * * @return bool */ - public function __isset($name) + public function __isset(string $name) { return isset($this->settings[$name]); @@ -373,7 +373,7 @@ public function __isset($name) * * @return void */ - public function __unset($name) + public function __unset(string $name) { $this->settings[$name] = null; @@ -399,7 +399,7 @@ public function getSettings() * * @return void */ - public function setSettings($settings) + public function setSettings(array $settings) { $this->settings = $settings; @@ -415,7 +415,7 @@ public function setSettings($settings) * * @return void */ - public function __construct(array $cliArgs=[], $dieOnUnknownArg=true) + public function __construct(array $cliArgs=[], bool $dieOnUnknownArg=true) { if (defined('PHP_CODESNIFFER_IN_TESTS') === true) { // Let everything through during testing so that we can @@ -498,7 +498,7 @@ public function __construct(array $cliArgs=[], $dieOnUnknownArg=true) * * @return void */ - public function setCommandLineValues($args) + public function setCommandLineValues(array $args) { $this->cliArgs = $args; $numArgs = count($args); @@ -675,7 +675,7 @@ public function restoreDefaults() * @return void * @throws \PHP_CodeSniffer\Exceptions\DeepExitException */ - public function processShortArgument($arg, $pos) + public function processShortArgument(string $arg, int $pos) { switch ($arg) { case 'h': @@ -787,7 +787,7 @@ public function processShortArgument($arg, $pos) * @return void * @throws \PHP_CodeSniffer\Exceptions\DeepExitException */ - public function processLongArgument($arg, $pos) + public function processLongArgument(string $arg, int $pos) { switch ($arg) { case 'help': @@ -1319,7 +1319,7 @@ public function processLongArgument($arg, $pos) * @return array * @throws \PHP_CodeSniffer\Exceptions\DeepExitException When any of the provided codes are not valid as sniff codes. */ - private function parseSniffCodes($input, $argument) + private function parseSniffCodes(string $input, string $argument) { $errors = []; $sniffs = []; @@ -1408,7 +1408,7 @@ static function ($carry, $item) { * @return void * @throws \PHP_CodeSniffer\Exceptions\DeepExitException */ - public function processUnknownArgument($arg, $pos) + public function processUnknownArgument(string $arg, int $pos) { // We don't know about any additional switches; just files. if ($arg[0] === '-') { @@ -1434,7 +1434,7 @@ public function processUnknownArgument($arg, $pos) * @return void * @throws \PHP_CodeSniffer\Exceptions\DeepExitException */ - public function processFilePath($path) + public function processFilePath(string $path) { // If we are processing STDIN, don't record any files to check. if ($this->stdin === true) { @@ -1490,7 +1490,7 @@ public function printUsage() * * @return string|void */ - public function printShortUsage($returnOutput=false) + public function printShortUsage(bool $returnOutput=false) { if (PHP_CODESNIFFER_CBF === true) { $usage = 'Run "phpcbf --help" for usage information'; @@ -1560,7 +1560,7 @@ public function printPHPCBFUsage() * @see setConfigData() * @see getAllConfigData() */ - public static function getConfigData($key) + public static function getConfigData(string $key) { $phpCodeSnifferConfig = self::getAllConfigData(); @@ -1585,7 +1585,7 @@ public static function getConfigData($key) * @return string|null * @see getConfigData() */ - public static function getExecutablePath($name) + public static function getExecutablePath(string $name) { $data = self::getConfigData($name.'_path'); if ($data !== null) { @@ -1633,7 +1633,7 @@ public static function getExecutablePath($name) * @see getConfigData() * @throws \PHP_CodeSniffer\Exceptions\DeepExitException If the config file can not be written. */ - public function setConfigData($key, $value, $temp=false) + public function setConfigData(string $key, ?string $value, bool $temp=false) { if (isset($this->overriddenDefaults['runtime-set']) === true && isset($this->overriddenDefaults['runtime-set'][$key]) === true @@ -1749,7 +1749,7 @@ public static function getAllConfigData() * * @return string */ - public function prepareConfigDataForDisplay($data) + public function prepareConfigDataForDisplay(array $data) { if (empty($data) === true) { return ''; @@ -1786,7 +1786,7 @@ public function prepareConfigDataForDisplay($data) * * @return void */ - public function printConfigData($data) + public function printConfigData(array $data) { echo $this->prepareConfigDataForDisplay($data); diff --git a/src/Fixer.php b/src/Fixer.php index fcfbd2e5db..b2da901c67 100644 --- a/src/Fixer.php +++ b/src/Fixer.php @@ -235,7 +235,7 @@ public function fixFile() * * @throws \PHP_CodeSniffer\Exceptions\RuntimeException When the diff command fails. */ - public function generateDiff($filePath=null, $colors=true) + public function generateDiff(?string $filePath=null, bool $colors=true) { if ($filePath === null) { $filePath = $this->currentFile->getFilename(); @@ -378,7 +378,7 @@ public function getContents() * * @return string */ - public function getTokenContent($stackPtr) + public function getTokenContent(int $stackPtr) { if ($this->inChangeset === true && isset($this->changeset[$stackPtr]) === true @@ -508,7 +508,7 @@ public function rollbackChangeset() * * @return bool If the change was accepted. */ - public function replaceToken($stackPtr, $content) + public function replaceToken(int $stackPtr, string $content) { if ($this->inConflict === true) { return false; @@ -628,7 +628,7 @@ public function replaceToken($stackPtr, $content) * * @return bool If a change was reverted. */ - public function revertToken($stackPtr) + public function revertToken(int $stackPtr) { if (isset($this->fixedTokens[$stackPtr]) === false) { return false; @@ -689,7 +689,7 @@ public function revertToken($stackPtr) * * @return bool If the change was accepted. */ - public function substrToken($stackPtr, $start, $length=null) + public function substrToken(int $stackPtr, int $start, ?int $length=null) { $current = $this->getTokenContent($stackPtr); @@ -711,7 +711,7 @@ public function substrToken($stackPtr, $start, $length=null) * * @return bool If the change was accepted. */ - public function addNewline($stackPtr) + public function addNewline(int $stackPtr) { $current = $this->getTokenContent($stackPtr); return $this->replaceToken($stackPtr, $current.$this->currentFile->eolChar); @@ -726,7 +726,7 @@ public function addNewline($stackPtr) * * @return bool If the change was accepted. */ - public function addNewlineBefore($stackPtr) + public function addNewlineBefore(int $stackPtr) { $current = $this->getTokenContent($stackPtr); return $this->replaceToken($stackPtr, $this->currentFile->eolChar.$current); @@ -742,7 +742,7 @@ public function addNewlineBefore($stackPtr) * * @return bool If the change was accepted. */ - public function addContent($stackPtr, $content) + public function addContent(int $stackPtr, string $content) { $current = $this->getTokenContent($stackPtr); return $this->replaceToken($stackPtr, $current.$content); @@ -758,7 +758,7 @@ public function addContent($stackPtr, $content) * * @return bool If the change was accepted. */ - public function addContentBefore($stackPtr, $content) + public function addContentBefore(int $stackPtr, string $content) { $current = $this->getTokenContent($stackPtr); return $this->replaceToken($stackPtr, $content.$current); @@ -778,7 +778,7 @@ public function addContentBefore($stackPtr, $content) * * @return void */ - public function changeCodeBlockIndent($start, $end, $change) + public function changeCodeBlockIndent(int $start, int $end, int $change) { $tokens = $this->currentFile->getTokens(); @@ -835,7 +835,7 @@ public function changeCodeBlockIndent($start, $end, $change) * * @return string */ - private function getSniffCodeForDebug($className) + private function getSniffCodeForDebug(string $className) { try { $sniffCode = Common::getSniffCode($className); diff --git a/src/Reporter.php b/src/Reporter.php index 98bb8a82a7..38c2388449 100644 --- a/src/Reporter.php +++ b/src/Reporter.php @@ -187,7 +187,7 @@ public function __construct(Config $config) * * @return bool */ - public function __isset($name) + public function __isset(string $name) { return ($name === 'totalFixable' || $name === 'totalFixed'); @@ -207,7 +207,7 @@ public function __isset($name) * * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the setting name is invalid. */ - public function __get($name) + public function __get(string $name) { if ($name === 'totalFixable') { return ($this->totalFixableErrors + $this->totalFixableWarnings); @@ -232,7 +232,7 @@ public function __get($name) * * @throws \PHP_CodeSniffer\Exceptions\RuntimeException */ - public function __set($name, $value) + public function __set(string $name, $value) { throw new RuntimeException("ERROR: setting property \"Reporter::\${$name}\" is not allowed"); @@ -248,7 +248,7 @@ public function __set($name, $value) * * @throws \PHP_CodeSniffer\Exceptions\RuntimeException */ - public function __unset($name) + public function __unset(string $name) { throw new RuntimeException("ERROR: unsetting property \"Reporter::\${$name}\" is not allowed"); @@ -286,7 +286,7 @@ public function printReports() * * @return void */ - public function printReport($report) + public function printReport(string $report) { $reportClass = $this->reports[$report]['class']; $reportFile = $this->reports[$report]['output']; diff --git a/src/Ruleset.php b/src/Ruleset.php index ab3b5a83f2..de2d3ff1e5 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -22,6 +22,7 @@ use RecursiveDirectoryIterator; use RecursiveIteratorIterator; use ReflectionClass; +use SimpleXMLElement; use stdClass; class Ruleset @@ -528,7 +529,7 @@ private function displayCachedMessages() * @throws \PHP_CodeSniffer\Exceptions\RuntimeException - If the ruleset path is invalid. * - If a specified autoload file could not be found. */ - public function processRuleset($rulesetPath, $depth=0) + public function processRuleset(string $rulesetPath, int $depth=0) { $rulesetPath = Common::realpath($rulesetPath); if (PHP_CODESNIFFER_VERBOSITY > 1) { @@ -895,7 +896,7 @@ public function processRuleset($rulesetPath, $depth=0) * * @return array */ - private function expandSniffDirectory($directory, $depth=0) + private function expandSniffDirectory(string $directory, int $depth=0) { $sniffs = []; @@ -957,7 +958,7 @@ private function expandSniffDirectory($directory, $depth=0) * @return array * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the reference is invalid. */ - private function expandRulesetReference($ref, $rulesetDir, $depth=0) + private function expandRulesetReference(string $ref, string $rulesetDir, int $depth=0) { // Naming an (external) standard "Internal" is not supported. if (strtolower($ref) === 'internal') { @@ -1139,7 +1140,7 @@ private function expandRulesetReference($ref, $rulesetDir, $depth=0) * @return void * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If rule settings are invalid. */ - private function processRule($rule, $newSniffs, $depth=0) + private function processRule(SimpleXMLElement $rule, array $newSniffs, int $depth=0) { $ref = (string) $rule['ref']; $todo = [$ref]; @@ -1390,7 +1391,7 @@ private function processRule($rule, $newSniffs, $depth=0) * * @return bool */ - private function shouldProcessElement($element) + private function shouldProcessElement(SimpleXMLElement $element) { if (isset($element['phpcbf-only']) === false && isset($element['phpcs-only']) === false @@ -1429,7 +1430,7 @@ private function shouldProcessElement($element) * * @return void */ - public function registerSniffs($files, $restrictions, $exclusions) + public function registerSniffs(array $files, array $restrictions, array $exclusions) { $listeners = []; @@ -1615,7 +1616,7 @@ public function populateTokenListeners() * which doesn't declare the property or explicitly supports * dynamic properties. */ - public function setSniffProperty($sniffClass, $name, $settings) + public function setSniffProperty(string $sniffClass, string $name, array $settings) { // Setting a property for a sniff we are not using. if (isset($this->sniffs[$sniffClass]) === false) { @@ -1737,7 +1738,7 @@ private function getRealPropertyValue($value) * * @return array */ - public function getIgnorePatterns($listener=null) + public function getIgnorePatterns(?string $listener=null) { if ($listener === null) { return $this->ignorePatterns; @@ -1763,7 +1764,7 @@ public function getIgnorePatterns($listener=null) * * @return array */ - public function getIncludePatterns($listener=null) + public function getIncludePatterns(?string $listener=null) { if ($listener === null) { return $this->includePatterns; diff --git a/src/Runner.php b/src/Runner.php index 7e914775bc..740dfaa9b3 100644 --- a/src/Runner.php +++ b/src/Runner.php @@ -536,7 +536,7 @@ private function run() * @return bool * @throws \PHP_CodeSniffer\Exceptions\RuntimeException */ - public function handleErrors($code, $message, $file, $line) + public function handleErrors(int $code, string $message, string $file, int $line) { if ((error_reporting() & $code) === 0) { // This type of error is being muted. @@ -556,7 +556,7 @@ public function handleErrors($code, $message, $file, $line) * @return void * @throws \PHP_CodeSniffer\Exceptions\DeepExitException */ - public function processFile($file) + public function processFile(File $file) { if (PHP_CODESNIFFER_VERBOSITY > 0) { $startTime = microtime(true); @@ -686,7 +686,7 @@ public function processFile($file) * * @return bool */ - private function processChildProcs($childProcs) + private function processChildProcs(array $childProcs) { $numProcessed = 0; $totalBatches = count($childProcs); @@ -771,7 +771,7 @@ private function processChildProcs($childProcs) * * @return void */ - public function printProgress(File $file, $numFiles, $numProcessed) + public function printProgress(File $file, int $numFiles, int $numProcessed) { if (PHP_CODESNIFFER_VERBOSITY > 0 || $this->config->showProgress === false @@ -874,7 +874,7 @@ public function printProgress(File $file, $numFiles, $numProcessed) * * @return void */ - private function registerOutOfMemoryShutdownMessage($command) + private function registerOutOfMemoryShutdownMessage(string $command) { // Allocate all needed memory beforehand as much as possible. $errorMsg = PHP_EOL.'The PHP_CodeSniffer "%1$s" command ran out of memory.'.PHP_EOL; diff --git a/tests/ConfigDouble.php b/tests/ConfigDouble.php index 975df462a7..886a814f32 100644 --- a/tests/ConfigDouble.php +++ b/tests/ConfigDouble.php @@ -56,7 +56,7 @@ final class ConfigDouble extends Config * * @return void */ - public function __construct(array $cliArgs=[], $skipSettingStandard=false, $skipSettingReportWidth=false) + public function __construct(array $cliArgs=[], bool $skipSettingStandard=false, bool $skipSettingReportWidth=false) { $this->skipSettingStandard = $skipSettingStandard; @@ -180,7 +180,7 @@ private function preventAutoDiscoveryScreenWidth() * * @return mixed */ - private function getStaticConfigProperty($name) + private function getStaticConfigProperty(string $name) { $property = new ReflectionProperty(Config::class, $name); (PHP_VERSION_ID < 80100) && $property->setAccessible(true); @@ -202,7 +202,7 @@ private function getStaticConfigProperty($name) * * @return void */ - private function setStaticConfigProperty($name, $value) + private function setStaticConfigProperty(string $name, $value) { $property = new ReflectionProperty(Config::class, $name); (PHP_VERSION_ID < 80100) && $property->setAccessible(true); From fe82153e13bddc8ac2797fefe4c52f62477b733a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:47:48 +0200 Subject: [PATCH 02/15] 4.0 | Files: add parameter types This commit explicitly does **not** include adding a parameter type to the `File::getTokensAsString()` `$start` and `$length` parameters as the pre-existing inline parameter validation is more comprehensive and more reliable. --- src/Files/DummyFile.php | 12 +++- src/Files/File.php | 130 +++++++++++++++++++++------------------- src/Files/FileList.php | 2 +- src/Files/LocalFile.php | 4 +- 4 files changed, 81 insertions(+), 67 deletions(-) diff --git a/src/Files/DummyFile.php b/src/Files/DummyFile.php index b10a18086a..f7ba62f46f 100644 --- a/src/Files/DummyFile.php +++ b/src/Files/DummyFile.php @@ -30,7 +30,7 @@ class DummyFile extends File * * @return void */ - public function __construct($content, Ruleset $ruleset, Config $config) + public function __construct(string $content, Ruleset $ruleset, Config $config) { $this->setContent($content); @@ -71,8 +71,14 @@ public function __construct($content, Ruleset $ruleset, Config $config) * * @return void */ - public function setErrorCounts($errorCount, $warningCount, $fixableErrorCount, $fixableWarningCount, $fixedErrorCount, $fixedWarningCount) - { + public function setErrorCounts( + int $errorCount, + int $warningCount, + int $fixableErrorCount, + int $fixableWarningCount, + int $fixedErrorCount, + int $fixedWarningCount + ) { $this->errorCount = $errorCount; $this->warningCount = $warningCount; $this->fixableErrorCount = $fixableErrorCount; diff --git a/src/Files/File.php b/src/Files/File.php index 4891153f10..84aaeba56a 100644 --- a/src/Files/File.php +++ b/src/Files/File.php @@ -267,7 +267,7 @@ class File * * @return void */ - public function __construct($path, Ruleset $ruleset, Config $config) + public function __construct(string $path, Ruleset $ruleset, Config $config) { $this->path = $path; $this->ruleset = $ruleset; @@ -296,7 +296,7 @@ public function __construct($path, Ruleset $ruleset, Config $config) * * @return void */ - public function setContent($content) + public function setContent(string $content) { $this->content = $content; $this->tokens = []; @@ -671,12 +671,12 @@ public function cleanUp() * @return boolean */ public function addError( - $error, - $stackPtr, - $code, - $data=[], - $severity=0, - $fixable=false + string $error, + ?int $stackPtr, + string $code, + array $data=[], + int $severity=0, + bool $fixable=false ) { if ($stackPtr === null) { $line = 1; @@ -705,12 +705,12 @@ public function addError( * @return boolean */ public function addWarning( - $warning, - $stackPtr, - $code, - $data=[], - $severity=0, - $fixable=false + string $warning, + ?int $stackPtr, + string $code, + array $data=[], + int $severity=0, + bool $fixable=false ) { if ($stackPtr === null) { $line = 1; @@ -738,11 +738,11 @@ public function addWarning( * @return boolean */ public function addErrorOnLine( - $error, - $line, - $code, - $data=[], - $severity=0 + string $error, + int $line, + string $code, + array $data=[], + int $severity=0 ) { return $this->addMessage(true, $error, $line, 1, $code, $data, $severity, false); @@ -762,11 +762,11 @@ public function addErrorOnLine( * @return boolean */ public function addWarningOnLine( - $warning, - $line, - $code, - $data=[], - $severity=0 + string $warning, + int $line, + string $code, + array $data=[], + int $severity=0 ) { return $this->addMessage(false, $warning, $line, 1, $code, $data, $severity, false); @@ -788,11 +788,11 @@ public function addWarningOnLine( * @return boolean */ public function addFixableError( - $error, - $stackPtr, - $code, - $data=[], - $severity=0 + string $error, + int $stackPtr, + string $code, + array $data=[], + int $severity=0 ) { $recorded = $this->addError($error, $stackPtr, $code, $data, $severity, true); if ($recorded === true && $this->fixer->enabled === true) { @@ -819,11 +819,11 @@ public function addFixableError( * @return boolean */ public function addFixableWarning( - $warning, - $stackPtr, - $code, - $data=[], - $severity=0 + string $warning, + int $stackPtr, + string $code, + array $data=[], + int $severity=0 ) { $recorded = $this->addWarning($warning, $stackPtr, $code, $data, $severity, true); if ($recorded === true && $this->fixer->enabled === true) { @@ -850,8 +850,16 @@ public function addFixableWarning( * * @return boolean */ - protected function addMessage($error, $message, $line, $column, $code, $data, $severity, $fixable) - { + protected function addMessage( + bool $error, + string $message, + int $line, + int $column, + string $code, + array $data, + int $severity, + bool $fixable + ) { // Check if this line is ignoring all message codes. if (isset($this->tokenizer->ignoredLines[$line]) === true && $this->tokenizer->ignoredLines[$line]->ignoresEverything() === true) { return false; @@ -1097,7 +1105,7 @@ protected function addMessage($error, $message, $line, $column, $code, $data, $s * * @return boolean */ - public function recordMetric($stackPtr, $metric, $value) + public function recordMetric(int $stackPtr, string $metric, string $value) { if (isset($this->metrics[$metric]) === false) { $this->metrics[$metric] = ['values' => [$value => 1]]; @@ -1311,7 +1319,7 @@ public function getFilename() * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the specified token is not of type * T_FUNCTION, T_CLASS, T_TRAIT, T_ENUM, or T_INTERFACE. */ - public function getDeclarationName($stackPtr) + public function getDeclarationName(int $stackPtr) { $tokenCode = $this->tokens[$stackPtr]['code']; @@ -1402,7 +1410,7 @@ public function getDeclarationName($stackPtr) * type T_FUNCTION, T_CLOSURE, T_USE, * or T_FN. */ - public function getMethodParameters($stackPtr) + public function getMethodParameters(int $stackPtr) { if ($this->tokens[$stackPtr]['code'] !== T_FUNCTION && $this->tokens[$stackPtr]['code'] !== T_CLOSURE @@ -1713,7 +1721,7 @@ public function getMethodParameters($stackPtr) * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the specified position is not a * T_FUNCTION, T_CLOSURE, or T_FN token. */ - public function getMethodProperties($stackPtr) + public function getMethodProperties(int $stackPtr) { if ($this->tokens[$stackPtr]['code'] !== T_FUNCTION && $this->tokens[$stackPtr]['code'] !== T_CLOSURE @@ -1901,7 +1909,7 @@ public function getMethodProperties($stackPtr) * T_VARIABLE token, or if the position is not * a class member variable. */ - public function getMemberProperties($stackPtr) + public function getMemberProperties(int $stackPtr) { if ($this->tokens[$stackPtr]['code'] !== T_VARIABLE) { throw new RuntimeException('$stackPtr must be of type T_VARIABLE'); @@ -2086,7 +2094,7 @@ public function getMemberProperties($stackPtr) * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the specified position is not a * T_CLASS token. */ - public function getClassProperties($stackPtr) + public function getClassProperties(int $stackPtr) { if ($this->tokens[$stackPtr]['code'] !== T_CLASS) { throw new RuntimeException('$stackPtr must be of type T_CLASS'); @@ -2143,7 +2151,7 @@ public function getClassProperties($stackPtr) * * @return boolean */ - public function isReference($stackPtr) + public function isReference(int $stackPtr) { if ($this->tokens[$stackPtr]['code'] !== T_BITWISE_AND) { return false; @@ -2256,7 +2264,7 @@ public function isReference($stackPtr) * @return string The token contents. * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If the specified position does not exist. */ - public function getTokensAsString($start, $length, $origContent=false) + public function getTokensAsString($start, $length, bool $origContent=false) { if (is_int($start) === false || isset($this->tokens[$start]) === false) { throw new RuntimeException('The $start position for getTokensAsString() must exist in the token stack'); @@ -2315,11 +2323,11 @@ public function getTokensAsString($start, $length, $origContent=false) */ public function findPrevious( $types, - $start, - $end=null, - $exclude=false, - $value=null, - $local=false + int $start, + ?int $end=null, + bool $exclude=false, + ?string $value=null, + bool $local=false ) { $types = (array) $types; @@ -2396,11 +2404,11 @@ public function findPrevious( */ public function findNext( $types, - $start, - $end=null, - $exclude=false, - $value=null, - $local=false + int $start, + ?int $end=null, + bool $exclude=false, + ?string $value=null, + bool $local=false ) { $types = (array) $types; @@ -2443,7 +2451,7 @@ public function findNext( * * @return int */ - public function findStartOfStatement($start, $ignore=null) + public function findStartOfStatement(int $start, $ignore=null) { $startTokens = Tokens::BLOCK_OPENERS; $startTokens[T_OPEN_SHORT_ARRAY] = true; @@ -2634,7 +2642,7 @@ public function findStartOfStatement($start, $ignore=null) * * @return int */ - public function findEndOfStatement($start, $ignore=null) + public function findEndOfStatement(int $start, $ignore=null) { $endTokens = [ T_COLON => true, @@ -2761,7 +2769,7 @@ public function findEndOfStatement($start, $ignore=null) * FALSE when no matching token could be found between the start of * the line and the start token. */ - public function findFirstOnLine($types, $start, $exclude=false, $value=null) + public function findFirstOnLine($types, int $start, bool $exclude=false, ?string $value=null) { if (is_array($types) === false) { $types = [$types]; @@ -2811,7 +2819,7 @@ public function findFirstOnLine($types, $start, $exclude=false, $value=null) * * @return boolean */ - public function hasCondition($stackPtr, $types) + public function hasCondition(int $stackPtr, $types) { // Check for the existence of the token. if (isset($this->tokens[$stackPtr]) === false) { @@ -2852,7 +2860,7 @@ public function hasCondition($stackPtr, $types) * * @return int|false */ - public function getCondition($stackPtr, $type, $first=true) + public function getCondition(int $stackPtr, $type, bool $first=true) { // Check for the existence of the token. if (isset($this->tokens[$stackPtr]) === false) { @@ -2890,7 +2898,7 @@ public function getCondition($stackPtr, $type, $first=true) * * @return string|false */ - public function findExtendedClassName($stackPtr) + public function findExtendedClassName(int $stackPtr) { // Check for the existence of the token. if (isset($this->tokens[$stackPtr]) === false) { @@ -2939,7 +2947,7 @@ public function findExtendedClassName($stackPtr) * * @return array|false */ - public function findImplementedInterfaceNames($stackPtr) + public function findImplementedInterfaceNames(int $stackPtr) { // Check for the existence of the token. if (isset($this->tokens[$stackPtr]) === false) { diff --git a/src/Files/FileList.php b/src/Files/FileList.php index 75ccf37e9b..b1d6e224b3 100644 --- a/src/Files/FileList.php +++ b/src/Files/FileList.php @@ -117,7 +117,7 @@ public function __construct(Config $config, Ruleset $ruleset) * * @return void */ - public function addFile($path, $file=null) + public function addFile(string $path, ?File $file=null) { // No filtering is done for STDIN when the filename // has not been specified. diff --git a/src/Files/LocalFile.php b/src/Files/LocalFile.php index db93ac1f13..907298e207 100644 --- a/src/Files/LocalFile.php +++ b/src/Files/LocalFile.php @@ -28,7 +28,7 @@ class LocalFile extends File * * @return void */ - public function __construct($path, Ruleset $ruleset, Config $config) + public function __construct(string $path, Ruleset $ruleset, Config $config) { $this->path = trim($path); if (Common::isReadable($this->path) === false) { @@ -166,7 +166,7 @@ public function process() * * @return void */ - private function replayErrors($errors, $warnings) + private function replayErrors(array $errors, array $warnings) { $this->errors = []; $this->warnings = []; From cd53c0f914673d8f7f3f514186c106b4d125a58d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:22:15 +0200 Subject: [PATCH 03/15] 4.0 | Filters: add parameter types --- src/Filters/Filter.php | 7 ++++--- src/Filters/GitModified.php | 2 +- src/Filters/GitStaged.php | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Filters/Filter.php b/src/Filters/Filter.php index a136869110..7f20ad6b36 100644 --- a/src/Filters/Filter.php +++ b/src/Filters/Filter.php @@ -15,6 +15,7 @@ use PHP_CodeSniffer\Util\Common; use RecursiveDirectoryIterator; use RecursiveFilterIterator; +use RecursiveIterator; use ReturnTypeWillChange; class Filter extends RecursiveFilterIterator @@ -84,7 +85,7 @@ class Filter extends RecursiveFilterIterator * * @return void */ - public function __construct($iterator, $basedir, Config $config, Ruleset $ruleset) + public function __construct(RecursiveIterator $iterator, string $basedir, Config $config, Ruleset $ruleset) { parent::__construct($iterator); $this->basedir = $basedir; @@ -177,7 +178,7 @@ public function getChildren() * * @return bool */ - protected function shouldProcessFile($path) + protected function shouldProcessFile(string $path) { // Check that the file's extension is one we are checking. // We are strict about checking the extension and we don't @@ -224,7 +225,7 @@ protected function shouldProcessFile($path) * * @return bool */ - protected function shouldIgnorePath($path) + protected function shouldIgnorePath(string $path) { if ($this->ignoreFilePatterns === null) { $this->ignoreDirPatterns = []; diff --git a/src/Filters/GitModified.php b/src/Filters/GitModified.php index c1f0216351..afc445d6f4 100644 --- a/src/Filters/GitModified.php +++ b/src/Filters/GitModified.php @@ -76,7 +76,7 @@ protected function getAllowedFiles() * * @return array */ - protected function exec($cmd) + protected function exec(string $cmd) { $output = []; $lastLine = exec($cmd, $output); diff --git a/src/Filters/GitStaged.php b/src/Filters/GitStaged.php index 894191c01f..fe32bb35a5 100644 --- a/src/Filters/GitStaged.php +++ b/src/Filters/GitStaged.php @@ -78,7 +78,7 @@ protected function getAllowedFiles() * * @return array */ - protected function exec($cmd) + protected function exec(string $cmd) { $output = []; $lastLine = exec($cmd, $output); From 14ff8698f2b74cb51b5e2bd187de2054590b2bd0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:44:55 +0200 Subject: [PATCH 04/15] 4.0 | Generators: add parameter types Includes changing the expected parameter type for a couple of methods from `DomNode` to `DomElement`. The previous was incorrect, but changing the method signature by making a type more specific, is a breaking change, so had to wait until now. --- src/Generators/Generator.php | 18 +++++++++--------- src/Generators/HTML.php | 10 +++++----- src/Generators/Markdown.php | 8 ++++---- src/Generators/Text.php | 16 ++++++++-------- .../Core/Generators/Fixtures/MockGenerator.php | 6 +++--- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Generators/Generator.php b/src/Generators/Generator.php index 3846e9784b..ca4b9939ea 100644 --- a/src/Generators/Generator.php +++ b/src/Generators/Generator.php @@ -75,15 +75,15 @@ public function __construct(Ruleset $ruleset) /** - * Retrieves the title of the sniff from the DOMNode supplied. + * Retrieves the title of the sniff from the DOMElement supplied. * - * @param \DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. + * @param \DOMElement $doc The DOMElement object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. * * @return string */ - protected function getTitle(DOMNode $doc) + protected function getTitle(DOMElement $doc) { $title = $doc->getAttribute('title'); @@ -141,14 +141,14 @@ public function generate() * * Doc generators must implement this function to produce output. * - * @param \DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. + * @param \DOMElement $doc The DOMElement object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. * * @return void * @see generate() */ - abstract protected function processSniff(DOMNode $doc); + abstract protected function processSniff(DOMElement $doc); }//end class diff --git a/src/Generators/HTML.php b/src/Generators/HTML.php index c5f167385d..c2282f24ff 100644 --- a/src/Generators/HTML.php +++ b/src/Generators/HTML.php @@ -262,13 +262,13 @@ protected function getFormattedFooter() /** * Process the documentation for a single sniff. * - * @param \DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. + * @param \DOMElement $doc The DOMElement object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. * * @return void */ - public function processSniff(DOMNode $doc) + public function processSniff(DOMElement $doc) { $content = ''; foreach ($doc->childNodes as $node) { @@ -301,7 +301,7 @@ public function processSniff(DOMNode $doc) * * @return string */ - private function titleToAnchor($title) + private function titleToAnchor(string $title) { // Slugify the text. $title = strtolower($title); diff --git a/src/Generators/Markdown.php b/src/Generators/Markdown.php index 50382aae80..fcad3b519f 100644 --- a/src/Generators/Markdown.php +++ b/src/Generators/Markdown.php @@ -100,13 +100,13 @@ protected function getFormattedFooter() /** * Process the documentation for a single sniff. * - * @param \DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. + * @param \DOMElement $doc The DOMElement object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. * * @return void */ - protected function processSniff(DOMNode $doc) + protected function processSniff(DOMElement $doc) { $content = ''; foreach ($doc->childNodes as $node) { diff --git a/src/Generators/Text.php b/src/Generators/Text.php index 47eefcaa04..dbc5908e09 100644 --- a/src/Generators/Text.php +++ b/src/Generators/Text.php @@ -23,13 +23,13 @@ class Text extends Generator /** * Process the documentation for a single sniff. * - * @param \DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. + * @param \DOMElement $doc The DOMElement object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. * * @return void */ - public function processSniff(DOMNode $doc) + public function processSniff(DOMElement $doc) { $content = ''; foreach ($doc->childNodes as $node) { @@ -50,16 +50,16 @@ public function processSniff(DOMNode $doc) /** * Format the title area for a single sniff. * - * @param \DOMNode $doc The DOMNode object for the sniff. - * It represents the "documentation" tag in the XML - * standard file. + * @param \DOMElement $doc The DOMElement object for the sniff. + * It represents the "documentation" tag in the XML + * standard file. * * @since 3.12.0 Replaces the Text::printTitle() method, * which was deprecated in 3.12.0 and removed in 4.0.0. * * @return string */ - protected function getFormattedTitle(DOMNode $doc) + protected function getFormattedTitle(DOMElement $doc) { $title = $this->getTitle($doc); $standard = $this->ruleset->name; diff --git a/tests/Core/Generators/Fixtures/MockGenerator.php b/tests/Core/Generators/Fixtures/MockGenerator.php index 8cf99ff047..262d7ef5aa 100644 --- a/tests/Core/Generators/Fixtures/MockGenerator.php +++ b/tests/Core/Generators/Fixtures/MockGenerator.php @@ -8,7 +8,7 @@ namespace PHP_CodeSniffer\Tests\Core\Generators\Fixtures; -use DOMNode; +use DOMElement; use PHP_CodeSniffer\Generators\Generator; class MockGenerator extends Generator @@ -17,11 +17,11 @@ class MockGenerator extends Generator /** * Process the documentation for a single sniff. * - * @param \DOMNode $doc The DOMNode object for the sniff. + * @param \DOMElement $doc The DOMElement object for the sniff. * * @return void */ - protected function processSniff(DOMNode $doc) + protected function processSniff(DOMElement $doc) { echo $this->getTitle($doc), PHP_EOL; } From b3e4dd6f6369dc332af3b2f557cbe6d8085c69a3 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:21:00 +0200 Subject: [PATCH 05/15] 4.0 | Reports: add parameter types --- src/Reports/Cbf.php | 20 ++++++++++---------- src/Reports/Checkstyle.php | 20 ++++++++++---------- src/Reports/Code.php | 20 ++++++++++---------- src/Reports/Csv.php | 20 ++++++++++---------- src/Reports/Diff.php | 20 ++++++++++---------- src/Reports/Emacs.php | 20 ++++++++++---------- src/Reports/Full.php | 20 ++++++++++---------- src/Reports/Gitblame.php | 4 ++-- src/Reports/Hgblame.php | 4 ++-- src/Reports/Info.php | 20 ++++++++++---------- src/Reports/Json.php | 20 ++++++++++---------- src/Reports/Junit.php | 20 ++++++++++---------- src/Reports/Notifysend.php | 24 ++++++++++++------------ src/Reports/Performance.php | 20 ++++++++++---------- src/Reports/Report.php | 20 ++++++++++---------- src/Reports/Source.php | 22 +++++++++++----------- src/Reports/Summary.php | 20 ++++++++++---------- src/Reports/Svnblame.php | 4 ++-- src/Reports/VersionControl.php | 24 ++++++++++++------------ src/Reports/Xml.php | 20 ++++++++++---------- 20 files changed, 181 insertions(+), 181 deletions(-) diff --git a/src/Reports/Cbf.php b/src/Reports/Cbf.php index e3369dd898..3abf73bb5f 100644 --- a/src/Reports/Cbf.php +++ b/src/Reports/Cbf.php @@ -42,7 +42,7 @@ class Cbf implements Report * @return bool * @throws \PHP_CodeSniffer\Exceptions\DeepExitException */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { $errors = $phpcsFile->getFixableCount(); if ($errors !== 0) { @@ -134,15 +134,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { $lines = explode(PHP_EOL, $cachedData); array_pop($lines); diff --git a/src/Reports/Checkstyle.php b/src/Reports/Checkstyle.php index 8640561fb6..56f36a5798 100644 --- a/src/Reports/Checkstyle.php +++ b/src/Reports/Checkstyle.php @@ -32,7 +32,7 @@ class Checkstyle implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { $out = new XMLWriter; $out->openMemory(); @@ -90,15 +90,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { echo ''.PHP_EOL; echo ''.PHP_EOL; diff --git a/src/Reports/Code.php b/src/Reports/Code.php index a6f5388414..d730a00ea6 100644 --- a/src/Reports/Code.php +++ b/src/Reports/Code.php @@ -34,7 +34,7 @@ class Code implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { if ($report['errors'] === 0 && $report['warnings'] === 0) { // Nothing to print. @@ -335,15 +335,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { if ($cachedData === '') { return; diff --git a/src/Reports/Csv.php b/src/Reports/Csv.php index ed7caca381..e47bf7bc6e 100644 --- a/src/Reports/Csv.php +++ b/src/Reports/Csv.php @@ -30,7 +30,7 @@ class Csv implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { if ($report['errors'] === 0 && $report['warnings'] === 0) { // Nothing to print. @@ -73,15 +73,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { echo 'File,Line,Column,Type,Message,Source,Severity,Fixable'.PHP_EOL; echo $cachedData; diff --git a/src/Reports/Diff.php b/src/Reports/Diff.php index f69bb0d4eb..d5f68298a3 100644 --- a/src/Reports/Diff.php +++ b/src/Reports/Diff.php @@ -32,7 +32,7 @@ class Diff implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { $errors = $phpcsFile->getFixableCount(); if ($errors === 0) { @@ -101,15 +101,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { echo $cachedData; if ($toScreen === true && $cachedData !== '') { diff --git a/src/Reports/Emacs.php b/src/Reports/Emacs.php index 076768a78e..14bf664f56 100644 --- a/src/Reports/Emacs.php +++ b/src/Reports/Emacs.php @@ -30,7 +30,7 @@ class Emacs implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { if ($report['errors'] === 0 && $report['warnings'] === 0) { // Nothing to print. @@ -73,15 +73,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { echo $cachedData; diff --git a/src/Reports/Full.php b/src/Reports/Full.php index 62e4503b06..87efe1d66d 100644 --- a/src/Reports/Full.php +++ b/src/Reports/Full.php @@ -30,7 +30,7 @@ class Full implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { if ($report['errors'] === 0 && $report['warnings'] === 0) { // Nothing to print. @@ -233,15 +233,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { if ($cachedData === '') { return; diff --git a/src/Reports/Gitblame.php b/src/Reports/Gitblame.php index c035ba75bb..6c126d9642 100644 --- a/src/Reports/Gitblame.php +++ b/src/Reports/Gitblame.php @@ -31,7 +31,7 @@ class Gitblame extends VersionControl * * @return mixed string or false if impossible to recover. */ - protected function getAuthor($line) + protected function getAuthor(string $line) { $blameParts = []; $line = preg_replace('|\s+|', ' ', $line); @@ -66,7 +66,7 @@ protected function getAuthor($line) * @return array * @throws \PHP_CodeSniffer\Exceptions\DeepExitException */ - protected function getBlameContent($filename) + protected function getBlameContent(string $filename) { $cwd = getcwd(); diff --git a/src/Reports/Hgblame.php b/src/Reports/Hgblame.php index caf47e111b..e402559919 100644 --- a/src/Reports/Hgblame.php +++ b/src/Reports/Hgblame.php @@ -31,7 +31,7 @@ class Hgblame extends VersionControl * * @return string|false String or FALSE if impossible to recover. */ - protected function getAuthor($line) + protected function getAuthor(string $line) { $blameParts = []; $line = preg_replace('|\s+|', ' ', $line); @@ -67,7 +67,7 @@ protected function getAuthor($line) * @return array * @throws \PHP_CodeSniffer\Exceptions\DeepExitException */ - protected function getBlameContent($filename) + protected function getBlameContent(string $filename) { $cwd = getcwd(); diff --git a/src/Reports/Info.php b/src/Reports/Info.php index f12f48250c..f6ae6f1a68 100644 --- a/src/Reports/Info.php +++ b/src/Reports/Info.php @@ -30,7 +30,7 @@ class Info implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { $metrics = $phpcsFile->getMetrics(); foreach ($metrics as $metric => $data) { @@ -61,15 +61,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { $lines = explode(PHP_EOL, $cachedData); array_pop($lines); diff --git a/src/Reports/Json.php b/src/Reports/Json.php index 67c8b5e63e..55fe4aa2ef 100644 --- a/src/Reports/Json.php +++ b/src/Reports/Json.php @@ -31,7 +31,7 @@ class Json implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { $filename = str_replace('\\', '\\\\', $report['filename']); $filename = str_replace('"', '\"', $filename); @@ -87,15 +87,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { echo '{"totals":{"errors":'.$totalErrors.',"warnings":'.$totalWarnings.',"fixable":'.$totalFixable.'},"files":{'; echo rtrim($cachedData, ','); diff --git a/src/Reports/Junit.php b/src/Reports/Junit.php index aaeeb17749..c59c4102c6 100644 --- a/src/Reports/Junit.php +++ b/src/Reports/Junit.php @@ -33,7 +33,7 @@ class Junit implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { $out = new XMLWriter; $out->openMemory(); @@ -101,15 +101,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { // Figure out the total number of tests. $tests = 0; diff --git a/src/Reports/Notifysend.php b/src/Reports/Notifysend.php index 839d99036e..503f7a6ffa 100644 --- a/src/Reports/Notifysend.php +++ b/src/Reports/Notifysend.php @@ -96,7 +96,7 @@ public function __construct() * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { echo $report['filename'].PHP_EOL; @@ -124,15 +124,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { $checkedFiles = explode(PHP_EOL, trim($cachedData)); @@ -157,7 +157,7 @@ public function generate( * * @return string|null Error message or NULL if no error/warning found. */ - protected function generateMessage($checkedFiles, $totalErrors, $totalWarnings) + protected function generateMessage(array $checkedFiles, int $totalErrors, int $totalWarnings) { if ($totalErrors === 0 && $totalWarnings === 0) { // Nothing to print. @@ -209,7 +209,7 @@ protected function notifyAllFine() * * @return void */ - protected function notifyErrors($msg) + protected function notifyErrors(string $msg) { $cmd = $this->getBasicCommand(); $cmd .= ' -i error'; diff --git a/src/Reports/Performance.php b/src/Reports/Performance.php index 8436989906..1d2bd40bef 100644 --- a/src/Reports/Performance.php +++ b/src/Reports/Performance.php @@ -32,7 +32,7 @@ class Performance implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { $times = $phpcsFile->getListenerTimes(); foreach ($times as $sniff => $time) { @@ -61,15 +61,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { $lines = explode(PHP_EOL, $cachedData); array_pop($lines); diff --git a/src/Reports/Report.php b/src/Reports/Report.php index 52d7883b5b..fa8ae1c7b1 100644 --- a/src/Reports/Report.php +++ b/src/Reports/Report.php @@ -52,7 +52,7 @@ interface Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80); + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80); /** @@ -72,15 +72,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ); diff --git a/src/Reports/Source.php b/src/Reports/Source.php index 405dd814a1..a6cc078880 100644 --- a/src/Reports/Source.php +++ b/src/Reports/Source.php @@ -30,7 +30,7 @@ class Source implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { if ($report['errors'] === 0 && $report['warnings'] === 0) { // Nothing to print. @@ -81,15 +81,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { $lines = explode(PHP_EOL, $cachedData); array_pop($lines); @@ -275,7 +275,7 @@ public function generate( * * @return string */ - public function makeFriendlyName($name) + public function makeFriendlyName(string $name) { if (trim($name) === '') { return ''; diff --git a/src/Reports/Summary.php b/src/Reports/Summary.php index c76e4bc2e5..c54848d402 100644 --- a/src/Reports/Summary.php +++ b/src/Reports/Summary.php @@ -30,7 +30,7 @@ class Summary implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { if (PHP_CODESNIFFER_VERBOSITY === 0 && $report['errors'] === 0 @@ -63,15 +63,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { $lines = explode(PHP_EOL, $cachedData); array_pop($lines); diff --git a/src/Reports/Svnblame.php b/src/Reports/Svnblame.php index 51e4a760f6..0fca60bc18 100644 --- a/src/Reports/Svnblame.php +++ b/src/Reports/Svnblame.php @@ -30,7 +30,7 @@ class Svnblame extends VersionControl * * @return mixed string or false if impossible to recover. */ - protected function getAuthor($line) + protected function getAuthor(string $line) { $blameParts = []; preg_match('|\s*([^\s]+)\s+([^\s]+)|', $line, $blameParts); @@ -52,7 +52,7 @@ protected function getAuthor($line) * @return array * @throws \PHP_CodeSniffer\Exceptions\DeepExitException */ - protected function getBlameContent($filename) + protected function getBlameContent(string $filename) { $command = 'svn blame "'.$filename.'" 2>&1'; $handle = popen($command, 'r'); diff --git a/src/Reports/VersionControl.php b/src/Reports/VersionControl.php index c76fb6d460..c7e6c79ace 100644 --- a/src/Reports/VersionControl.php +++ b/src/Reports/VersionControl.php @@ -38,7 +38,7 @@ abstract class VersionControl implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { $blames = $this->getBlameContent($phpcsFile->getFilename()); @@ -148,15 +148,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { $errorsShown = ($totalErrors + $totalWarnings); if ($errorsShown === 0) { @@ -356,7 +356,7 @@ public function generate( * * @return mixed string or false if impossible to recover. */ - abstract protected function getAuthor($line); + abstract protected function getAuthor(string $line); /** @@ -366,7 +366,7 @@ abstract protected function getAuthor($line); * * @return array */ - abstract protected function getBlameContent($filename); + abstract protected function getBlameContent(string $filename); }//end class diff --git a/src/Reports/Xml.php b/src/Reports/Xml.php index 68276d80d2..c64c6570ca 100644 --- a/src/Reports/Xml.php +++ b/src/Reports/Xml.php @@ -32,7 +32,7 @@ class Xml implements Report * * @return bool */ - public function generateFileReport($report, File $phpcsFile, $showSources=false, $width=80) + public function generateFileReport(array $report, File $phpcsFile, bool $showSources=false, int $width=80) { $out = new XMLWriter; $out->openMemory(); @@ -107,15 +107,15 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, * @return void */ public function generate( - $cachedData, - $totalFiles, - $totalErrors, - $totalWarnings, - $totalFixable, - $showSources=false, - $width=80, - $interactive=false, - $toScreen=true + string $cachedData, + int $totalFiles, + int $totalErrors, + int $totalWarnings, + int $totalFixable, + bool $showSources=false, + int $width=80, + bool $interactive=false, + bool $toScreen=true ) { echo ''.PHP_EOL; echo ''.PHP_EOL; From b5ee6dcd002b3bf6162f8b1425a4e999c5590b5e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:49:00 +0200 Subject: [PATCH 06/15] 4.0 | Tokenizers: add parameter types --- src/Tokenizers/Comment.php | 6 +++--- src/Tokenizers/PHP.php | 8 ++++---- src/Tokenizers/Tokenizer.php | 11 ++++++----- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Tokenizers/Comment.php b/src/Tokenizers/Comment.php index 824b9b646e..610ba3cb75 100644 --- a/src/Tokenizers/Comment.php +++ b/src/Tokenizers/Comment.php @@ -25,7 +25,7 @@ class Comment * * @return array>> */ - public function tokenizeString($comment, $eolChar, $stackPtr) + public function tokenizeString(string $comment, string $eolChar, int $stackPtr) { if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('*** START COMMENT TOKENIZING ***', 2); @@ -188,7 +188,7 @@ public function tokenizeString($comment, $eolChar, $stackPtr) * * @return array> */ - private function processLine($comment, $eolChar, $start, $end) + private function processLine(string $comment, string $eolChar, int $start, int $end) { $tokens = []; @@ -263,7 +263,7 @@ private function processLine($comment, $eolChar, $start, $end) * * @return array|null */ - private function collectWhitespace($comment, $start, $end) + private function collectWhitespace(string $comment, int $start, int $end) { $space = ''; for ($start; $start < $end; $start++) { diff --git a/src/Tokenizers/PHP.php b/src/Tokenizers/PHP.php index 176e70241e..50199b4a95 100644 --- a/src/Tokenizers/PHP.php +++ b/src/Tokenizers/PHP.php @@ -535,7 +535,7 @@ class PHP extends Tokenizer * * @return array */ - protected function tokenize($code) + protected function tokenize(string $code) { if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write('*** START PHP TOKENIZING ***', 1); @@ -3847,7 +3847,7 @@ public static function standardiseToken($token) * * @return array The new token in array format. */ - public static function resolveSimpleToken($token) + public static function resolveSimpleToken(string $token) { $newToken = []; @@ -3955,7 +3955,7 @@ public static function resolveSimpleToken($token) * * @return int|null The position of the closing token, if found. NULL otherwise. */ - private function findCloser(array &$tokens, $start, $openerTokens, $closerChar) + private function findCloser(array &$tokens, int $start, $openerTokens, string $closerChar) { $numTokens = count($tokens); $stack = [0]; @@ -3990,7 +3990,7 @@ private function findCloser(array &$tokens, $start, $openerTokens, $closerChar) * * @return array|null The array of parsed attribute tokens */ - private function parsePhpAttribute(array &$tokens, $stackPtr) + private function parsePhpAttribute(array &$tokens, int $stackPtr) { $token = $tokens[$stackPtr]; diff --git a/src/Tokenizers/Tokenizer.php b/src/Tokenizers/Tokenizer.php index 8c9a4f2caa..2dcda2a870 100644 --- a/src/Tokenizers/Tokenizer.php +++ b/src/Tokenizers/Tokenizer.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Tokenizers; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Exceptions\TokenizerException; use PHP_CodeSniffer\Util\Common; use PHP_CodeSniffer\Util\IgnoreList; @@ -108,7 +109,7 @@ abstract class Tokenizer * @return void * @throws \PHP_CodeSniffer\Exceptions\TokenizerException If the file appears to be minified. */ - public function __construct($content, $config, $eolChar='\n') + public function __construct(string $content, ?Config $config, string $eolChar='\n') { $this->eolChar = $eolChar; @@ -139,7 +140,7 @@ public function __construct($content, $config, $eolChar='\n') * * @return boolean */ - protected function isMinifiedContent($content, $eolChar='\n') + protected function isMinifiedContent(string $content, string $eolChar='\n') { // Minified files often have a very large number of characters per line // and cause issues when tokenizing. @@ -174,7 +175,7 @@ public function getTokens() * * @return array */ - abstract protected function tokenize($code); + abstract protected function tokenize(string $code); /** @@ -500,7 +501,7 @@ private function createPositionMap() * * @return void */ - public function replaceTabsInToken(&$token, $prefix=' ', $padding=' ', $tabWidth=null) + public function replaceTabsInToken(array &$token, string $prefix=' ', string $padding=' ', ?int $tabWidth=null) { $checkEncoding = false; if (function_exists('iconv_strlen') === true) { @@ -840,7 +841,7 @@ private function createScopeMap() * @return int The position in the stack that closed the scope. * @throws \PHP_CodeSniffer\Exceptions\TokenizerException If the nesting level gets too deep. */ - private function recurseScopeMap($stackPtr, $depth=1, &$ignore=0) + private function recurseScopeMap(int $stackPtr, int $depth=1, int &$ignore=0) { if (PHP_CODESNIFFER_VERBOSITY > 1) { StatusWriter::write("=> Begin scope map recursion at token $stackPtr with depth $depth", $depth); From 30b85c1dc875416183bf482a6823f68359edd5e4 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:25:34 +0200 Subject: [PATCH 07/15] 4.0 | Util classes: add parameter types This commit explicitly does **not** include adding a parameter type to the `MessageCollector::add()` `$message` and `$type` parameters and the `Common::getSniffCode()` `$sniffsClass` parameter, as the pre-existing inline parameter validation is more comprehensive and more reliable. Includes removing a type check from an "internal-only" class which is no longer necessary (and updating the associated test). --- src/Util/Cache.php | 4 ++-- src/Util/Common.php | 30 +++++++++++++++--------------- src/Util/Help.php | 13 +++---------- src/Util/IgnoreList.php | 4 ++-- src/Util/MessageCollector.php | 4 ++-- src/Util/Standards.php | 12 ++++++------ src/Util/Timing.php | 6 +++--- src/Util/Writers/StatusWriter.php | 8 ++++---- tests/Core/Util/Help/HelpTest.php | 13 +++++-------- 9 files changed, 42 insertions(+), 52 deletions(-) diff --git a/src/Util/Cache.php b/src/Util/Cache.php index 3813333dcb..d1429c45b4 100644 --- a/src/Util/Cache.php +++ b/src/Util/Cache.php @@ -307,7 +307,7 @@ public static function save() * * @return mixed */ - public static function get($key=null) + public static function get(?string $key=null) { if ($key === null) { return self::$cache; @@ -331,7 +331,7 @@ public static function get($key=null) * * @return void */ - public static function set($key, $value) + public static function set(?string $key, $value) { if ($key === null) { self::$cache = $value; diff --git a/src/Util/Common.php b/src/Util/Common.php index 9f609a73b3..753b0189f9 100644 --- a/src/Util/Common.php +++ b/src/Util/Common.php @@ -49,7 +49,7 @@ class Common * * @return bool */ - public static function isPharFile($path) + public static function isPharFile(string $path) { if (strpos($path, 'phar://') === 0) { return true; @@ -70,7 +70,7 @@ public static function isPharFile($path) * * @return boolean */ - public static function isReadable($path) + public static function isReadable(string $path) { if (@is_readable($path) === true) { return true; @@ -97,7 +97,7 @@ public static function isReadable($path) * * @return string|false */ - public static function realpath($path) + public static function realpath(string $path) { // Support the path replacement of ~ with the user's home directory. if (substr($path, 0, 2) === '~/') { @@ -150,7 +150,7 @@ public static function realpath($path) * * @return string */ - public static function stripBasepath($path, $basepath) + public static function stripBasepath(string $path, ?string $basepath) { if (empty($basepath) === true) { return $path; @@ -178,7 +178,7 @@ public static function stripBasepath($path, $basepath) * * @return string */ - public static function detectLineEndings($contents) + public static function detectLineEndings(string $contents) { if (preg_match("/\r\n?|\n/", $contents, $matches) !== 1) { // Assume there are no newlines. @@ -258,7 +258,7 @@ public static function isStdinATTY() * * @return string */ - public static function escapeshellcmd($cmd) + public static function escapeshellcmd(string $cmd) { $cmd = escapeshellcmd($cmd); @@ -285,7 +285,7 @@ public static function escapeshellcmd($cmd) * * @return string */ - public static function prepareForOutput($content, $exclude=[]) + public static function prepareForOutput(string $content, array $exclude=[]) { if (PHP_OS_FAMILY === 'Windows') { if (in_array("\r", $exclude, true) === false) { @@ -329,7 +329,7 @@ public static function prepareForOutput($content, $exclude=[]) * * @return string */ - public static function stripColors($text) + public static function stripColors(string $text) { return preg_replace('`\033\[[0-9;]+m`', '', $text); @@ -357,10 +357,10 @@ public static function stripColors($text) * @return boolean */ public static function isCamelCaps( - $name, - $classFormat=false, - $visibilityPublic=true, - $strict=true + string $name, + bool $classFormat=false, + bool $visibilityPublic=true, + bool $strict=true ) { // Check the first character first. if ($classFormat === false) { @@ -428,7 +428,7 @@ public static function isCamelCaps( * * @return boolean */ - public static function isUnderscoreName($name) + public static function isUnderscoreName(string $name) { // If there is whitespace in the name, it can't be valid. if (strpos($name, ' ') !== false) { @@ -469,7 +469,7 @@ public static function isUnderscoreName($name) * * @return string */ - public static function suggestType($varType) + public static function suggestType(string $varType) { if ($varType === '') { return ''; @@ -589,7 +589,7 @@ public static function getSniffCode($sniffClass) * * @return string */ - public static function cleanSniffClass($sniffClass) + public static function cleanSniffClass(string $sniffClass) { $newName = strtolower($sniffClass); diff --git a/src/Util/Help.php b/src/Util/Help.php index 0c543f2b94..fd4adcb208 100644 --- a/src/Util/Help.php +++ b/src/Util/Help.php @@ -16,7 +16,6 @@ namespace PHP_CodeSniffer\Util; -use InvalidArgumentException; use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Util\Common; @@ -137,15 +136,9 @@ final class Help * @param \PHP_CodeSniffer\Config $config Configuration object. * @param array $longOptions The long options which should be shown. * @param string $shortOptions The short options which should be shown. - * - * @throws \InvalidArgumentException When $shortOptions is not a string. */ - public function __construct(Config $config, array $longOptions, $shortOptions='') + public function __construct(Config $config, array $longOptions, string $shortOptions='') { - if (is_string($shortOptions) === false) { - throw new InvalidArgumentException('The $shortOptions parameter must be a string'); - } - $this->config = $config; $this->requestedOptions = array_merge($longOptions, str_split($shortOptions)); @@ -327,7 +320,7 @@ private function printCategories() * * @return void */ - private function printCategoryHeader($header) + private function printCategoryHeader(string $header) { $header .= ':'; if ($this->config->colors === true) { @@ -393,7 +386,7 @@ private function printCategoryOptions(array $options) * * @return string */ - private function colorizeVariableInput($text) + private function colorizeVariableInput(string $text) { return preg_replace('`(<(?:(?>[^<>]+)|(?R))*>)`', "\033[36m".'$1'."\033[32m", $text); diff --git a/src/Util/IgnoreList.php b/src/Util/IgnoreList.php index 14cf50c5ce..86797bc831 100644 --- a/src/Util/IgnoreList.php +++ b/src/Util/IgnoreList.php @@ -96,7 +96,7 @@ public static function getNewInstanceFrom(?IgnoreList $ignoreList) * * @return \PHP_CodeSniffer\Util\IgnoreList $this for chaining. */ - public function set($code, $ignore) + public function set(string $code, bool $ignore) { $data = &$this->data; $parts = explode('.', $code); @@ -126,7 +126,7 @@ public function set($code, $ignore) * * @return bool */ - public function isIgnored($code) + public function isIgnored(string $code) { $data = $this->data; $returnValue = $data['.default']; diff --git a/src/Util/MessageCollector.php b/src/Util/MessageCollector.php index 23ab88155b..99984d863d 100644 --- a/src/Util/MessageCollector.php +++ b/src/Util/MessageCollector.php @@ -146,7 +146,7 @@ public function containsBlockingErrors() * * @throws \PHP_CodeSniffer\Exceptions\RuntimeException When there are blocking errors. */ - public function display($order=self::ORDERBY_SEVERITY) + public function display(string $order=self::ORDERBY_SEVERITY) { if ($this->cache === []) { return; @@ -199,7 +199,7 @@ private function prefixAll(array $messages) * * @return string */ - private function prefix($message, $type) + private function prefix(string $message, int $type) { switch ($type) { case self::ERROR: diff --git a/src/Util/Standards.php b/src/Util/Standards.php index d22f233086..ce1d7104de 100644 --- a/src/Util/Standards.php +++ b/src/Util/Standards.php @@ -77,8 +77,8 @@ public static function getInstalledStandardPaths() * @see getInstalledStandardPaths() */ public static function getInstalledStandardDetails( - $includeGeneric=false, - $standardsDir='' + bool $includeGeneric=false, + string $standardsDir='' ) { $rulesets = []; @@ -166,8 +166,8 @@ public static function getInstalledStandardDetails( * @see isInstalledStandard() */ public static function getInstalledStandards( - $includeGeneric=false, - $standardsDir='' + bool $includeGeneric=false, + string $standardsDir='' ) { $installedStandards = []; @@ -231,7 +231,7 @@ public static function getInstalledStandards( * @return boolean * @see getInstalledStandards() */ - public static function isInstalledStandard($standard) + public static function isInstalledStandard(string $standard) { $path = self::getInstalledStandardPath($standard); if ($path !== null && strpos($path, 'ruleset.xml') !== false) { @@ -277,7 +277,7 @@ public static function isInstalledStandard($standard) * * @return string|null */ - public static function getInstalledStandardPath($standard) + public static function getInstalledStandardPath(string $standard) { if (strpos($standard, '.') !== false) { return null; diff --git a/src/Util/Timing.php b/src/Util/Timing.php index 9ba3ded3c4..11d57f48a9 100644 --- a/src/Util/Timing.php +++ b/src/Util/Timing.php @@ -89,7 +89,7 @@ public static function getDuration() * * @return float Duration in milliseconds. */ - public static function getDurationSince($startTime) + public static function getDurationSince(float $startTime) { return ((microtime(true) - $startTime) * 1000); @@ -103,7 +103,7 @@ public static function getDurationSince($startTime) * * @return string */ - public static function getHumanReadableDuration($duration) + public static function getHumanReadableDuration(float $duration) { $timeString = ''; if ($duration >= self::MINUTE_IN_MS) { @@ -132,7 +132,7 @@ public static function getHumanReadableDuration($duration) * * @return void */ - public static function printRunTime($force=false) + public static function printRunTime(bool $force=false) { if ($force === false && self::$printed === true) { // A double call. diff --git a/src/Util/Writers/StatusWriter.php b/src/Util/Writers/StatusWriter.php index a52b634282..e147a0c7b0 100644 --- a/src/Util/Writers/StatusWriter.php +++ b/src/Util/Writers/StatusWriter.php @@ -60,7 +60,7 @@ final class StatusWriter * * @return void */ - public static function write($message, $indent=0, $newlines=1) + public static function write(string $message, int $indent=0, int $newlines=1) { if (self::$paused === true) { return; @@ -83,7 +83,7 @@ public static function write($message, $indent=0, $newlines=1) * * @return void */ - public static function forceWrite($message, $indent=0, $newlines=1) + public static function forceWrite(string $message, int $indent=0, int $newlines=1) { if ($indent > 0) { $message = str_repeat("\t", $indent).$message; @@ -106,7 +106,7 @@ public static function forceWrite($message, $indent=0, $newlines=1) * * @return void */ - public static function writeNewline($nr=1) + public static function writeNewline(int $nr=1) { self::write('', 0, $nr); @@ -121,7 +121,7 @@ public static function writeNewline($nr=1) * * @return void */ - public static function forceWriteNewline($nr=1) + public static function forceWriteNewline(int $nr=1) { self::forceWrite('', 0, $nr); diff --git a/tests/Core/Util/Help/HelpTest.php b/tests/Core/Util/Help/HelpTest.php index 952d8e4f71..ebf102b34f 100644 --- a/tests/Core/Util/Help/HelpTest.php +++ b/tests/Core/Util/Help/HelpTest.php @@ -9,12 +9,12 @@ namespace PHP_CodeSniffer\Tests\Core\Util\Help; -use InvalidArgumentException; use PHP_CodeSniffer\Tests\ConfigDouble; use PHP_CodeSniffer\Util\Help; use PHPUnit\Framework\TestCase; use ReflectionMethod; use ReflectionProperty; +use TypeError; /** * Test the Help class. @@ -134,20 +134,17 @@ public function testQaValidCategoryOptionDefinitions() /** - * Test receiving an expected exception when the shortOptions parameter is not passed a string value. + * Test receiving an expected exception when the shortOptions parameter is not passed a scalar value. * * @return void */ - public function testConstructorInvalidArgumentException() + public function testConstructorTypeError() { - $message = 'The $shortOptions parameter must be a string'; - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage($message); + $this->expectException(TypeError::class); new Help(new ConfigDouble(), [], []); - }//end testConstructorInvalidArgumentException() + }//end testConstructorTypeError() /** From 089fa31ab5e34107d01d6bf146fe47baaff64c61 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:23:11 +0200 Subject: [PATCH 08/15] 4.0 | (Abstract) Sniff classes: add parameter types --- src/Sniffs/AbstractArraySniff.php | 8 ++++---- src/Sniffs/AbstractPatternSniff.php | 18 +++++++++--------- src/Sniffs/AbstractScopeSniff.php | 10 +++++----- src/Sniffs/AbstractVariableSniff.php | 10 +++++----- src/Sniffs/Sniff.php | 2 +- .../Core/Sniffs/AbstractArraySniffTestable.php | 5 +++-- 6 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/Sniffs/AbstractArraySniff.php b/src/Sniffs/AbstractArraySniff.php index 8dabf344cc..3908dafe04 100644 --- a/src/Sniffs/AbstractArraySniff.php +++ b/src/Sniffs/AbstractArraySniff.php @@ -40,7 +40,7 @@ final public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -110,7 +110,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return int */ - private function getNext(File $phpcsFile, $ptr, $arrayEnd) + private function getNext(File $phpcsFile, int $ptr, int $arrayEnd) { $tokens = $phpcsFile->getTokens(); @@ -150,7 +150,7 @@ private function getNext(File $phpcsFile, $ptr, $arrayEnd) * * @return void */ - abstract protected function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices); + abstract protected function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices); /** @@ -166,7 +166,7 @@ abstract protected function processSingleLineArray($phpcsFile, $stackPtr, $array * * @return void */ - abstract protected function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices); + abstract protected function processMultiLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices); }//end class diff --git a/src/Sniffs/AbstractPatternSniff.php b/src/Sniffs/AbstractPatternSniff.php index 0beb2eb519..60d85a8f58 100644 --- a/src/Sniffs/AbstractPatternSniff.php +++ b/src/Sniffs/AbstractPatternSniff.php @@ -123,7 +123,7 @@ final public function register() * * @return array */ - private function getPatternTokenTypes($pattern) + private function getPatternTokenTypes(array $pattern) { $tokenTypes = []; foreach ($pattern as $pos => $patternInfo) { @@ -149,7 +149,7 @@ private function getPatternTokenTypes($pattern) * as the listener. * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If we could not determine a token to listen for. */ - private function getListenerTokenPos($pattern) + private function getListenerTokenPos(array $pattern) { $tokenTypes = $this->getPatternTokenTypes($pattern); $tokenCodes = array_keys($tokenTypes); @@ -178,7 +178,7 @@ private function getListenerTokenPos($pattern) * @return void * @see register() */ - final public function process(File $phpcsFile, $stackPtr) + final public function process(File $phpcsFile, int $stackPtr) { $file = $phpcsFile->getFilename(); if ($this->currFile !== $file) { @@ -246,7 +246,7 @@ final public function process(File $phpcsFile, $stackPtr) * * @return array|false */ - protected function processPattern($patternInfo, File $phpcsFile, $stackPtr) + protected function processPattern(array $patternInfo, File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $pattern = $patternInfo['pattern']; @@ -697,7 +697,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr) * * @return string The error message. */ - protected function prepareError($found, $patternCode) + protected function prepareError(string $found, string $patternCode) { $found = str_replace("\r\n", '\n', $found); $found = str_replace("\n", '\n', $found); @@ -749,7 +749,7 @@ protected function registerSupplementary() * @return void * @see registerSupplementary() */ - protected function processSupplementary(File $phpcsFile, $stackPtr) + protected function processSupplementary(File $phpcsFile, int $stackPtr) { }//end processSupplementary() @@ -764,7 +764,7 @@ protected function processSupplementary(File $phpcsFile, $stackPtr) * @see createSkipPattern() * @see createTokenPattern() */ - private function parse($pattern) + private function parse(string $pattern) { $patterns = []; $length = strlen($pattern); @@ -855,7 +855,7 @@ private function parse($pattern) * @see createTokenPattern() * @see parse() */ - private function createSkipPattern($pattern, $from) + private function createSkipPattern(string $pattern, int $from) { $skip = ['type' => 'skip']; @@ -908,7 +908,7 @@ private function createSkipPattern($pattern, $from) * @see createSkipPattern() * @see parse() */ - private function createTokenPattern($str) + private function createTokenPattern(string $str) { // Pause the StatusWriter to silence Tokenizer debug info about the patterns being parsed (which only confuses things). StatusWriter::pause(); diff --git a/src/Sniffs/AbstractScopeSniff.php b/src/Sniffs/AbstractScopeSniff.php index 165474ac46..63bb438152 100644 --- a/src/Sniffs/AbstractScopeSniff.php +++ b/src/Sniffs/AbstractScopeSniff.php @@ -11,7 +11,7 @@ * parent::__construct(array(T_CLASS), array(T_FUNCTION)); * } * - * protected function processTokenWithinScope(\PHP_CodeSniffer\Files\File $phpcsFile, $stackPtr, $currScope) + * protected function processTokenWithinScope(\PHP_CodeSniffer\Files\File $phpcsFile, int $stackPtr, int $currScope) * { * $className = $phpcsFile->getDeclarationName($currScope); * $phpcsFile->addWarning('encountered a method within class '.$className, $stackPtr, 'MethodFound'); @@ -71,7 +71,7 @@ abstract class AbstractScopeSniff implements Sniff public function __construct( array $scopeTokens, array $tokens, - $listenOutside=false + bool $listenOutside=false ) { if (empty($scopeTokens) === true) { $error = 'The scope tokens list cannot be empty'; @@ -127,7 +127,7 @@ final public function register() * the rest of the file. * @see processTokenWithinScope() */ - final public function process(File $phpcsFile, $stackPtr) + final public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -167,7 +167,7 @@ final public function process(File $phpcsFile, $stackPtr) * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - abstract protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope); + abstract protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope); /** @@ -183,7 +183,7 @@ abstract protected function processTokenWithinScope(File $phpcsFile, $stackPtr, * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - abstract protected function processTokenOutsideScope(File $phpcsFile, $stackPtr); + abstract protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr); }//end class diff --git a/src/Sniffs/AbstractVariableSniff.php b/src/Sniffs/AbstractVariableSniff.php index db6bf313c5..a1e3c96896 100644 --- a/src/Sniffs/AbstractVariableSniff.php +++ b/src/Sniffs/AbstractVariableSniff.php @@ -84,7 +84,7 @@ public function __construct() * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - final protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) + final protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) { $tokens = $phpcsFile->getTokens(); @@ -162,7 +162,7 @@ final protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $cu * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - final protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + final protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); // These variables are not member vars. @@ -193,7 +193,7 @@ final protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - abstract protected function processMemberVar(File $phpcsFile, $stackPtr); + abstract protected function processMemberVar(File $phpcsFile, int $stackPtr); /** @@ -208,7 +208,7 @@ abstract protected function processMemberVar(File $phpcsFile, $stackPtr); * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - abstract protected function processVariable(File $phpcsFile, $stackPtr); + abstract protected function processVariable(File $phpcsFile, int $stackPtr); /** @@ -227,7 +227,7 @@ abstract protected function processVariable(File $phpcsFile, $stackPtr); * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - abstract protected function processVariableInString(File $phpcsFile, $stackPtr); + abstract protected function processVariableInString(File $phpcsFile, int $stackPtr); }//end class diff --git a/src/Sniffs/Sniff.php b/src/Sniffs/Sniff.php index e0f7cfe9c1..0708b5bb0c 100644 --- a/src/Sniffs/Sniff.php +++ b/src/Sniffs/Sniff.php @@ -74,7 +74,7 @@ public function register(); * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - public function process(File $phpcsFile, $stackPtr); + public function process(File $phpcsFile, int $stackPtr); }//end interface diff --git a/tests/Core/Sniffs/AbstractArraySniffTestable.php b/tests/Core/Sniffs/AbstractArraySniffTestable.php index 751b01a8b9..124bb7e805 100644 --- a/tests/Core/Sniffs/AbstractArraySniffTestable.php +++ b/tests/Core/Sniffs/AbstractArraySniffTestable.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Tests\Core\Sniffs; +use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\AbstractArraySniff; class AbstractArraySniffTestable extends AbstractArraySniff @@ -35,7 +36,7 @@ class AbstractArraySniffTestable extends AbstractArraySniff * * @return void */ - public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices) + public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices) { $this->indicies = $indices; @@ -55,7 +56,7 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra * * @return void */ - public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices) + public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices) { $this->indicies = $indices; From e7b31dd0d7405a0b0fb2ed00027e69391ed48946 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:58:27 +0200 Subject: [PATCH 09/15] 4.0 | Standards/Generic: add parameter types to sniffs --- src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php | 5 +++-- .../Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php | 2 +- .../Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php | 2 +- .../Generic/Sniffs/Classes/DuplicateClassNameSniff.php | 2 +- .../Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php | 2 +- .../Sniffs/CodeAnalysis/AssignmentInConditionSniff.php | 2 +- .../Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php | 6 +++--- .../Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php | 2 +- .../Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php | 2 +- .../CodeAnalysis/ForLoopWithTestFunctionCallSniff.php | 2 +- .../Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php | 2 +- .../RequireExplicitBooleanOperatorPrecedenceSniff.php | 2 +- .../Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php | 2 +- .../Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php | 2 +- .../Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php | 2 +- .../Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php | 2 +- src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php | 2 +- src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php | 2 +- src/Standards/Generic/Sniffs/Commenting/TodoSniff.php | 2 +- .../ControlStructures/DisallowYodaConditionsSniff.php | 4 ++-- .../ControlStructures/InlineControlStructureSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php | 2 +- .../Generic/Sniffs/Files/EndFileNoNewlineSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/LineLengthSniff.php | 4 ++-- .../Generic/Sniffs/Files/LowercasedFilenameSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php | 2 +- .../Generic/Sniffs/Files/OneInterfacePerFileSniff.php | 2 +- .../Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php | 2 +- src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php | 2 +- .../Sniffs/Formatting/DisallowMultipleStatementsSniff.php | 2 +- .../Sniffs/Formatting/MultipleStatementAlignmentSniff.php | 4 ++-- .../Generic/Sniffs/Formatting/SpaceAfterCastSniff.php | 2 +- .../Generic/Sniffs/Formatting/SpaceAfterNotSniff.php | 2 +- .../Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php | 2 +- .../Sniffs/Functions/FunctionCallArgumentSpacingSniff.php | 4 ++-- .../Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php | 2 +- .../Functions/OpeningFunctionBraceKernighanRitchieSniff.php | 2 +- .../Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php | 2 +- src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php | 2 +- .../NamingConventions/AbstractClassNamePrefixSniff.php | 2 +- .../Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php | 4 ++-- .../Sniffs/NamingConventions/ConstructorNameSniff.php | 6 +++--- .../Sniffs/NamingConventions/InterfaceNameSuffixSniff.php | 2 +- .../Sniffs/NamingConventions/TraitNameSuffixSniff.php | 2 +- .../Sniffs/NamingConventions/UpperCaseConstantNameSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php | 2 +- .../Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php | 2 +- .../Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php | 3 ++- .../Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php | 4 ++-- .../Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php | 2 +- .../Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php | 4 ++-- src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php | 2 +- .../Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php | 4 ++-- src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php | 4 ++-- src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php | 6 +++--- src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php | 2 +- .../Generic/Sniffs/PHP/RequireStrictTypesSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php | 2 +- src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php | 2 +- .../Generic/Sniffs/Strings/UnnecessaryHeredocSniff.php | 2 +- .../Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php | 2 +- .../Generic/Sniffs/VersionControl/GitMergeConflictSniff.php | 2 +- .../Sniffs/VersionControl/SubversionPropertiesSniff.php | 4 ++-- .../Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php | 2 +- .../Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php | 2 +- .../Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php | 2 +- .../Generic/Sniffs/WhiteSpace/GotoTargetSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php | 2 +- .../Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php | 4 ++-- .../Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php | 2 +- 79 files changed, 99 insertions(+), 97 deletions(-) diff --git a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php index 5c0fb5dd04..eac4bef40b 100644 --- a/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays; +use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\AbstractArraySniff; use PHP_CodeSniffer\Util\Tokens; @@ -36,7 +37,7 @@ class ArrayIndentSniff extends AbstractArraySniff * * @return void */ - public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices) + public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices) { }//end processSingleLineArray() @@ -55,7 +56,7 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra * * @return void */ - public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices) + public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php b/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php index 6854945ad2..531e1baa93 100644 --- a/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php b/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php index f98277116e..ebbb53506f 100644 --- a/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $phpcsFile->recordMetric($stackPtr, 'Short array syntax used', 'yes'); diff --git a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php index 0645ba5d8e..1192056e96 100644 --- a/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php +++ b/src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php @@ -45,7 +45,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php index 126b648113..8d348dd269 100644 --- a/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php +++ b/src/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php @@ -42,7 +42,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $scopeIdentifier = $phpcsFile->findNext(T_STRING, ($stackPtr + 1)); diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php index d4896f2ad8..7fa17a73e2 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php @@ -75,7 +75,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php index 0dc23d8b6a..aaba609eec 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php @@ -44,7 +44,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -66,7 +66,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - private function processSemicolon(File $phpcsFile, $stackPtr) + private function processSemicolon(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -146,7 +146,7 @@ private function processSemicolon(File $phpcsFile, $stackPtr) * * @return void */ - private function processCloseTag(File $phpcsFile, $stackPtr) + private function processCloseTag(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php index 11e2d13ad3..258acd3858 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php @@ -65,7 +65,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php index 11a831ef61..0b5c1e7753 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php @@ -51,7 +51,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php index d40156b087..4731fdc4b4 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php @@ -55,7 +55,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php index 8174d66532..786bafb656 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php @@ -57,7 +57,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceSniff.php index 99457657c4..c8d8630e1e 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/RequireExplicitBooleanOperatorPrecedenceSniff.php @@ -71,7 +71,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php index 7471be83f2..6916514d0b 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php @@ -58,7 +58,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php index 2f4faa891c..ac0e8b8112 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php @@ -50,7 +50,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php index a3788c411a..4fd2d11299 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php @@ -82,7 +82,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; diff --git a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php index 092b23d6a7..0dcc971251 100644 --- a/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php +++ b/src/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php @@ -61,7 +61,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; diff --git a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php index 9cf9058055..32d840f6da 100644 --- a/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php index d7d26abbb6..ea205e86e3 100644 --- a/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/FixmeSniff.php @@ -39,7 +39,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php index 22450414f1..ab7915210f 100644 --- a/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php +++ b/src/Standards/Generic/Sniffs/Commenting/TodoSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php index 03eafed6d9..acf73d4b79 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/DisallowYodaConditionsSniff.php @@ -42,7 +42,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $previousIndex = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($stackPtr - 1), null, true); @@ -134,7 +134,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return bool */ - public function isArrayStatic(File $phpcsFile, $arrayToken) + public function isArrayStatic(File $phpcsFile, int $arrayToken) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php index 63624a2e28..d4ff889df0 100644 --- a/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +++ b/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php @@ -53,7 +53,7 @@ public function register() * * @return void|int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php b/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php index 60f4025dd9..39522a58dd 100644 --- a/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php +++ b/src/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php @@ -60,7 +60,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // The BOM will be the very first token in the file. if ($stackPtr !== 0) { diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php index ebf9291eb8..e38f2af1fb 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php @@ -40,7 +40,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Skip to the end of the file. $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php index d75f865410..84d767f8e3 100644 --- a/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php +++ b/src/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php @@ -40,7 +40,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Skip to the end of the file. $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php b/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php index 8f597dfdf8..aa6fc2fe06 100644 --- a/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/ExecutableFileSniff.php @@ -40,7 +40,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $filename = $phpcsFile->getFilename(); diff --git a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php index 77228a43af..5abccac0fd 100644 --- a/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php +++ b/src/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php @@ -59,7 +59,7 @@ public function register() * * @return int|void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Allow a byte-order mark. $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php index d6b9d3e5c5..e2cd86f12a 100644 --- a/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineEndingsSniff.php @@ -47,7 +47,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $found = $phpcsFile->eolChar; $found = str_replace("\n", '\n', $found); diff --git a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php index 0df3444a1a..9f0d59da21 100644 --- a/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LineLengthSniff.php @@ -68,7 +68,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); for ($i = 1; $i < $phpcsFile->numTokens; $i++) { @@ -94,7 +94,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - protected function checkLineLength($phpcsFile, $tokens, $stackPtr) + protected function checkLineLength(File $phpcsFile, array $tokens, int $stackPtr) { // The passed token is the first on the line. $stackPtr--; diff --git a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php index 1773cb8a6b..7cd762b262 100644 --- a/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php +++ b/src/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php @@ -40,7 +40,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $filename = $phpcsFile->getFilename(); if ($filename === 'STDIN') { diff --git a/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php index e328e74436..6424af1169 100644 --- a/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $start = ($stackPtr + 1); diff --git a/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php index 34211f2f3c..6110581244 100644 --- a/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $start = ($stackPtr + 1); diff --git a/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php index 459c5d1aae..a061038398 100644 --- a/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneObjectStructurePerFileSniff.php @@ -42,7 +42,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $start = ($stackPtr + 1); diff --git a/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php b/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php index 309383fcdc..aa353bfc39 100644 --- a/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php +++ b/src/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $start = ($stackPtr + 1); diff --git a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php index 750fdabc58..6240f30c8d 100644 --- a/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $fixable = true; diff --git a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php index 0f5a5d30d3..062c7b1958 100644 --- a/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php @@ -61,7 +61,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $lastAssign = $this->checkAlignment($phpcsFile, $stackPtr); return ($lastAssign + 1); @@ -80,7 +80,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return int */ - public function checkAlignment($phpcsFile, $stackPtr, $end=null) + public function checkAlignment(File $phpcsFile, int $stackPtr, ?int $end=null) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php index 7ea5c74ca5..a35a5042c7 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php @@ -52,7 +52,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $this->spacing = (int) $this->spacing; diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php index 2af5b28bf5..f1c60b700f 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php @@ -52,7 +52,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $this->spacing = (int) $this->spacing; diff --git a/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php b/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php index 5659892b35..8c608cb537 100644 --- a/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php +++ b/src/Standards/Generic/Sniffs/Formatting/SpaceBeforeCastSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php index 7ef4d7094a..a1e13a5a44 100644 --- a/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php @@ -48,7 +48,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -99,7 +99,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - public function checkSpacing(File $phpcsFile, $stackPtr, $openBracket) + public function checkSpacing(File $phpcsFile, int $stackPtr, int $openBracket) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php index ef0f7af7a2..e6f0f08373 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php @@ -55,7 +55,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php index 3d6c3098cf..45a847f67b 100644 --- a/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +++ b/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php @@ -55,7 +55,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php index 9bce43c189..085a4b404f 100644 --- a/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php @@ -77,7 +77,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php index d2672b5eeb..4fc9e7d352 100644 --- a/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php +++ b/src/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php @@ -52,7 +52,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php index f009d56ef2..24cc4bc1c4 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/AbstractClassNamePrefixSniff.php @@ -36,7 +36,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { if ($phpcsFile->getClassProperties($stackPtr)['is_abstract'] === false) { // This class is not abstract so we don't need to check it. diff --git a/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php index d9d160442c..fd7302a9a2 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php @@ -126,7 +126,7 @@ public function __construct() * * @return void */ - protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) { $tokens = $phpcsFile->getTokens(); @@ -211,7 +211,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop * * @return void */ - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { $functionName = $phpcsFile->getDeclarationName($stackPtr); if ($functionName === '') { diff --git a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php index 6fc23f0825..92039f1bfe 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php @@ -55,7 +55,7 @@ public function __construct() * * @return void */ - protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) { $tokens = $phpcsFile->getTokens(); @@ -144,7 +144,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop * * @return void */ - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { }//end processTokenOutsideScope() @@ -158,7 +158,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) * * @return void */ - protected function loadFunctionNamesInScope(File $phpcsFile, $currScope) + protected function loadFunctionNamesInScope(File $phpcsFile, int $currScope) { $this->functionList = []; $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php index 1bd01b335c..21f771cce6 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/InterfaceNameSuffixSniff.php @@ -36,7 +36,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $interfaceName = $phpcsFile->getDeclarationName($stackPtr); if ($interfaceName === '') { diff --git a/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php index 45bc549718..a9350e7ee8 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/TraitNameSuffixSniff.php @@ -36,7 +36,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $traitName = $phpcsFile->getDeclarationName($stackPtr); if ($traitName === '') { diff --git a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php index 497124d7e8..c3cf71d598 100644 --- a/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +++ b/src/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php @@ -42,7 +42,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php b/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php index f3c56b5888..28805aa820 100644 --- a/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $error = 'Use of the backtick operator is forbidden'; $phpcsFile->addError($error, $stackPtr, 'Found'); diff --git a/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php b/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php index c55622bfa3..6e9b6cea02 100644 --- a/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php @@ -59,7 +59,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $expected = 0; if ($stackPtr > 0) { diff --git a/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php b/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php index 23dd2b6b20..5f7d4ac028 100644 --- a/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $closeTag = $phpcsFile->findNext(T_CLOSE_TAG, $stackPtr); if ($closeTag === false) { diff --git a/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php b/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php index e75b7d00bd..ee4baabd40 100644 --- a/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php @@ -10,6 +10,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP; +use PHP_CodeSniffer\Files\File; use ReflectionFunction; class DeprecatedFunctionsSniff extends ForbiddenFunctionsSniff @@ -57,7 +58,7 @@ public function __construct() * * @return void */ - protected function addError($phpcsFile, $stackPtr, $functionName, $pattern=null) + protected function addError(File $phpcsFile, int $stackPtr, string $functionName, ?string $pattern=null) { $data = [$functionName]; $error = 'Function %s() has been deprecated'; diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php index 511b31cc08..0f5331071f 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php @@ -39,7 +39,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $openTag = $tokens[$stackPtr]; @@ -86,7 +86,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return string */ - protected function getSnippet($content, $start='', $length=40) + protected function getSnippet(string $content, string $start='', int $length=40) { $startPos = 0; diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php index acab6e3f97..6ea4334bf8 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowRequestSuperglobalSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php index 69ce307506..d21172f72c 100644 --- a/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php @@ -48,7 +48,7 @@ public function register() * * @return void|int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $token = $tokens[$stackPtr]; @@ -146,7 +146,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return string */ - protected function getSnippet($content, $start='', $length=40) + protected function getSnippet(string $content, string $start='', int $length=40) { $startPos = 0; diff --git a/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php b/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php index 063489a724..c7abc69e4c 100644 --- a/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/DiscourageGotoSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $phpcsFile->addWarning('Use of the GOTO language construct is discouraged', $stackPtr, 'Found'); diff --git a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php index fd44e51645..2198a6df05 100644 --- a/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php @@ -122,7 +122,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -210,7 +210,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - protected function addError($phpcsFile, $stackPtr, $functionName, $pattern=null) + protected function addError(File $phpcsFile, int $stackPtr, string $functionName, ?string $pattern=null) { $data = [$functionName]; $error = 'The use of function %s() is '; diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php index b5b773fa65..7449642a07 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php @@ -88,7 +88,7 @@ public function register() * called again on the current file until the returned stack * pointer is reached. */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -201,7 +201,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - protected function processConstant(File $phpcsFile, $stackPtr) + protected function processConstant(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $keyword = $tokens[$stackPtr]['content']; diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php index 8e1a3260fd..be47356af3 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php @@ -52,7 +52,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $keyword = $tokens[$stackPtr]['content']; diff --git a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php index 5da9e6a7af..31836e7f02 100644 --- a/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php @@ -69,7 +69,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -266,7 +266,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - protected function processUnionType(File $phpcsFile, $typeDeclStart, $typeDeclEnd, $error, $errorCode) + protected function processUnionType(File $phpcsFile, int $typeDeclStart, int $typeDeclEnd, string $error, string $errorCode) { $tokens = $phpcsFile->getTokens(); $typeTokenCount = 0; @@ -328,7 +328,7 @@ protected function processUnionType(File $phpcsFile, $typeDeclStart, $typeDeclEn * * @return void */ - protected function processType(File $phpcsFile, $stackPtr, $type, $error, $errorCode) + protected function processType(File $phpcsFile, int $stackPtr, string $type, string $error, string $errorCode) { $typeLower = strtolower($type); diff --git a/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php b/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php index 87bf11c418..545e13e895 100644 --- a/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php @@ -51,7 +51,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Prepare the "Found" string to display. $contextLength = 4; diff --git a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php index dcf3f56153..459f55eea3 100644 --- a/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/RequireStrictTypesSniff.php @@ -38,7 +38,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $declare = $phpcsFile->findNext(T_DECLARE, ($stackPtr + 1)); diff --git a/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php b/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php index 555e9cdeb2..3f68328f3a 100644 --- a/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php index 803e3802db..f552561a4f 100644 --- a/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php @@ -50,7 +50,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { if ($this->phpPath === null) { $this->phpPath = Config::getExecutablePath('php'); diff --git a/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php b/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php index 1a65f3c34e..130297c8a7 100644 --- a/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php +++ b/src/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php @@ -24,7 +24,7 @@ class UpperCaseConstantSniff extends LowerCaseConstantSniff * * @return void */ - protected function processConstant(File $phpcsFile, $stackPtr) + protected function processConstant(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $keyword = $tokens[$stackPtr]['content']; diff --git a/src/Standards/Generic/Sniffs/Strings/UnnecessaryHeredocSniff.php b/src/Standards/Generic/Sniffs/Strings/UnnecessaryHeredocSniff.php index e6c04dbfd4..4993934c53 100644 --- a/src/Standards/Generic/Sniffs/Strings/UnnecessaryHeredocSniff.php +++ b/src/Standards/Generic/Sniffs/Strings/UnnecessaryHeredocSniff.php @@ -66,7 +66,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php index 436424b3d7..047135cd63 100644 --- a/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php +++ b/src/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php @@ -48,7 +48,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php index 30faf73489..120b8810c3 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/GitMergeConflictSniff.php @@ -40,7 +40,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $error = 'Merge conflict boundary found; type: %s'; diff --git a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php index 5642be16bd..87466b0abd 100644 --- a/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php +++ b/src/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php @@ -61,7 +61,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $path = $phpcsFile->getFilename(); $properties = $this->getProperties($path); @@ -126,7 +126,7 @@ public function process(File $phpcsFile, $stackPtr) * @throws \PHP_CodeSniffer\Exceptions\RuntimeException If Subversion properties file could * not be opened. */ - protected function getProperties($path) + protected function getProperties(string $path) { $properties = []; diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php index 1e03894d36..2b852d2394 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php @@ -76,7 +76,7 @@ public function register() * * @return void|int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php index e6fbfab040..69a0284c36 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php @@ -61,7 +61,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tabsReplaced = false; if ($this->tabWidth === null) { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php index 9409322ee5..0dc03302b1 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php @@ -63,7 +63,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { if ($this->tabWidth === null) { if (isset($phpcsFile->config->tabWidth) === false || $phpcsFile->config->tabWidth === 0) { diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/GotoTargetSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/GotoTargetSpacingSniff.php index 8da73e7390..4e297c7adb 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/GotoTargetSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/GotoTargetSpacingSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php index ca595743d4..b1e548a3b9 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/HereNowdocIdentifierSpacingSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php index 84d299e9c2..01565f804c 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/IncrementDecrementSpacingSniff.php @@ -41,7 +41,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php index 68d4994df0..75e504a023 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php @@ -55,7 +55,7 @@ public function register() * @return int|void Integer stack pointer to skip forward or void to continue * normal file processing. */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index c35d9f7e2a..10da68ef6f 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -111,7 +111,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $debug = Config::getConfigData('scope_indent_debug'); if ($debug !== null) { @@ -1323,7 +1323,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return bool */ - protected function adjustIndent(File $phpcsFile, $stackPtr, $length, $change) + protected function adjustIndent(File $phpcsFile, int $stackPtr, int $length, int $change) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php index c45f5aae9f..ae9c5aeb6f 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/SpreadOperatorSpacingAfterSniff.php @@ -52,7 +52,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $this->spacing = (int) $this->spacing; From f69ee7cf2ece1a354328af009aa6a5b4faf02456 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:59:10 +0200 Subject: [PATCH 10/15] 4.0 | Standards/PEAR: add parameter types to sniffs --- .../Sniffs/Classes/ClassDeclarationSniff.php | 2 +- .../Sniffs/Commenting/ClassCommentSniff.php | 4 ++-- .../Sniffs/Commenting/FileCommentSniff.php | 18 +++++++++--------- .../Sniffs/Commenting/FunctionCommentSniff.php | 8 ++++---- .../Sniffs/Commenting/InlineCommentSniff.php | 2 +- .../MultiLineConditionSniff.php | 2 +- .../PEAR/Sniffs/Files/IncludingFileSniff.php | 2 +- .../Formatting/MultiLineAssignmentSniff.php | 2 +- .../Functions/FunctionCallSignatureSniff.php | 8 ++++---- .../Functions/FunctionDeclarationSniff.php | 10 +++++----- .../Functions/ValidDefaultValueSniff.php | 2 +- .../NamingConventions/ValidClassNameSniff.php | 2 +- .../ValidFunctionNameSniff.php | 4 ++-- .../ValidVariableNameSniff.php | 6 +++--- .../WhiteSpace/ObjectOperatorIndentSniff.php | 2 +- .../WhiteSpace/ScopeClosingBraceSniff.php | 2 +- 16 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php index 3466be1a44..346bb19b47 100644 --- a/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php @@ -42,7 +42,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $errorData = [strtolower($tokens[$stackPtr]['content'])]; diff --git a/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php index 8fa6bfba79..daf4267e16 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php @@ -41,7 +41,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $type = strtolower($tokens[$stackPtr]['content']); @@ -99,7 +99,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVersion($phpcsFile, array $tags) + protected function processVersion(File $phpcsFile, array $tags) { $tokens = $phpcsFile->getTokens(); foreach ($tags as $tag) { diff --git a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php index 0e0da3e7f9..f62243e9b5 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php @@ -99,7 +99,7 @@ public function register() * * @return int|void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -228,7 +228,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - protected function processTags($phpcsFile, $stackPtr, $commentStart) + protected function processTags(File $phpcsFile, int $stackPtr, int $commentStart) { $tokens = $phpcsFile->getTokens(); @@ -325,7 +325,7 @@ protected function processTags($phpcsFile, $stackPtr, $commentStart) * * @return void */ - protected function processCategory($phpcsFile, array $tags) + protected function processCategory(File $phpcsFile, array $tags) { $tokens = $phpcsFile->getTokens(); foreach ($tags as $tag) { @@ -367,7 +367,7 @@ protected function processCategory($phpcsFile, array $tags) * * @return void */ - protected function processPackage($phpcsFile, array $tags) + protected function processPackage(File $phpcsFile, array $tags) { $tokens = $phpcsFile->getTokens(); foreach ($tags as $tag) { @@ -420,7 +420,7 @@ protected function processPackage($phpcsFile, array $tags) * * @return void */ - protected function processSubpackage($phpcsFile, array $tags) + protected function processSubpackage(File $phpcsFile, array $tags) { $tokens = $phpcsFile->getTokens(); foreach ($tags as $tag) { @@ -464,7 +464,7 @@ protected function processSubpackage($phpcsFile, array $tags) * * @return void */ - protected function processAuthor($phpcsFile, array $tags) + protected function processAuthor(File $phpcsFile, array $tags) { $tokens = $phpcsFile->getTokens(); foreach ($tags as $tag) { @@ -494,7 +494,7 @@ protected function processAuthor($phpcsFile, array $tags) * * @return void */ - protected function processCopyright($phpcsFile, array $tags) + protected function processCopyright(File $phpcsFile, array $tags) { $tokens = $phpcsFile->getTokens(); foreach ($tags as $tag) { @@ -535,7 +535,7 @@ protected function processCopyright($phpcsFile, array $tags) * * @return void */ - protected function processLicense($phpcsFile, array $tags) + protected function processLicense(File $phpcsFile, array $tags) { $tokens = $phpcsFile->getTokens(); foreach ($tags as $tag) { @@ -564,7 +564,7 @@ protected function processLicense($phpcsFile, array $tags) * * @return void */ - protected function processVersion($phpcsFile, array $tags) + protected function processVersion(File $phpcsFile, array $tags) { $tokens = $phpcsFile->getTokens(); foreach ($tags as $tag) { diff --git a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php index 2661ca97f8..3b3201f11b 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php @@ -57,7 +57,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $scopeModifier = $phpcsFile->getMethodProperties($stackPtr)['scope']; if (($scopeModifier === 'protected' @@ -189,7 +189,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) + protected function processReturn(File $phpcsFile, int $stackPtr, int $commentStart) { $tokens = $phpcsFile->getTokens(); @@ -238,7 +238,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) * * @return void */ - protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) + protected function processThrows(File $phpcsFile, int $stackPtr, int $commentStart) { $tokens = $phpcsFile->getTokens(); @@ -273,7 +273,7 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) * * @return void */ - protected function processParams(File $phpcsFile, $stackPtr, $commentStart) + protected function processParams(File $phpcsFile, int $stackPtr, int $commentStart) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php index 71c11808dd..575374d222 100644 --- a/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php index c9dfefa69d..89caa9c417 100644 --- a/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php +++ b/src/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php @@ -48,7 +48,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php index afb3974be7..93a03fa533 100644 --- a/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php +++ b/src/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php @@ -45,7 +45,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php b/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php index 0f18710df4..111c3cc0e1 100644 --- a/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php +++ b/src/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php @@ -44,7 +44,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php index 24fb56ac1c..2c56243a9b 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php @@ -73,7 +73,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $this->requiredSpacesAfterOpen = (int) $this->requiredSpacesAfterOpen; $this->requiredSpacesBeforeClose = (int) $this->requiredSpacesBeforeClose; @@ -171,7 +171,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return bool */ - public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) + public function isMultiLineCall(File $phpcsFile, int $stackPtr, int $openBracket, array $tokens) { $closeBracket = $tokens[$openBracket]['parenthesis_closer']; if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) { @@ -196,7 +196,7 @@ public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $token * * @return void */ - public function processSingleLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) + public function processSingleLineCall(File $phpcsFile, int $stackPtr, int $openBracket, array $tokens) { $closer = $tokens[$openBracket]['parenthesis_closer']; if ($openBracket === ($closer - 1)) { @@ -326,7 +326,7 @@ public function processSingleLineCall(File $phpcsFile, $stackPtr, $openBracket, * * @return void */ - public function processMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) + public function processMultiLineCall(File $phpcsFile, int $stackPtr, int $openBracket, array $tokens) { // We need to work out how far indented the function // call itself is, so we can work out how far to diff --git a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php index f60f5ca947..1d6e5a7798 100644 --- a/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php @@ -50,7 +50,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -210,7 +210,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return bool */ - public function isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tokens) + public function isMultiLineDeclaration(File $phpcsFile, int $stackPtr, int $openBracket, array $tokens) { $closeBracket = $tokens[$openBracket]['parenthesis_closer']; if ($tokens[$openBracket]['line'] !== $tokens[$closeBracket]['line']) { @@ -247,7 +247,7 @@ public function isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tok * * @return void */ - public function processSingleLineDeclaration($phpcsFile, $stackPtr, $tokens) + public function processSingleLineDeclaration(File $phpcsFile, int $stackPtr, array $tokens) { if ($tokens[$stackPtr]['code'] === T_CLOSURE) { $sniff = new OpeningFunctionBraceKernighanRitchieSniff(); @@ -272,7 +272,7 @@ public function processSingleLineDeclaration($phpcsFile, $stackPtr, $tokens) * * @return void */ - public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) + public function processMultiLineDeclaration(File $phpcsFile, int $stackPtr, array $tokens) { $this->processArgumentList($phpcsFile, $stackPtr, $this->indent); @@ -371,7 +371,7 @@ public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) * * @return void */ - public function processArgumentList($phpcsFile, $stackPtr, $indent, $type='function') + public function processArgumentList(File $phpcsFile, int $stackPtr, int $indent, string $type='function') { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php index 34643acbee..4e2255c3e9 100644 --- a/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php +++ b/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php @@ -41,7 +41,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Flag for when we have found a default in our arg list. // If there is a value without a default after this, it is an error. diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php index c2ed80ac6e..a78e707e77 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php @@ -42,7 +42,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php index cf89387273..976f7d0af6 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -88,7 +88,7 @@ public function __construct() * * @return void */ - protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) { $tokens = $phpcsFile->getTokens(); @@ -196,7 +196,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop * * @return void */ - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { $functionName = $phpcsFile->getDeclarationName($stackPtr); if (ltrim($functionName, '_') === '') { diff --git a/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php index eded91388b..4146bf8301 100644 --- a/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -38,7 +38,7 @@ public function __construct() * * @return void */ - protected function processMemberVar(File $phpcsFile, $stackPtr) + protected function processMemberVar(File $phpcsFile, int $stackPtr) { try { $memberProps = $phpcsFile->getMemberProperties($stackPtr); @@ -92,7 +92,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariable(File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, int $stackPtr) { /* We don't care about normal variables. @@ -109,7 +109,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariableInString(File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, int $stackPtr) { /* We don't care about normal variables. diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php index f6c9dbf802..716b571a8b 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php @@ -61,7 +61,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index 704c51e560..f304dff1ef 100644 --- a/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -45,7 +45,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); From c0f8a9143140731275a14cf597d8850ed7d71a4c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:59:50 +0200 Subject: [PATCH 11/15] 4.0 | Standards/PSR: add parameter types to sniffs --- src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php | 2 +- src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php | 4 ++-- .../PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php | 4 ++-- .../PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php | 6 +++--- .../PSR12/Sniffs/Classes/ClassInstantiationSniff.php | 2 +- src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php | 2 +- .../PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php | 2 +- .../ControlStructures/BooleanOperatorPlacementSniff.php | 2 +- .../ControlStructures/ControlStructureSpacingSniff.php | 2 +- src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php | 2 +- src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php | 6 +++--- src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php | 2 +- src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php | 2 +- .../PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php | 2 +- .../PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php | 2 +- .../PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php | 2 +- .../PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php | 2 +- .../PSR12/Sniffs/Operators/OperatorSpacingSniff.php | 2 +- .../PSR12/Sniffs/Properties/ConstantVisibilitySniff.php | 2 +- src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php | 6 +++--- src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php | 6 +++--- .../PSR2/Sniffs/Classes/PropertyDeclarationSniff.php | 6 +++--- .../ControlStructures/ControlStructureSpacingSniff.php | 2 +- .../Sniffs/ControlStructures/ElseIfDeclarationSniff.php | 2 +- .../Sniffs/ControlStructures/SwitchDeclarationSniff.php | 6 +++--- src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php | 2 +- src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php | 2 +- .../PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php | 2 +- .../PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php | 2 +- .../PSR2/Sniffs/Methods/MethodDeclarationSniff.php | 4 ++-- .../PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php | 2 +- .../PSR2/Sniffs/Namespaces/UseDeclarationSniff.php | 4 ++-- 32 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php index e3f626b3ce..88da7606d5 100644 --- a/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php @@ -42,7 +42,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['scope_closer']) === false) { diff --git a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php index 5397962557..7804495bf6 100644 --- a/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php +++ b/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php @@ -62,7 +62,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $result = $this->searchForConflict($phpcsFile, 0, ($phpcsFile->numTokens - 1), $tokens); @@ -100,7 +100,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return array */ - private function searchForConflict($phpcsFile, $start, $end, $tokens) + private function searchForConflict(File $phpcsFile, int $start, int $end, array $tokens) { $checkAnnotations = $phpcsFile->config->annotations; diff --git a/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php b/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php index 1127dac646..e99fa97b3b 100644 --- a/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php +++ b/src/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php @@ -27,7 +27,7 @@ class CamelCapsMethodNameSniff extends GenericCamelCapsFunctionNameSniff * * @return void */ - protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) { $tokens = $phpcsFile->getTokens(); @@ -82,7 +82,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop * * @return void */ - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { }//end processTokenOutsideScope() diff --git a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php index 80eda11a85..31508b61af 100644 --- a/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/AnonClassDeclarationSniff.php @@ -54,7 +54,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['scope_opener']) === false) { @@ -144,7 +144,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - public function processSingleLineArgumentList(File $phpcsFile, $stackPtr) + public function processSingleLineArgumentList(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -231,7 +231,7 @@ public function processSingleLineArgumentList(File $phpcsFile, $stackPtr) * * @return void */ - public function processMultiLineArgumentList(File $phpcsFile, $stackPtr) + public function processMultiLineArgumentList(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php index c870ead4f9..6c005ceabe 100644 --- a/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php b/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php index 82f215f6ef..3e241c326d 100644 --- a/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/ClosingBraceSniff.php @@ -43,7 +43,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['scope_closer']) === false) { diff --git a/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php b/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php index 55251418f5..7825057f73 100644 --- a/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php +++ b/src/Standards/PSR12/Sniffs/Classes/OpeningBraceSpaceSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['scope_opener']) === false) { diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php index 295c0bd379..ca0c68b399 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/BooleanOperatorPlacementSniff.php @@ -62,7 +62,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index 8322c91bd7..43417c13d9 100644 --- a/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR12/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -72,7 +72,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php index 3d81af18ce..86027d0617 100644 --- a/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/DeclareStatementSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Allow a byte-order mark. $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php index 6350265cc1..a47a172a73 100644 --- a/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/FileHeaderSniff.php @@ -38,7 +38,7 @@ public function register() * * @return int|void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -128,7 +128,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return array */ - public function getHeaderLines(File $phpcsFile, $stackPtr) + public function getHeaderLines(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -286,7 +286,7 @@ public function getHeaderLines(File $phpcsFile, $stackPtr) * * @return void */ - public function processHeaderLines(File $phpcsFile, $headerLines) + public function processHeaderLines(File $phpcsFile, array $headerLines) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php b/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php index 8aff3d51e7..af4ebe14da 100644 --- a/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/ImportStatementSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php index f8863ffab2..a43341fc4a 100644 --- a/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php +++ b/src/Standards/PSR12/Sniffs/Files/OpenTagSniff.php @@ -37,7 +37,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { if ($stackPtr !== 0) { // This rule only applies if the open tag is on the first line of the file. diff --git a/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php index f65d480429..19f9880278 100644 --- a/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Functions/NullableTypeDeclarationSniff.php @@ -53,7 +53,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $nextNonEmptyPtr = $phpcsFile->findNext([T_WHITESPACE], ($stackPtr + 1), null, true); if ($nextNonEmptyPtr === false) { diff --git a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php index cf1afc560d..654b6d240c 100644 --- a/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Functions/ReturnTypeDeclarationSniff.php @@ -41,7 +41,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php b/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php index 65d39eb915..899499f6db 100644 --- a/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php +++ b/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $typecast = str_replace(' ', '', $tokens[$stackPtr]['content']); diff --git a/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php b/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php index a67f3b70ef..dbd34e2043 100644 --- a/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php +++ b/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php @@ -44,7 +44,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $this->maxDepth = (int) $this->maxDepth; diff --git a/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php b/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php index ff4df8325d..e5cd2d40e8 100644 --- a/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php +++ b/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php @@ -55,7 +55,7 @@ public function register() * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php b/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php index 28d4150fea..6dbd01383e 100644 --- a/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php +++ b/src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php @@ -49,7 +49,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php index 74c3828eb9..dc9fd101ab 100644 --- a/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php +++ b/src/Standards/PSR12/Sniffs/Traits/UseDeclarationSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void|int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -312,7 +312,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - protected function processUseGroup(File $phpcsFile, $stackPtr) + protected function processUseGroup(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -680,7 +680,7 @@ protected function processUseGroup(File $phpcsFile, $stackPtr) * * @return void */ - protected function processUseStatement(File $phpcsFile, $stackPtr) + protected function processUseStatement(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php index c95f0a40ad..9207b64222 100644 --- a/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php @@ -44,7 +44,7 @@ class ClassDeclarationSniff extends PEARClassDeclarationSniff * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // We want all the errors from the PEAR standard, plus some of our own. parent::process($phpcsFile, $stackPtr); @@ -70,7 +70,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - public function processOpen(File $phpcsFile, $stackPtr) + public function processOpen(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $stackPtrType = strtolower($tokens[$stackPtr]['content']); @@ -473,7 +473,7 @@ public function processOpen(File $phpcsFile, $stackPtr) * * @return void */ - public function processClose(File $phpcsFile, $stackPtr) + public function processClose(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php index 5be9959510..15a88b40a8 100644 --- a/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php @@ -37,7 +37,7 @@ public function __construct() * * @return void */ - protected function processMemberVar(File $phpcsFile, $stackPtr) + protected function processMemberVar(File $phpcsFile, int $stackPtr) { try { $propertyInfo = $phpcsFile->getMemberProperties($stackPtr); @@ -290,7 +290,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariable(File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, int $stackPtr) { /* We don't care about normal variables. @@ -307,7 +307,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariableInString(File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, int $stackPtr) { /* We don't care about normal variables. diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php index afd6caecfe..06d218a74e 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php @@ -61,7 +61,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $this->requiredSpacesAfterOpen = (int) $this->requiredSpacesAfterOpen; $this->requiredSpacesBeforeClose = (int) $this->requiredSpacesBeforeClose; diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php index 7f5e97c188..59abfd1c46 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php index fa9a2d289a..71d633cfe9 100644 --- a/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -59,7 +59,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -236,7 +236,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return int|false */ - private function findNextCase($phpcsFile, $stackPtr, $end) + private function findNextCase(File $phpcsFile, int $stackPtr, int $end) { $tokens = $phpcsFile->getTokens(); while (($stackPtr = $phpcsFile->findNext([T_CASE, T_DEFAULT, T_SWITCH], $stackPtr, $end)) !== false) { @@ -265,7 +265,7 @@ private function findNextCase($phpcsFile, $stackPtr, $end) * * @return int|bool */ - private function findNestedTerminator($phpcsFile, $stackPtr, $end) + private function findNestedTerminator(File $phpcsFile, int $stackPtr, int $end) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php index 80c97b11b4..c57a6ec366 100644 --- a/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php @@ -38,7 +38,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php index 5b2d2817b7..60f4c0793e 100644 --- a/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php +++ b/src/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php @@ -40,7 +40,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { if ($phpcsFile->findNext(T_INLINE_HTML, ($stackPtr + 1)) !== false) { return $phpcsFile->numTokens; diff --git a/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php b/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php index adb717db02..3034306ab5 100644 --- a/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php @@ -37,7 +37,7 @@ class FunctionCallSignatureSniff extends PEARFunctionCallSignatureSniff * * @return bool */ - public function isMultiLineCall(File $phpcsFile, $stackPtr, $openBracket, $tokens) + public function isMultiLineCall(File $phpcsFile, int $stackPtr, int $openBracket, array $tokens) { // If the first argument is on a new line, this is a multi-line // function call, even if there is only one argument. diff --git a/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php b/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php index c4f1a6f4fc..c697c0e325 100644 --- a/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php index 7eb1b864fe..e8a200a404 100644 --- a/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php @@ -36,7 +36,7 @@ public function __construct() * * @return void */ - protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) { $tokens = $phpcsFile->getTokens(); @@ -153,7 +153,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop * * @return void */ - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { }//end processTokenOutsideScope() diff --git a/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php index e414a495e2..0abd7a2912 100644 --- a/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php index 0bb1ce645c..00ee940685 100644 --- a/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php +++ b/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { if ($this->shouldIgnoreUse($phpcsFile, $stackPtr) === true) { return; @@ -274,7 +274,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return bool */ - private function shouldIgnoreUse($phpcsFile, $stackPtr) + private function shouldIgnoreUse(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); From b52d312ebdf34950adc951bfec5141e4876ab536 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 22:04:27 +0200 Subject: [PATCH 12/15] 4.0 | Standards/Squiz: add parameter types to sniffs --- .../Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php | 2 +- .../Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php | 6 +++--- .../Squiz/Sniffs/Classes/ClassDeclarationSniff.php | 6 +++--- .../Squiz/Sniffs/Classes/ClassFileNameSniff.php | 2 +- .../Sniffs/Classes/LowercaseClassKeywordsSniff.php | 2 +- .../Sniffs/Classes/SelfMemberReferenceSniff.php | 6 +++--- .../Squiz/Sniffs/Classes/ValidClassNameSniff.php | 2 +- .../Squiz/Sniffs/Commenting/BlockCommentSniff.php | 2 +- .../Squiz/Sniffs/Commenting/ClassCommentSniff.php | 2 +- .../Commenting/ClosingDeclarationCommentSniff.php | 2 +- .../Sniffs/Commenting/DocCommentAlignmentSniff.php | 2 +- .../Sniffs/Commenting/EmptyCatchCommentSniff.php | 2 +- .../Squiz/Sniffs/Commenting/FileCommentSniff.php | 2 +- .../Squiz/Sniffs/Commenting/FunctionCommentSniff.php | 12 ++++++------ .../Commenting/FunctionCommentThrowTagSniff.php | 2 +- .../Squiz/Sniffs/Commenting/InlineCommentSniff.php | 2 +- .../Commenting/LongConditionClosingCommentSniff.php | 2 +- .../Sniffs/Commenting/PostStatementCommentSniff.php | 2 +- .../Squiz/Sniffs/Commenting/VariableCommentSniff.php | 6 +++--- .../ControlStructures/ControlSignatureSniff.php | 2 +- .../ControlStructures/ElseIfDeclarationSniff.php | 2 +- .../ForEachLoopDeclarationSniff.php | 2 +- .../ControlStructures/ForLoopDeclarationSniff.php | 2 +- .../ControlStructures/InlineIfDeclarationSniff.php | 2 +- .../ControlStructures/LowercaseDeclarationSniff.php | 2 +- .../ControlStructures/SwitchDeclarationSniff.php | 2 +- .../Squiz/Sniffs/Files/FileExtensionSniff.php | 2 +- .../Squiz/Sniffs/Formatting/OperatorBracketSniff.php | 4 ++-- .../FunctionDeclarationArgumentSpacingSniff.php | 4 ++-- .../Functions/FunctionDuplicateArgumentSniff.php | 2 +- .../Squiz/Sniffs/Functions/GlobalFunctionSniff.php | 2 +- .../Functions/LowercaseFunctionKeywordsSniff.php | 2 +- .../Functions/MultiLineFunctionDeclarationSniff.php | 9 +++++---- .../NamingConventions/ValidFunctionNameSniff.php | 2 +- .../NamingConventions/ValidVariableNameSniff.php | 6 +++--- .../Sniffs/Objects/ObjectInstantiationSniff.php | 2 +- .../Operators/ComparisonOperatorUsageSniff.php | 2 +- .../Operators/IncrementDecrementUsageSniff.php | 6 +++--- .../Sniffs/Operators/ValidLogicalOperatorsSniff.php | 2 +- .../Squiz/Sniffs/PHP/CommentedOutCodeSniff.php | 2 +- .../Sniffs/PHP/DisallowBooleanStatementSniff.php | 2 +- .../Sniffs/PHP/DisallowComparisonAssignmentSniff.php | 2 +- .../Squiz/Sniffs/PHP/DisallowInlineIfSniff.php | 2 +- .../Sniffs/PHP/DisallowMultipleAssignmentsSniff.php | 2 +- .../Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php | 10 +++++----- src/Standards/Squiz/Sniffs/PHP/EvalSniff.php | 2 +- .../Squiz/Sniffs/PHP/GlobalKeywordSniff.php | 2 +- src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php | 2 +- .../Squiz/Sniffs/PHP/InnerFunctionsSniff.php | 2 +- .../Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php | 2 +- .../Squiz/Sniffs/PHP/NonExecutableCodeSniff.php | 2 +- .../Squiz/Sniffs/Scope/MemberVarScopeSniff.php | 6 +++--- .../Squiz/Sniffs/Scope/MethodScopeSniff.php | 4 ++-- .../Squiz/Sniffs/Scope/StaticThisUsageSniff.php | 6 +++--- .../Sniffs/Strings/ConcatenationSpacingSniff.php | 2 +- .../Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php | 2 +- .../Squiz/Sniffs/Strings/EchoedStringsSniff.php | 2 +- .../Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php | 2 +- .../WhiteSpace/ControlStructureSpacingSniff.php | 2 +- .../WhiteSpace/FunctionClosingBraceSpaceSniff.php | 2 +- .../WhiteSpace/FunctionOpeningBraceSpaceSniff.php | 2 +- .../Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php | 2 +- .../WhiteSpace/LogicalOperatorSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/MemberVarSpacingSniff.php | 6 +++--- .../Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php | 6 +++--- .../Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php | 4 ++-- .../Sniffs/WhiteSpace/ScopeClosingBraceSniff.php | 2 +- .../Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/SemicolonSpacingSniff.php | 2 +- .../Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php | 2 +- 71 files changed, 108 insertions(+), 107 deletions(-) diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php index b6bb31de6b..b51160e080 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php index 33eb961502..cd684ff53a 100644 --- a/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php @@ -41,7 +41,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -161,7 +161,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd) + public function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd) { $tokens = $phpcsFile->getTokens(); @@ -335,7 +335,7 @@ public function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arra * * @return void */ - public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd) + public function processMultiLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd) { $tokens = $phpcsFile->getTokens(); $keywordStart = $tokens[$stackPtr]['column']; diff --git a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php index e3ae7af678..8a0e0b987c 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php @@ -26,7 +26,7 @@ class ClassDeclarationSniff extends PSR2ClassDeclarationSniff * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // We want all the errors from the PSR2 standard, plus some of our own. parent::process($phpcsFile, $stackPtr); @@ -51,7 +51,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - public function processOpen(File $phpcsFile, $stackPtr) + public function processOpen(File $phpcsFile, int $stackPtr) { parent::processOpen($phpcsFile, $stackPtr); @@ -96,7 +96,7 @@ public function processOpen(File $phpcsFile, $stackPtr) * * @return void */ - public function processClose(File $phpcsFile, $stackPtr) + public function processClose(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['scope_closer']) === false) { diff --git a/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php b/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php index abe6feecb9..a29568dbf7 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php @@ -42,7 +42,7 @@ public function register() * @return int|void Integer stack pointer to skip forward or void to continue * normal file processing. */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $fullPath = $phpcsFile->getFilename(); if ($fullPath === 'STDIN') { diff --git a/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php b/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php index e11c46b6e5..63ad4b93f2 100644 --- a/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php @@ -47,7 +47,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php index 1a4e508ca9..6c709e3ab5 100644 --- a/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php @@ -41,7 +41,7 @@ public function __construct() * * @return void */ - protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) { $tokens = $phpcsFile->getTokens(); @@ -165,7 +165,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop * * @return void */ - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { }//end processTokenOutsideScope() @@ -180,7 +180,7 @@ protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) * * @return string */ - protected function getNamespaceName(File $phpcsFile, $stackPtr) + protected function getNamespaceName(File $phpcsFile, int $stackPtr) { $namespace = '\\'; $namespaceDeclaration = $phpcsFile->findPrevious(T_NAMESPACE, $stackPtr); diff --git a/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php b/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php index 729a5c1f02..d626d27139 100644 --- a/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php +++ b/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php @@ -44,7 +44,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php index 8b3d1a1b3d..8c17a5ddd9 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php @@ -48,7 +48,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { if ($this->tabWidth === null) { if (isset($phpcsFile->config->tabWidth) === false || $phpcsFile->config->tabWidth === 0) { diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php index 60d553fc2e..48fba2de90 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php @@ -45,7 +45,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $find = [ diff --git a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php index a9fd5d39b8..0b542b5ad6 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php @@ -43,7 +43,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php index b4b1a50df1..5811dbe77d 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php index 301537fe72..434f759661 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php index 4a8e1aa286..f51dab0040 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php @@ -49,7 +49,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $commentStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index 143548802c..2f4fcc8aa4 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -42,7 +42,7 @@ class FunctionCommentSniff extends PEARFunctionCommentSniff * * @return void */ - protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) + protected function processReturn(File $phpcsFile, int $stackPtr, int $commentStart) { $tokens = $phpcsFile->getTokens(); $return = null; @@ -202,7 +202,7 @@ protected function processReturn(File $phpcsFile, $stackPtr, $commentStart) * * @return void */ - protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) + protected function processThrows(File $phpcsFile, int $stackPtr, int $commentStart) { $tokens = $phpcsFile->getTokens(); @@ -278,7 +278,7 @@ protected function processThrows(File $phpcsFile, $stackPtr, $commentStart) * * @return void */ - protected function processParams(File $phpcsFile, $stackPtr, $commentStart) + protected function processParams(File $phpcsFile, int $stackPtr, int $commentStart) { if ($this->phpVersion === null) { $this->phpVersion = Config::getConfigData('php_version'); @@ -653,7 +653,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart) * * @return void */ - protected function checkSpacingAfterParamType(File $phpcsFile, $param, $maxType, $spacing=1) + protected function checkSpacingAfterParamType(File $phpcsFile, array $param, int $maxType, int $spacing=1) { // Check number of spaces after the type. $spaces = ($maxType - strlen($param['type']) + $spacing); @@ -712,7 +712,7 @@ protected function checkSpacingAfterParamType(File $phpcsFile, $param, $maxType, * * @return void */ - protected function checkSpacingAfterParamName(File $phpcsFile, $param, $maxVar, $spacing=1) + protected function checkSpacingAfterParamName(File $phpcsFile, array $param, int $maxVar, int $spacing=1) { // Check number of spaces after the var name. $spaces = ($maxVar - strlen($param['var']) + $spacing); @@ -771,7 +771,7 @@ protected function checkSpacingAfterParamName(File $phpcsFile, $param, $maxVar, * * @return boolean TRUE if the docblock contains only {@inheritdoc} (case-insensitive). */ - protected function checkInheritdoc(File $phpcsFile, $stackPtr, $commentStart) + protected function checkInheritdoc(File $phpcsFile, int $stackPtr, int $commentStart) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php index b1a8427b19..10fb86200f 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php index a6c3e56a40..18a751fc69 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php @@ -52,7 +52,7 @@ public function register() * * @return void|int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php index 089829b4e5..9cdb4f4764 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php @@ -70,7 +70,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php index b107b255af..99adb01ad0 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php @@ -55,7 +55,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php index 8c8c868d3f..fa078adfb6 100644 --- a/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +++ b/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php @@ -38,7 +38,7 @@ public function __construct() * * @return void */ - public function processMemberVar(File $phpcsFile, $stackPtr) + public function processMemberVar(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -189,7 +189,7 @@ public function processMemberVar(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariable(File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, int $stackPtr) { }//end processVariable() @@ -206,7 +206,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariableInString(File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, int $stackPtr) { }//end processVariableInString() diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php index ec49134af9..47641ba415 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php @@ -58,7 +58,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php index 3cdb901d5e..0675d7ea89 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $error = 'Usage of ELSEIF not allowed; use ELSE IF instead'; $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotAllowed'); diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php index 498849209f..49328ca064 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php @@ -51,7 +51,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $this->requiredSpacesAfterOpen = (int) $this->requiredSpacesAfterOpen; $this->requiredSpacesBeforeClose = (int) $this->requiredSpacesBeforeClose; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php index 9355bf1107..82a328aff3 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php @@ -59,7 +59,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $this->requiredSpacesAfterOpen = (int) $this->requiredSpacesAfterOpen; $this->requiredSpacesBeforeClose = (int) $this->requiredSpacesBeforeClose; diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php index ff39c847fb..dea4c45591 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php index 068563c03c..1e3d4465c4 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php @@ -49,7 +49,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php index 8aad874b86..3432089e2a 100644 --- a/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php @@ -45,7 +45,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php b/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php index aceecffd36..15e12538ba 100644 --- a/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php +++ b/src/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php @@ -37,7 +37,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $fileName = $phpcsFile->getFilename(); diff --git a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php index c182cae6f4..53cad251c0 100644 --- a/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php +++ b/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -253,7 +253,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - public function addMissingBracketsError($phpcsFile, $stackPtr) + public function addMissingBracketsError(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php index 38e09813c6..6158518000 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php @@ -64,7 +64,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -101,7 +101,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - public function processBracket($phpcsFile, $openBracket) + public function processBracket(File $phpcsFile, int $openBracket) { $tokens = $phpcsFile->getTokens(); $closeBracket = $tokens[$openBracket]['parenthesis_closer']; diff --git a/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php b/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php index 5eafbfdbb5..31983996ac 100644 --- a/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php b/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php index 1c3db67c0d..075cfd9cca 100644 --- a/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php b/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php index c06be3beb2..c3e07a15c7 100644 --- a/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php @@ -43,7 +43,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php index 2b950c73c6..0c0afa9868 100644 --- a/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +++ b/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Functions; +use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions\FunctionDeclarationSniff as PEARFunctionDeclarationSniff; use PHP_CodeSniffer\Util\Tokens; @@ -29,7 +30,7 @@ class MultiLineFunctionDeclarationSniff extends PEARFunctionDeclarationSniff * * @return bool */ - public function isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tokens) + public function isMultiLineDeclaration(File $phpcsFile, int $stackPtr, int $openBracket, array $tokens) { $bracketsToCheck = [$stackPtr => $openBracket]; @@ -93,7 +94,7 @@ public function isMultiLineDeclaration($phpcsFile, $stackPtr, $openBracket, $tok * * @return void */ - public function processSingleLineDeclaration($phpcsFile, $stackPtr, $tokens) + public function processSingleLineDeclaration(File $phpcsFile, int $stackPtr, array $tokens) { // We do everything the parent sniff does, and a bit more because we // define multi-line declarations a bit differently. @@ -139,7 +140,7 @@ public function processSingleLineDeclaration($phpcsFile, $stackPtr, $tokens) * * @return void */ - public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) + public function processMultiLineDeclaration(File $phpcsFile, int $stackPtr, array $tokens) { // We do everything the parent sniff does, and a bit more. parent::processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens); @@ -174,7 +175,7 @@ public function processMultiLineDeclaration($phpcsFile, $stackPtr, $tokens) * * @return void */ - public function processBracket($phpcsFile, $openBracket, $tokens, $type='function') + public function processBracket(File $phpcsFile, int $openBracket, array $tokens, string $type='function') { $errorPrefix = ''; if ($type === 'use') { diff --git a/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php b/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php index 90ceaf2212..1661f81d69 100644 --- a/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php +++ b/src/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php @@ -26,7 +26,7 @@ class ValidFunctionNameSniff extends PEARValidFunctionNameSniff * * @return void */ - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { $functionName = $phpcsFile->getDeclarationName($stackPtr); if ($functionName === '') { diff --git a/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php index 835ef2533e..d20890092e 100644 --- a/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -28,7 +28,7 @@ class ValidVariableNameSniff extends AbstractVariableSniff * * @return void */ - protected function processVariable(File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $varName = ltrim($tokens[$stackPtr]['content'], '$'); @@ -113,7 +113,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) * * @return void */ - protected function processMemberVar(File $phpcsFile, $stackPtr) + protected function processMemberVar(File $phpcsFile, int $stackPtr) { try { $memberProps = $phpcsFile->getMemberProperties($stackPtr); @@ -163,7 +163,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariableInString(File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php b/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php index cc35558f7c..4593eafd63 100644 --- a/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php +++ b/src/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php index b70624a01d..1539f1f143 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php @@ -70,7 +70,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php index bb056a3503..77feb56bf6 100644 --- a/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php @@ -44,7 +44,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -66,7 +66,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - protected function processIncDec($phpcsFile, $stackPtr) + protected function processIncDec(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -116,7 +116,7 @@ protected function processIncDec($phpcsFile, $stackPtr) * * @return void */ - protected function processAssignment($phpcsFile, $stackPtr) + protected function processAssignment(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php b/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php index 720e4724ad..42e9285faa 100644 --- a/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php +++ b/src/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php index f8ce6242ff..f631e9e86b 100644 --- a/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php @@ -49,7 +49,7 @@ public function register() * @return int|void Integer stack pointer to skip forward or void to continue * normal file processing. */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php index f94000f8a7..72fb7ef49a 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) { diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php index 6bc151b626..6a6c964875 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php index 48bda2bb0a..4acad46dda 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $phpcsFile->addError('Inline IF statements are not allowed', $stackPtr, 'Found'); diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php index 4542bde1c9..fdeea37e83 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php index 8bcabaad04..464989bb9d 100644 --- a/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php @@ -60,7 +60,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $openBracket = $tokens[$stackPtr]['parenthesis_opener']; diff --git a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php index 9c327cca45..1781afdfc3 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php @@ -41,7 +41,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -68,7 +68,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return void */ - private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag) + private function validateMultilineEmbeddedPhp(File $phpcsFile, int $stackPtr, $closingTag) { $tokens = $phpcsFile->getTokens(); @@ -335,7 +335,7 @@ private function validateMultilineEmbeddedPhp($phpcsFile, $stackPtr, $closingTag * * @return void */ - private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag) + private function validateInlineEmbeddedPhp(File $phpcsFile, int $stackPtr, int $closeTag) { $tokens = $phpcsFile->getTokens(); @@ -442,7 +442,7 @@ private function validateInlineEmbeddedPhp($phpcsFile, $stackPtr, $closeTag) * * @return void */ - private function reportEmptyTagSet(File $phpcsFile, $stackPtr, $closeTag) + private function reportEmptyTagSet(File $phpcsFile, int $stackPtr, int $closeTag) { $tokens = $phpcsFile->getTokens(); $error = 'Empty embedded PHP tag found'; @@ -479,7 +479,7 @@ private function reportEmptyTagSet(File $phpcsFile, $stackPtr, $closeTag) * * @return int */ - private function calculateLineIndent(File $phpcsFile, $stackPtr) + private function calculateLineIndent(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php b/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php index 102bd7c3fa..75ce26a17c 100644 --- a/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/EvalSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $error = 'Use of eval() is discouraged'; $phpcsFile->addWarning($error, $stackPtr, 'Discouraged'); diff --git a/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php b/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php index fec3ec8217..c092669df4 100644 --- a/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php @@ -37,7 +37,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php b/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php index b3ab816d0c..4a1165a8f0 100644 --- a/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/HeredocSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php index c60d43c394..5f25a7d981 100644 --- a/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php index d2bc2c706a..5b8c4eafc6 100644 --- a/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php @@ -60,7 +60,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php index cb2a55c95b..238ea560c0 100644 --- a/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php +++ b/src/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php @@ -61,7 +61,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php b/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php index 0aa018e48d..cf8adecc2e 100644 --- a/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php +++ b/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php @@ -37,7 +37,7 @@ public function __construct() * * @return void */ - protected function processMemberVar(File $phpcsFile, $stackPtr) + protected function processMemberVar(File $phpcsFile, int $stackPtr) { try { $properties = $phpcsFile->getMemberProperties($stackPtr); @@ -72,7 +72,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariable(File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, int $stackPtr) { /* We don't care about normal variables. @@ -89,7 +89,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariableInString(File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, int $stackPtr) { /* We don't care about normal variables. diff --git a/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php b/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php index 62f6327c07..3527cfeab4 100644 --- a/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php +++ b/src/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php @@ -36,7 +36,7 @@ public function __construct() * * @return void */ - protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) + protected function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) { $tokens = $phpcsFile->getTokens(); @@ -74,7 +74,7 @@ protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScop * * @return void */ - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { }//end processTokenOutsideScope() diff --git a/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php b/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php index 28be44d744..ad755903bd 100644 --- a/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php @@ -37,7 +37,7 @@ public function __construct() * * @return void */ - public function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) + public function processTokenWithinScope(File $phpcsFile, int $stackPtr, int $currScope) { $tokens = $phpcsFile->getTokens(); @@ -82,7 +82,7 @@ public function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope) * * @return void */ - private function checkThisUsage(File $phpcsFile, $next, $end) + private function checkThisUsage(File $phpcsFile, int $next, int $end) { $tokens = $phpcsFile->getTokens(); @@ -119,7 +119,7 @@ private function checkThisUsage(File $phpcsFile, $next, $end) * * @return void */ - protected function processTokenOutsideScope(File $phpcsFile, $stackPtr) + protected function processTokenOutsideScope(File $phpcsFile, int $stackPtr) { }//end processTokenOutsideScope() diff --git a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php index af42919f09..3f2dcd4f6d 100644 --- a/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php @@ -52,7 +52,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if (isset($tokens[($stackPtr + 2)]) === false) { diff --git a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php index 22519449da..786f5b89a2 100644 --- a/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php @@ -66,7 +66,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php b/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php index be3c05d0c1..4093ec84dc 100644 --- a/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php +++ b/src/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php index 2d67c4b757..b8d7706ae2 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php index 7171c3f283..1eaf278f27 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php @@ -51,7 +51,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php index 9cfdeb910c..4cca5e03c2 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php index 55bd99de40..cd7a1a9e53 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php @@ -40,7 +40,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php index 9e277189f2..4b2c34b61b 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php @@ -66,7 +66,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $previousNonEmpty = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($stackPtr - 1), null, true); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php index ce674aaf09..d193456e02 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php index 9e6b8f1f43..6aebe71a73 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php @@ -52,7 +52,7 @@ public function __construct() * called again on the current file until the returned stack * pointer is reached. */ - protected function processMemberVar(File $phpcsFile, $stackPtr) + protected function processMemberVar(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -240,7 +240,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariable(File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, int $stackPtr) { /* We don't care about normal variables. @@ -257,7 +257,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariableInString(File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, int $stackPtr) { /* We don't care about normal variables. diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php index 1c27be7a3d..ce80cae8ce 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php @@ -48,7 +48,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) { @@ -97,7 +97,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return boolean true if there was no error, false otherwise. */ - protected function checkSpacingBeforeOperator(File $phpcsFile, $stackPtr, $before) + protected function checkSpacingBeforeOperator(File $phpcsFile, int $stackPtr, $before) { if ($before !== 0 && ($before !== 'newline' || $this->ignoreNewlines === false) @@ -136,7 +136,7 @@ protected function checkSpacingBeforeOperator(File $phpcsFile, $stackPtr, $befor * * @return boolean true if there was no error, false otherwise. */ - protected function checkSpacingAfterOperator(File $phpcsFile, $stackPtr, $after) + protected function checkSpacingAfterOperator(File $phpcsFile, int $stackPtr, $after) { if ($after !== 0 && ($after !== 'newline' || $this->ignoreNewlines === false) diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php index c66d8b14b0..8abe1b98f0 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php @@ -124,7 +124,7 @@ public function register() * pointer is reached. Return `$phpcsFile->numTokens` to skip * the rest of the file. */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -339,7 +339,7 @@ public function process(File $phpcsFile, $stackPtr) * * @return boolean */ - protected function isOperator(File $phpcsFile, $stackPtr) + protected function isOperator(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php index acdb9be205..20949d807d 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php index 9dbf59b606..f1425771b9 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php @@ -41,7 +41,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php index f871a99256..6092327e62 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php @@ -38,7 +38,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php index 1bdfa5fcb9..5cfcc680ad 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php @@ -58,7 +58,7 @@ public function register() * * @return void */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); From fb23527a2dd2e298fc2cd50703407142c722696e Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 22:02:33 +0200 Subject: [PATCH 13/15] 4.0 | Standards/Zend: add parameter types to sniffs --- src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php | 2 +- .../Sniffs/NamingConventions/ValidVariableNameSniff.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php index ed68eb8dc0..3b2efebb01 100644 --- a/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php +++ b/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php @@ -38,7 +38,7 @@ public function register() * * @return int */ - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Find the last non-empty token. $tokens = $phpcsFile->getTokens(); diff --git a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php index 843e3255d8..2bd4d40eec 100644 --- a/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php +++ b/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php @@ -28,7 +28,7 @@ class ValidVariableNameSniff extends AbstractVariableSniff * * @return void */ - protected function processVariable(File $phpcsFile, $stackPtr) + protected function processVariable(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $varName = ltrim($tokens[$stackPtr]['content'], '$'); @@ -113,7 +113,7 @@ protected function processVariable(File $phpcsFile, $stackPtr) * * @return void */ - protected function processMemberVar(File $phpcsFile, $stackPtr) + protected function processMemberVar(File $phpcsFile, int $stackPtr) { try { $memberProps = $phpcsFile->getMemberProperties($stackPtr); @@ -169,7 +169,7 @@ protected function processMemberVar(File $phpcsFile, $stackPtr) * * @return void */ - protected function processVariableInString(File $phpcsFile, $stackPtr) + protected function processVariableInString(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); From f186984c2851b62b1e91076badd89e156f25ac95 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 22:05:31 +0200 Subject: [PATCH 14/15] 4.0 | Tests: add parameter types to sniffs used as test fixtures --- .../TestStandard/Sniffs/FixFileReturnValue/AllGoodSniff.php | 2 +- .../TestStandard/Sniffs/FixFileReturnValue/ConflictSniff.php | 2 +- .../Sniffs/FixFileReturnValue/NotEnoughLoopsSniff.php | 2 +- .../Fixtures/StandardWithDocs/Sniffs/DummySniff.php | 2 +- .../BrokenNamingConventions/Sniffs/Category/Sniff.php | 2 +- .../Sniffs/Category/SubDir/TooDeeplyNestedSniff.php | 2 +- .../Sniffs/MissingCategoryDirSniff.php | 2 +- .../BrokenNamingConventions/Sniffs/NoNamespaceSniff.php | 2 +- .../BrokenNamingConventions/Sniffs/PartialNamespaceSniff.php | 2 +- .../Sniffs/Sniffs/CategoryCalledSniffsSniff.php | 2 +- .../.hiddenAbove/src/MyStandard/DummySniff.php | 2 +- .../Fixtures/ExternalA/Sniffs/CheckSomething/ValidSniff.php | 2 +- .../Fixtures/ExternalB/Sniffs/CheckMore/ValidSniff.php | 2 +- .../src/MyStandard/Sniffs/Category/ValidSniff.php | 2 +- .../Ruleset/Fixtures/Internal/Sniffs/Valid/ValidSniff.php | 2 +- .../Sniffs/Deprecated/WithLongReplacementSniff.php | 2 +- .../WithReplacementContainingLinuxNewlinesSniff.php | 2 +- .../Deprecated/WithReplacementContainingNewlinesSniff.php | 2 +- .../TestStandard/Sniffs/Deprecated/WithReplacementSniff.php | 2 +- .../Sniffs/Deprecated/WithoutReplacementSniff.php | 2 +- .../DeprecatedInvalid/EmptyDeprecationVersionSniff.php | 2 +- .../Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php | 2 +- .../DeprecatedInvalid/InvalidDeprecationMessageSniff.php | 2 +- .../DeprecatedInvalid/InvalidDeprecationVersionSniff.php | 2 +- .../Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php | 2 +- .../Sniffs/InvalidSniffs/RegisterNoArraySniff.php | 2 +- .../InvalidImplementsWithoutImplementSniff.php | 2 +- .../Sniffs/MissingInterface/ValidImplementsSniff.php | 2 +- .../MissingInterface/ValidImplementsViaAbstractSniff.php | 5 +++-- .../Sniffs/SetProperty/AllowedAsDeclaredSniff.php | 2 +- .../Sniffs/SetProperty/AllowedViaMagicMethodSniff.php | 2 +- .../Sniffs/SetProperty/AllowedViaStdClassSniff.php | 2 +- .../Sniffs/SetProperty/NotAllowedViaAttributeSniff.php | 2 +- .../SetProperty/PropertyTypeHandlingOldArrayFormatSniff.php | 2 +- .../Sniffs/SetProperty/PropertyTypeHandlingSniff.php | 2 +- .../ImplementsDeprecatedInterfaceSniff.php | 2 +- .../Sniffs/SupportedTokenizers/ListensForCSSAndJSSniff.php | 2 +- .../ListensForCSSAndUnrecognizedSniff.php | 2 +- .../Sniffs/SupportedTokenizers/ListensForCSSSniff.php | 2 +- .../Sniffs/SupportedTokenizers/ListensForEmptySniff.php | 2 +- .../Sniffs/SupportedTokenizers/ListensForJSSniff.php | 2 +- .../SupportedTokenizers/ListensForPHPAndCSSAndJSSniff.php | 2 +- .../ListensForUnrecognizedTokenizersSniff.php | 2 +- .../Sniffs/ValidSniffs/RegisterEmptyArraySniff.php | 2 +- .../Fixtures/TestStandard/Sniffs/ExitCodes/ErrorSniff.php | 2 +- .../TestStandard/Sniffs/ExitCodes/FailToFixSniff.php | 2 +- .../TestStandard/Sniffs/ExitCodes/FixableErrorSniff.php | 2 +- .../TestStandard/Sniffs/ExitCodes/FixableWarningSniff.php | 2 +- .../Fixtures/TestStandard/Sniffs/ExitCodes/NoIssuesSniff.php | 2 +- .../Fixtures/TestStandard/Sniffs/ExitCodes/WarningSniff.php | 2 +- 50 files changed, 52 insertions(+), 51 deletions(-) diff --git a/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/AllGoodSniff.php b/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/AllGoodSniff.php index 20dbe2fe22..3b3b898260 100644 --- a/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/AllGoodSniff.php +++ b/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/AllGoodSniff.php @@ -18,7 +18,7 @@ public function register() return [T_ECHO]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/ConflictSniff.php b/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/ConflictSniff.php index ca7afb9159..75946a1ec5 100644 --- a/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/ConflictSniff.php +++ b/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/ConflictSniff.php @@ -40,7 +40,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/NotEnoughLoopsSniff.php b/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/NotEnoughLoopsSniff.php index e42d3fd7ed..ce3e506a10 100644 --- a/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/NotEnoughLoopsSniff.php +++ b/tests/Core/Fixer/Fixtures/TestStandard/Sniffs/FixFileReturnValue/NotEnoughLoopsSniff.php @@ -20,7 +20,7 @@ public function register() return [T_ECHO]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/DummySniff.php b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/DummySniff.php index 1a2546b111..d7d9e0c4c2 100644 --- a/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/DummySniff.php +++ b/tests/Core/Generators/Fixtures/StandardWithDocs/Sniffs/DummySniff.php @@ -18,7 +18,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Category/Sniff.php b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Category/Sniff.php index 9da190d175..50ae76c61d 100644 --- a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Category/Sniff.php +++ b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Category/Sniff.php @@ -17,7 +17,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Category/SubDir/TooDeeplyNestedSniff.php b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Category/SubDir/TooDeeplyNestedSniff.php index abba3557ca..19e2092eea 100644 --- a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Category/SubDir/TooDeeplyNestedSniff.php +++ b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Category/SubDir/TooDeeplyNestedSniff.php @@ -17,7 +17,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/MissingCategoryDirSniff.php b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/MissingCategoryDirSniff.php index 57fee19ac9..f4eae2129e 100644 --- a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/MissingCategoryDirSniff.php +++ b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/MissingCategoryDirSniff.php @@ -17,7 +17,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/NoNamespaceSniff.php b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/NoNamespaceSniff.php index 85dc940fe2..257ab62f30 100644 --- a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/NoNamespaceSniff.php +++ b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/NoNamespaceSniff.php @@ -15,7 +15,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/PartialNamespaceSniff.php b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/PartialNamespaceSniff.php index 77bb14693f..cb7d555263 100644 --- a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/PartialNamespaceSniff.php +++ b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/PartialNamespaceSniff.php @@ -17,7 +17,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Sniffs/CategoryCalledSniffsSniff.php b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Sniffs/CategoryCalledSniffsSniff.php index 7312e80e8e..bb33e70da4 100644 --- a/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Sniffs/CategoryCalledSniffsSniff.php +++ b/tests/Core/Ruleset/Fixtures/BrokenNamingConventions/Sniffs/Sniffs/CategoryCalledSniffsSniff.php @@ -17,7 +17,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/DummySniff.php b/tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/DummySniff.php index 64d0f1c911..a1a5d18ef6 100644 --- a/tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/DummySniff.php +++ b/tests/Core/Ruleset/Fixtures/DirectoryExpansion/.hiddenAbove/src/MyStandard/DummySniff.php @@ -18,7 +18,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/ExternalA/Sniffs/CheckSomething/ValidSniff.php b/tests/Core/Ruleset/Fixtures/ExternalA/Sniffs/CheckSomething/ValidSniff.php index 51061e3b5e..32b08609c6 100644 --- a/tests/Core/Ruleset/Fixtures/ExternalA/Sniffs/CheckSomething/ValidSniff.php +++ b/tests/Core/Ruleset/Fixtures/ExternalA/Sniffs/CheckSomething/ValidSniff.php @@ -18,7 +18,7 @@ public function register() return [T_CLASS]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/ExternalB/Sniffs/CheckMore/ValidSniff.php b/tests/Core/Ruleset/Fixtures/ExternalB/Sniffs/CheckMore/ValidSniff.php index 1584f70504..5b7e350a7b 100644 --- a/tests/Core/Ruleset/Fixtures/ExternalB/Sniffs/CheckMore/ValidSniff.php +++ b/tests/Core/Ruleset/Fixtures/ExternalB/Sniffs/CheckMore/ValidSniff.php @@ -18,7 +18,7 @@ public function register() return [T_CLASS]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/FakeHomePath/src/MyStandard/Sniffs/Category/ValidSniff.php b/tests/Core/Ruleset/Fixtures/FakeHomePath/src/MyStandard/Sniffs/Category/ValidSniff.php index 9346df9eb1..ee376e4bfc 100644 --- a/tests/Core/Ruleset/Fixtures/FakeHomePath/src/MyStandard/Sniffs/Category/ValidSniff.php +++ b/tests/Core/Ruleset/Fixtures/FakeHomePath/src/MyStandard/Sniffs/Category/ValidSniff.php @@ -18,7 +18,7 @@ public function register() return [T_CLASS]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/Internal/Sniffs/Valid/ValidSniff.php b/tests/Core/Ruleset/Fixtures/Internal/Sniffs/Valid/ValidSniff.php index e7a04f495a..3d144d1ca1 100644 --- a/tests/Core/Ruleset/Fixtures/Internal/Sniffs/Valid/ValidSniff.php +++ b/tests/Core/Ruleset/Fixtures/Internal/Sniffs/Valid/ValidSniff.php @@ -18,7 +18,7 @@ public function register() return [T_CLASS]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithLongReplacementSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithLongReplacementSniff.php index 659d89ee2a..2d007a6272 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithLongReplacementSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithLongReplacementSniff.php @@ -34,7 +34,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php index d870cbf7e4..c8c9c0507d 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingLinuxNewlinesSniff.php @@ -38,7 +38,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php index 2516d7cd2e..2c3bece7df 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementContainingNewlinesSniff.php @@ -38,7 +38,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementSniff.php index 1953448672..271701b061 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithReplacementSniff.php @@ -34,7 +34,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithoutReplacementSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithoutReplacementSniff.php index 888e08fd13..0a1d61d0f8 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithoutReplacementSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/Deprecated/WithoutReplacementSniff.php @@ -34,7 +34,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php index 4e26b7b761..5efa6d0f19 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyDeprecationVersionSniff.php @@ -34,7 +34,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php index cdf15c3031..a4e4d3260c 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/EmptyRemovalVersionSniff.php @@ -34,7 +34,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php index 368bd4140b..1cfef9fcf3 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationMessageSniff.php @@ -35,7 +35,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php index b8218ad57e..13d0a88649 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidDeprecationVersionSniff.php @@ -34,7 +34,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php index 1177e73338..a687e2c5a8 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/DeprecatedInvalid/InvalidRemovalVersionSniff.php @@ -34,7 +34,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffs/RegisterNoArraySniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffs/RegisterNoArraySniff.php index a77ac24fa5..04608613fd 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffs/RegisterNoArraySniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/InvalidSniffs/RegisterNoArraySniff.php @@ -18,7 +18,7 @@ public function register() return false; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/InvalidImplementsWithoutImplementSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/InvalidImplementsWithoutImplementSniff.php index 39e61e385a..349f7d99e0 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/InvalidImplementsWithoutImplementSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/InvalidImplementsWithoutImplementSniff.php @@ -17,7 +17,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/ValidImplementsSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/ValidImplementsSniff.php index 33e2ef7a2e..a2a7f5c087 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/ValidImplementsSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/ValidImplementsSniff.php @@ -18,7 +18,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/ValidImplementsViaAbstractSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/ValidImplementsViaAbstractSniff.php index ec23300247..e194d1a7d3 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/ValidImplementsViaAbstractSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/MissingInterface/ValidImplementsViaAbstractSniff.php @@ -7,17 +7,18 @@ namespace Fixtures\TestStandard\Sniffs\MissingInterface; +use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\AbstractArraySniff; final class ValidImplementsViaAbstractSniff extends AbstractArraySniff { - protected function processSingleLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices) + protected function processSingleLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices) { // Do something. } - protected function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $arrayEnd, $indices) + protected function processMultiLineArray(File $phpcsFile, int $stackPtr, int $arrayStart, int $arrayEnd, array $indices) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedAsDeclaredSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedAsDeclaredSniff.php index a8f0364c54..49dc48ce85 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedAsDeclaredSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedAsDeclaredSniff.php @@ -21,7 +21,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php index 98eb22c573..b6cedba4c8 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaMagicMethodSniff.php @@ -33,7 +33,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaStdClassSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaStdClassSniff.php index 0f58b2e001..cc1a27921e 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaStdClassSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/AllowedViaStdClassSniff.php @@ -19,7 +19,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php index bb52355827..2a2b3e54f8 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/NotAllowedViaAttributeSniff.php @@ -20,7 +20,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingOldArrayFormatSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingOldArrayFormatSniff.php index fff048d1e1..879f594bce 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingOldArrayFormatSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingOldArrayFormatSniff.php @@ -53,7 +53,7 @@ public function register() return [T_ECHO]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingSniff.php index 63d88a64e5..bec9113a98 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SetProperty/PropertyTypeHandlingSniff.php @@ -272,7 +272,7 @@ public function register() return [T_ECHO]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ImplementsDeprecatedInterfaceSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ImplementsDeprecatedInterfaceSniff.php index 6a12eda8d1..4876653cae 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ImplementsDeprecatedInterfaceSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ImplementsDeprecatedInterfaceSniff.php @@ -39,7 +39,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndJSSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndJSSniff.php index 37d754f0bd..db4103ef25 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndJSSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndJSSniff.php @@ -23,7 +23,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndUnrecognizedSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndUnrecognizedSniff.php index a2560ad103..b87df5a03f 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndUnrecognizedSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSAndUnrecognizedSniff.php @@ -23,7 +23,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSSniff.php index 98e30a3f07..d22a45c80c 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForCSSSniff.php @@ -20,7 +20,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForEmptySniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForEmptySniff.php index 244a6e0979..8453e8f021 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForEmptySniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForEmptySniff.php @@ -20,7 +20,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForJSSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForJSSniff.php index e675498d1d..9338ffdb08 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForJSSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForJSSniff.php @@ -20,7 +20,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForPHPAndCSSAndJSSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForPHPAndCSSAndJSSniff.php index 3e04961414..29e93d3fa3 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForPHPAndCSSAndJSSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForPHPAndCSSAndJSSniff.php @@ -27,7 +27,7 @@ public function register() ]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForUnrecognizedTokenizersSniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForUnrecognizedTokenizersSniff.php index 5958156034..f465fd8251 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForUnrecognizedTokenizersSniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/SupportedTokenizers/ListensForUnrecognizedTokenizersSniff.php @@ -23,7 +23,7 @@ public function register() return [T_WHITESPACE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/ValidSniffs/RegisterEmptyArraySniff.php b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/ValidSniffs/RegisterEmptyArraySniff.php index 2d58e95275..ff63667bb3 100644 --- a/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/ValidSniffs/RegisterEmptyArraySniff.php +++ b/tests/Core/Ruleset/Fixtures/TestStandard/Sniffs/ValidSniffs/RegisterEmptyArraySniff.php @@ -18,7 +18,7 @@ public function register() return []; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do something. } diff --git a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/ErrorSniff.php b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/ErrorSniff.php index 3f92483588..86d0ae0cf4 100644 --- a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/ErrorSniff.php +++ b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/ErrorSniff.php @@ -18,7 +18,7 @@ public function register() return [T_VARIABLE]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if ($tokens[$stackPtr]['content'] === '$var') { diff --git a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FailToFixSniff.php b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FailToFixSniff.php index 7c3ee78134..1b129b97e9 100644 --- a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FailToFixSniff.php +++ b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FailToFixSniff.php @@ -18,7 +18,7 @@ public function register() return [T_ECHO]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); diff --git a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FixableErrorSniff.php b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FixableErrorSniff.php index f3d4ef20b9..e132097049 100644 --- a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FixableErrorSniff.php +++ b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FixableErrorSniff.php @@ -18,7 +18,7 @@ public function register() return [T_OPEN_TAG]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); $contents = $tokens[$stackPtr]['content']; diff --git a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FixableWarningSniff.php b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FixableWarningSniff.php index 21522302ad..5374dba560 100644 --- a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FixableWarningSniff.php +++ b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/FixableWarningSniff.php @@ -18,7 +18,7 @@ public function register() return [T_SEMICOLON]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $tokens = $phpcsFile->getTokens(); if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) { diff --git a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/NoIssuesSniff.php b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/NoIssuesSniff.php index 5f03652652..aa3ffcab0b 100644 --- a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/NoIssuesSniff.php +++ b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/NoIssuesSniff.php @@ -18,7 +18,7 @@ public function register() return [T_ECHO]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { // Do nothing. } diff --git a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/WarningSniff.php b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/WarningSniff.php index 683f7dd3ea..d6ca183e41 100644 --- a/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/WarningSniff.php +++ b/tests/Core/Util/ExitCode/Fixtures/TestStandard/Sniffs/ExitCodes/WarningSniff.php @@ -18,7 +18,7 @@ public function register() return [T_COMMENT]; } - public function process(File $phpcsFile, $stackPtr) + public function process(File $phpcsFile, int $stackPtr) { $phpcsFile->addWarning('Commments are not allowed', $stackPtr, 'Found'); } From a44f026657b249c583fe9beafdf9bcd6d6ea4f26 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2025 21:56:03 +0200 Subject: [PATCH 15/15] 4.0 | AbstractSniffTestCase: add parameter types Includes updating the sniff test classes overloading these methods. --- .../Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php | 2 +- .../Generic/Tests/Commenting/DocCommentUnitTest.php | 3 ++- src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php | 3 ++- src/Standards/Generic/Tests/Files/LineLengthUnitTest.php | 3 ++- .../Generic/Tests/Files/LowercasedFilenameUnitTest.php | 2 +- .../OpeningFunctionBraceKernighanRitchieUnitTest.php | 3 ++- .../Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php | 2 +- .../Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php | 3 ++- .../Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php | 3 ++- .../Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php | 3 ++- .../PEAR/Tests/Classes/ClassDeclarationUnitTest.php | 3 ++- .../PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php | 3 ++- src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php | 3 ++- .../Squiz/Tests/Classes/ClassFileNameUnitTest.php | 2 +- .../Squiz/Tests/Commenting/BlockCommentUnitTest.php | 3 ++- tests/Standards/AbstractSniffTestCase.php | 7 ++++--- 16 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php index e68d8aa7b7..857fe3502a 100644 --- a/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php +++ b/src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.php @@ -27,7 +27,7 @@ final class EmptyPHPStatementUnitTest extends AbstractSniffTestCase * * @return string[] */ - protected function getTestFiles($testFileBase) + protected function getTestFiles(string $testFileBase) { $testFiles = [$testFileBase.'1.inc']; diff --git a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php index d4b1724b89..60c75d5106 100644 --- a/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +++ b/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Tests\Commenting; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class DocCommentUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { $config->tabWidth = 4; diff --git a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php index 748601ffd0..8f65ea193f 100644 --- a/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineEndingsUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class LineEndingsUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { $config->tabWidth = 4; diff --git a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php index 18b3f83c26..164ae90a12 100644 --- a/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LineLengthUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Tests\Files; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class LineLengthUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { $config->tabWidth = 4; diff --git a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php index b36b5d6424..2a3e61fdf5 100644 --- a/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php +++ b/src/Standards/Generic/Tests/Files/LowercasedFilenameUnitTest.php @@ -30,7 +30,7 @@ final class LowercasedFilenameUnitTest extends AbstractSniffTestCase * * @return string[] */ - protected function getTestFiles($testFileBase) + protected function getTestFiles(string $testFileBase) { $testFileDir = dirname($testFileBase); $testFiles = parent::getTestFiles($testFileBase); diff --git a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php index 14f99fae14..8824883b2d 100644 --- a/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +++ b/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Tests\Functions; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class OpeningFunctionBraceKernighanRitchieUnitTest extends AbstractSniffTe * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { if ($testFile === 'OpeningFunctionBraceKernighanRitchieUnitTest.2.inc') { $config->tabWidth = 4; diff --git a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php index 46a6d7ee98..ddfd82d26f 100644 --- a/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php +++ b/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php @@ -27,7 +27,7 @@ final class DisallowShortOpenTagUnitTest extends AbstractSniffTestCase * * @return string[] */ - protected function getTestFiles($testFileBase) + protected function getTestFiles(string $testFileBase) { $testFiles = [$testFileBase.'1.inc']; diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php index 267cfe1a90..581fe82574 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class DisallowSpaceIndentUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { if ($testFile === 'DisallowSpaceIndentUnitTest.2.inc') { return; diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php index c3d1747f24..32043c606b 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class DisallowTabIndentUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { $config->tabWidth = 4; diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index b20093b486..f454c66060 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class ScopeIndentUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { $config->setConfigData('scope_indent_debug', '0', true); diff --git a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php index d80254150f..30105bcf9a 100644 --- a/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php +++ b/src/Standards/PEAR/Tests/Classes/ClassDeclarationUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\PEAR\Tests\Classes; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class ClassDeclarationUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { if ($testFile === 'ClassDeclarationUnitTest.1.inc') { return; diff --git a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php index ca9a016b20..1a5a326950 100644 --- a/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\PEAR\Tests\WhiteSpace; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class ScopeIndentUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { $config->setConfigData('scope_indent_debug', '0', true); diff --git a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php index 90f27b107a..0fb4887baa 100644 --- a/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php +++ b/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\PSR1\Tests\Files; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class SideEffectsUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { if ($testFile === 'SideEffectsUnitTest.12.inc') { $config->annotations = false; diff --git a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php index 056a71b364..15e63206ff 100644 --- a/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php +++ b/src/Standards/Squiz/Tests/Classes/ClassFileNameUnitTest.php @@ -31,7 +31,7 @@ final class ClassFileNameUnitTest extends AbstractSniffTestCase * * @return string[] */ - protected function getTestFiles($testFileBase) + protected function getTestFiles(string $testFileBase) { $testFiles = []; diff --git a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php index 16c9edb5cd..726086ec9b 100644 --- a/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php +++ b/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php @@ -9,6 +9,7 @@ namespace PHP_CodeSniffer\Standards\Squiz\Tests\Commenting; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Tests\Standards\AbstractSniffTestCase; /** @@ -28,7 +29,7 @@ final class BlockCommentUnitTest extends AbstractSniffTestCase * * @return void */ - public function setCliValues($testFile, $config) + public function setCliValues(string $testFile, Config $config) { $config->tabWidth = 4; diff --git a/tests/Standards/AbstractSniffTestCase.php b/tests/Standards/AbstractSniffTestCase.php index 872b09c114..bea529835f 100644 --- a/tests/Standards/AbstractSniffTestCase.php +++ b/tests/Standards/AbstractSniffTestCase.php @@ -14,6 +14,7 @@ namespace PHP_CodeSniffer\Tests\Standards; use DirectoryIterator; +use PHP_CodeSniffer\Config; use PHP_CodeSniffer\Exceptions\RuntimeException; use PHP_CodeSniffer\Files\LocalFile; use PHP_CodeSniffer\Ruleset; @@ -99,7 +100,7 @@ public static function tearDownAfterClass(): void * * @return string[] */ - protected function getTestFiles($testFileBase) + protected function getTestFiles(string $testFileBase) { $testFiles = []; @@ -440,12 +441,12 @@ public function generateFailureMessages(LocalFile $file) /** * Get a list of CLI values to set before the file is tested. * - * @param string $filename The name of the file being tested. + * @param string $testFile The name of the file being tested. * @param \PHP_CodeSniffer\Config $config The config data for the run. * * @return void */ - public function setCliValues($filename, $config) + public function setCliValues(string $testFile, Config $config) { }//end setCliValues()