From 30b8571bcf1f0f2acd752b7dedf76c24dc681b26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Wed, 19 Jul 2023 21:12:28 +0000 Subject: [PATCH 01/15] Fix typos --- Modernize/ruleset.xml | 2 +- .../Docs/CodeAnalysis/StaticInFinalClassStandard.xml | 4 ++-- .../Tests/CodeAnalysis/StaticInFinalClassUnitTest.inc | 8 ++++---- .../CodeAnalysis/StaticInFinalClassUnitTest.inc.fixed | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Modernize/ruleset.xml b/Modernize/ruleset.xml index bbfc2ea8..57e341ba 100644 --- a/Modernize/ruleset.xml +++ b/Modernize/ruleset.xml @@ -1,5 +1,5 @@ - A collection of sniffs to detect code modernization opportunties. + A collection of sniffs to detect code modernization opportunities. diff --git a/Universal/Docs/CodeAnalysis/StaticInFinalClassStandard.xml b/Universal/Docs/CodeAnalysis/StaticInFinalClassStandard.xml index 8c5f3bd8..5f9f45bd 100644 --- a/Universal/Docs/CodeAnalysis/StaticInFinalClassStandard.xml +++ b/Universal/Docs/CodeAnalysis/StaticInFinalClassStandard.xml @@ -14,7 +14,7 @@ ]]> - + - + Date: Thu, 20 Jul 2023 14:19:43 +0200 Subject: [PATCH 02/15] README: fix order of the sniff list ... which wasn't completely alphabetic anymore. --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 51c90888..c5af005d 100644 --- a/README.md +++ b/README.md @@ -220,16 +220,16 @@ Require a consistent modifier keyword order for class declarations. If a [`php_version` configuration option][php_version-config] has been passed to PHPCS using either `--config-set` or `--runtime-set`, it will be respected by the sniff. In effect, this means that the sniff will only report on PHP4-style constructors if the configured PHP version is less than 8.0. -#### `Universal.CodeAnalysis.NoEchoSprintf` :wrench: :books: - -Detects use of the inefficient `echo [v]sprintf(...);` combi. Use `[v]printf()` instead. - #### `Universal.CodeAnalysis.ForeachUniqueAssignment` :wrench: :books: Detects `foreach` control structures which use the same variable for both the key as well as the value assignment as this will lead to unexpected - and most likely unintended - behaviour. Note: The fixer will maintain the existing behaviour of the code. This may not be the _intended_ behaviour. +#### `Universal.CodeAnalysis.NoEchoSprintf` :wrench: :books: + +Detects use of the inefficient `echo [v]sprintf(...);` combi. Use `[v]printf()` instead. + #### `Universal.CodeAnalysis.StaticInFinalClass` :wrench: :books: Detects using `static` instead of `self` in OO constructs which are `final`. @@ -419,12 +419,6 @@ Forbid using import `use` statements for functions. See [`Universal.UseStatements.DisallowUseClass`](#universalusestatementsdisallowuseclass-bar_chart-books) for information on the error codes. -#### `Universal.UseStatements.LowercaseFunctionConst` :wrench: :bar_chart: :books: - -Enforce that `function` and `const` keywords when used in an import `use` statement are always lowercase. - -Companion sniff to the PHPCS native `Generic.PHP.LowerCaseKeyword` sniff which doesn't cover these keywords when used in an import `use` statement. - #### `Universal.UseStatements.KeywordSpacing` :wrench: :bar_chart: :books: Enforce the use of a single space after the `use`, `function`, `const` keywords and both before and after the `as` keyword in import `use` statements. @@ -433,6 +427,12 @@ Companion sniff to the PHPCS native `Generic.WhiteSpace.LanguageConstructSpacing The sniff has modular error codes to allow for disabling individual checks. The error codes are: `SpaceAfterUse`, `SpaceAfterFunction`, `SpaceAfterConst`, `SpaceBeforeAs` and `SpaceAfterAs`. +#### `Universal.UseStatements.LowercaseFunctionConst` :wrench: :bar_chart: :books: + +Enforce that `function` and `const` keywords when used in an import `use` statement are always lowercase. + +Companion sniff to the PHPCS native `Generic.PHP.LowerCaseKeyword` sniff which doesn't cover these keywords when used in an import `use` statement. + #### `Universal.UseStatements.NoLeadingBackslash` :wrench: :bar_chart: :books: Verify that a name being imported in an import `use` statement does not start with a leading backslash. From 2fea560cb157a82bb8c338493f94b8870ce36216 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 9 Aug 2023 03:10:03 +0200 Subject: [PATCH 03/15] Modernize/Dirname: rename test case file ... in anticipation of additional test case files being added. --- ...nameUnitTest.inc => DirnameUnitTest.1.inc} | 0 ....inc.fixed => DirnameUnitTest.1.inc.fixed} | 0 .../Tests/FunctionCalls/DirnameUnitTest.php | 76 ++++++++++--------- 3 files changed, 42 insertions(+), 34 deletions(-) rename Modernize/Tests/FunctionCalls/{DirnameUnitTest.inc => DirnameUnitTest.1.inc} (100%) rename Modernize/Tests/FunctionCalls/{DirnameUnitTest.inc.fixed => DirnameUnitTest.1.inc.fixed} (100%) diff --git a/Modernize/Tests/FunctionCalls/DirnameUnitTest.inc b/Modernize/Tests/FunctionCalls/DirnameUnitTest.1.inc similarity index 100% rename from Modernize/Tests/FunctionCalls/DirnameUnitTest.inc rename to Modernize/Tests/FunctionCalls/DirnameUnitTest.1.inc diff --git a/Modernize/Tests/FunctionCalls/DirnameUnitTest.inc.fixed b/Modernize/Tests/FunctionCalls/DirnameUnitTest.1.inc.fixed similarity index 100% rename from Modernize/Tests/FunctionCalls/DirnameUnitTest.inc.fixed rename to Modernize/Tests/FunctionCalls/DirnameUnitTest.1.inc.fixed diff --git a/Modernize/Tests/FunctionCalls/DirnameUnitTest.php b/Modernize/Tests/FunctionCalls/DirnameUnitTest.php index eaa73dba..ccac2dbc 100644 --- a/Modernize/Tests/FunctionCalls/DirnameUnitTest.php +++ b/Modernize/Tests/FunctionCalls/DirnameUnitTest.php @@ -28,43 +28,51 @@ final class DirnameUnitTest extends AbstractSniffUnitTest * The key of the array should represent the line number and the value * should represent the number of errors that should occur on that line. * + * @param string $testFile The name of the file being tested. + * * @return array */ - public function getErrorList() + public function getErrorList($testFile = '') { - return [ - 50 => 1, - 51 => 1, - 53 => 1, - 56 => 1, - 61 => 1, - 62 => 1, - 63 => 1, - 65 => 1, - 66 => 1, - 69 => 1, - 70 => 1, - 73 => 1, - 79 => 3, - 80 => 3, - 82 => 1, - 83 => 2, - 86 => 1, - 94 => 1, - 99 => 1, - 107 => 1, - 108 => 1, - 110 => 2, - 113 => 3, - 114 => 3, - 120 => 4, - 121 => 4, - 124 => 4, - 127 => 1, - 128 => 1, - 130 => 1, - 131 => 1, - ]; + switch ($testFile) { + case 'DirnameUnitTest.1.inc': + return [ + 50 => 1, + 51 => 1, + 53 => 1, + 56 => 1, + 61 => 1, + 62 => 1, + 63 => 1, + 65 => 1, + 66 => 1, + 69 => 1, + 70 => 1, + 73 => 1, + 79 => 3, + 80 => 3, + 82 => 1, + 83 => 2, + 86 => 1, + 94 => 1, + 99 => 1, + 107 => 1, + 108 => 1, + 110 => 2, + 113 => 3, + 114 => 3, + 120 => 4, + 121 => 4, + 124 => 4, + 127 => 1, + 128 => 1, + 130 => 1, + 131 => 1, + ]; + + default: + return []; + } } /** From 46af321caca99a781cb005c2ef783a428c3f8bf5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 9 Aug 2023 03:36:53 +0200 Subject: [PATCH 04/15] Modernize/Dirname: respect a passed `php_version` If no `php_version` is passed, the sniff will behave as before. However, is a `php_version` is passed, the sniff will now selectively stay silent depending on the configured PHP and whether the proposed fixes could be applied. Includes additional tests. Includes adding information about the support of the `php_version` config setting to the README docs. --- .../Sniffs/FunctionCalls/DirnameSniff.php | 30 ++++++++++++++ .../Tests/FunctionCalls/DirnameUnitTest.2.inc | 10 +++++ .../FunctionCalls/DirnameUnitTest.2.inc.fixed | 10 +++++ .../Tests/FunctionCalls/DirnameUnitTest.3.inc | 11 +++++ .../FunctionCalls/DirnameUnitTest.3.inc.fixed | 11 +++++ .../Tests/FunctionCalls/DirnameUnitTest.4.inc | 10 +++++ .../FunctionCalls/DirnameUnitTest.4.inc.fixed | 10 +++++ .../Tests/FunctionCalls/DirnameUnitTest.5.inc | 7 ++++ .../Tests/FunctionCalls/DirnameUnitTest.php | 41 +++++++++++++++++++ README.md | 3 ++ 10 files changed, 143 insertions(+) create mode 100644 Modernize/Tests/FunctionCalls/DirnameUnitTest.2.inc create mode 100644 Modernize/Tests/FunctionCalls/DirnameUnitTest.2.inc.fixed create mode 100644 Modernize/Tests/FunctionCalls/DirnameUnitTest.3.inc create mode 100644 Modernize/Tests/FunctionCalls/DirnameUnitTest.3.inc.fixed create mode 100644 Modernize/Tests/FunctionCalls/DirnameUnitTest.4.inc create mode 100644 Modernize/Tests/FunctionCalls/DirnameUnitTest.4.inc.fixed create mode 100644 Modernize/Tests/FunctionCalls/DirnameUnitTest.5.inc diff --git a/Modernize/Sniffs/FunctionCalls/DirnameSniff.php b/Modernize/Sniffs/FunctionCalls/DirnameSniff.php index 63e9c680..14dfed1a 100644 --- a/Modernize/Sniffs/FunctionCalls/DirnameSniff.php +++ b/Modernize/Sniffs/FunctionCalls/DirnameSniff.php @@ -13,6 +13,7 @@ use PHP_CodeSniffer\Files\File; use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; +use PHPCSUtils\BackCompat\Helper; use PHPCSUtils\Tokens\Collections; use PHPCSUtils\Utils\Context; use PHPCSUtils\Utils\PassedParameters; @@ -25,6 +26,15 @@ final class DirnameSniff implements Sniff { + /** + * PHP version as configured or 0 if unknown. + * + * @since 1.1.1 + * + * @var int + */ + private $phpVersion; + /** * Registers the tokens that this sniff wants to listen for. * @@ -50,6 +60,21 @@ public function register() */ public function process(File $phpcsFile, $stackPtr) { + if (isset($this->phpVersion) === false || \defined('PHP_CODESNIFFER_IN_TESTS')) { + // Set default value to prevent this code from running every time the sniff is triggered. + $this->phpVersion = 0; + + $phpVersion = Helper::getConfigData('php_version'); + if ($phpVersion !== null) { + $this->phpVersion = (int) $phpVersion; + } + } + + if ($this->phpVersion !== 0 && $this->phpVersion < 50300) { + // PHP version too low, nothing to do. + return; + } + $tokens = $phpcsFile->getTokens(); if (\strtolower($tokens[$stackPtr]['content']) !== 'dirname') { @@ -182,6 +207,11 @@ public function process(File $phpcsFile, $stackPtr) /* * PHP 7.0+: Detect use of nested calls to dirname(). */ + if ($this->phpVersion !== 0 && $this->phpVersion < 70000) { + // No need to check for this issue if the PHP version would not allow for it anyway. + return; + } + if (\preg_match('`^\s*\\\\?dirname\s*\(`i', $pathParam['clean']) !== 1) { return; } diff --git a/Modernize/Tests/FunctionCalls/DirnameUnitTest.2.inc b/Modernize/Tests/FunctionCalls/DirnameUnitTest.2.inc new file mode 100644 index 00000000..e88858be --- /dev/null +++ b/Modernize/Tests/FunctionCalls/DirnameUnitTest.2.inc @@ -0,0 +1,10 @@ + 1, ]; + case 'DirnameUnitTest.3.inc': + return [ + 10 => 1, + ]; + + case 'DirnameUnitTest.4.inc': + return [ + 9 => 1, + 10 => 1, + ]; + default: return []; } diff --git a/README.md b/README.md index c5af005d..22ba5382 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,9 @@ This sniff will detect and auto-fix two typical code modernizations which can be 2. Since PHP 7.0, nested function calls to `dirname()` can be changed to use the `$levels` parameter. Errorcode: `Modernize.FunctionCalls.Dirname.Nested`. +If a [`php_version` configuration option][php_version-config] has been passed to PHPCS using either `--config-set` or `--runtime-set`, it will be respected by the sniff. +In effect, this means that the sniff will only report on modernizations which can be applied for the PHP version as configured. + ### NormalizedArrays From b1877b494c8b10f40b662ccae0d66192bd3bffe1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 16 Aug 2023 23:35:07 +0200 Subject: [PATCH 05/15] CS: alphabetize use statements --- Modernize/Tests/FunctionCalls/DirnameUnitTest.php | 2 +- Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php | 2 +- .../Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php | 2 +- Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php | 2 +- Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php | 2 +- .../Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php | 2 +- Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php | 2 +- Universal/Sniffs/Operators/StrictComparisonsSniff.php | 2 +- Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php | 2 +- Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php | 2 +- Universal/Sniffs/UseStatements/DisallowUseClassSniff.php | 2 +- Universal/Sniffs/UseStatements/DisallowUseConstSniff.php | 2 +- Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php | 2 +- Universal/Sniffs/UseStatements/KeywordSpacingSniff.php | 2 +- Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php | 2 +- Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php | 2 +- Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php | 2 +- Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php | 2 +- Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php | 2 +- Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Modernize/Tests/FunctionCalls/DirnameUnitTest.php b/Modernize/Tests/FunctionCalls/DirnameUnitTest.php index 7b687ac0..00a8aad0 100644 --- a/Modernize/Tests/FunctionCalls/DirnameUnitTest.php +++ b/Modernize/Tests/FunctionCalls/DirnameUnitTest.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Modernize\Tests\FunctionCalls; -use PHPCSUtils\BackCompat\Helper; use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest; +use PHPCSUtils\BackCompat\Helper; /** * Unit test class for the Dirname sniff. diff --git a/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php b/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php index 00384ac6..c387ffa4 100644 --- a/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php +++ b/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\Namespaces; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHPCSUtils\Utils\Namespaces; /** diff --git a/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php b/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php index b3200278..2ccdadf7 100644 --- a/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php +++ b/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\Namespaces; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHPCSUtils\Utils\Namespaces; /** diff --git a/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php b/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php index b6676c26..e25b0345 100644 --- a/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php +++ b/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\Namespaces; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHPCSUtils\Utils\Namespaces; /** diff --git a/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php b/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php index c53cdf0b..04fe88df 100644 --- a/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php +++ b/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\Namespaces; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHPCSUtils\Utils\Namespaces; /** diff --git a/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php b/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php index 33c9609c..bbc5d1bf 100644 --- a/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php +++ b/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\OOStructures; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Tokens\Collections; use PHPCSUtils\Utils\ObjectDeclarations; diff --git a/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php b/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php index b654c280..501b17cf 100644 --- a/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php +++ b/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\Operators; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; /** * Enforce the use of the boolean `&&` and `||` operators instead of the logical `and`/`or` operators. diff --git a/Universal/Sniffs/Operators/StrictComparisonsSniff.php b/Universal/Sniffs/Operators/StrictComparisonsSniff.php index c1fead35..e472236b 100644 --- a/Universal/Sniffs/Operators/StrictComparisonsSniff.php +++ b/Universal/Sniffs/Operators/StrictComparisonsSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\Operators; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; /** * Enforce the use of strict comparisons. diff --git a/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php b/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php index cfed01dc..9d68b1fe 100644 --- a/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php +++ b/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\Operators; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Fixers\SpacesFixer; diff --git a/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php b/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php index 3303eac1..5e1f6d1f 100644 --- a/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php +++ b/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\UseStatements; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Utils\GetTokensAsString; use PHPCSUtils\Utils\UseStatements; diff --git a/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php b/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php index 3ac22c3b..82c4e692 100644 --- a/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php +++ b/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php @@ -11,8 +11,8 @@ namespace PHPCSExtra\Universal\Sniffs\UseStatements; use PHP_CodeSniffer\Exceptions\RuntimeException; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Utils\Namespaces; use PHPCSUtils\Utils\UseStatements; diff --git a/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php b/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php index b0a69755..1b7ab433 100644 --- a/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php +++ b/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php @@ -11,8 +11,8 @@ namespace PHPCSExtra\Universal\Sniffs\UseStatements; use PHP_CodeSniffer\Exceptions\RuntimeException; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Utils\Namespaces; use PHPCSUtils\Utils\UseStatements; diff --git a/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php b/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php index 64aaa130..29f860ca 100644 --- a/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php +++ b/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php @@ -11,8 +11,8 @@ namespace PHPCSExtra\Universal\Sniffs\UseStatements; use PHP_CodeSniffer\Exceptions\RuntimeException; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Utils\Namespaces; use PHPCSUtils\Utils\UseStatements; diff --git a/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php b/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php index ffef7cb8..25ac1b63 100644 --- a/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php +++ b/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\UseStatements; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Fixers\SpacesFixer; use PHPCSUtils\Utils\UseStatements; diff --git a/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php b/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php index 6cfb8313..9a123743 100644 --- a/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php +++ b/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\UseStatements; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Utils\UseStatements; diff --git a/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php b/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php index 811210b8..7c73b8c8 100644 --- a/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php +++ b/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\UseStatements; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Utils\UseStatements; diff --git a/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php b/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php index ebf7fe27..8975f694 100644 --- a/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php +++ b/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\UseStatements; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Utils\NamingConventions; use PHPCSUtils\Utils\UseStatements; diff --git a/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php b/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php index 4cde4b26..05fb2ff9 100644 --- a/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php +++ b/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\WhiteSpace; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\Fixers\SpacesFixer; diff --git a/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php b/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php index 29e5b335..4a14a1b3 100644 --- a/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php +++ b/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\WhiteSpace; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\BackCompat\Helper; use PHPCSUtils\Fixers\SpacesFixer; diff --git a/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php b/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php index c4f970f9..79210db3 100644 --- a/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php +++ b/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php @@ -10,8 +10,8 @@ namespace PHPCSExtra\Universal\Sniffs\WhiteSpace; -use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Files\File; +use PHP_CodeSniffer\Sniffs\Sniff; use PHP_CodeSniffer\Util\Tokens; use PHPCSUtils\BackCompat\Helper; use PHPCSUtils\Tokens\Collections; From 5626417bc0ea4084e21e02cd30aae9e9781eb6b1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Aug 2023 21:28:30 +0200 Subject: [PATCH 06/15] Modernize/Dirname: set redundant default values These variables are only accessed within conditions and those conditions already sufficiently ensure that the variables will be set for the conditions path. Even so, PHPStan cannot handle this, so we may as well declare sensible defaults for each of those variables to make things more explicit. --- Modernize/Sniffs/FunctionCalls/DirnameSniff.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Modernize/Sniffs/FunctionCalls/DirnameSniff.php b/Modernize/Sniffs/FunctionCalls/DirnameSniff.php index 14dfed1a..53b49f69 100644 --- a/Modernize/Sniffs/FunctionCalls/DirnameSniff.php +++ b/Modernize/Sniffs/FunctionCalls/DirnameSniff.php @@ -150,6 +150,8 @@ public function process(File $phpcsFile, $stackPtr) * PHP 5.3+: Detect use of dirname(__FILE__). */ if (\strtoupper($pathParam['clean']) === '__FILE__') { + $levelsValue = false; + // Determine if the issue is auto-fixable. $hasComment = $phpcsFile->findNext(Tokens::$commentTokens, ($opener + 1), $closer); $fixable = ($hasComment === false); @@ -248,7 +250,12 @@ public function process(File $phpcsFile, $stackPtr) */ // Step 1: Are there comments ? If so, not auto-fixable as we don't want to remove comments. - $fixable = true; + $fixable = true; + $outerLevelsValue = false; + $innerParameters = []; + $innerLevelsParam = false; + $innerLevelsValue = false; + for ($i = ($opener + 1); $i < $closer; $i++) { if (isset(Tokens::$commentTokens[$tokens[$i]['code']])) { $fixable = false; From 33997268123bbbcdbf4a26d9cd416d88a969fe44 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Aug 2023 21:29:20 +0200 Subject: [PATCH 07/15] Universal/DisallowInlineTabs: set redundant default values This variable is only accessed within conditions and those conditions already sufficiently ensure that the variable will be set for the conditions path. Even so, PHPStan cannot handle this, so we may as well declare a sensible default for this variable to make things more explicit. --- Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php b/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php index 2deee1a8..3499506e 100644 --- a/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php +++ b/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php @@ -127,6 +127,7 @@ public function process(File $phpcsFile, $stackPtr) * so from here on out, we **know** there will be tabs in the content. */ $origContent = $token['orig_content']; + $commentOnly = ''; $multiLineComment = false; if (($tokens[$i]['code'] === \T_COMMENT From 780c759d3e4f6f960cc870a59a47d82e002919d1 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Aug 2023 21:30:10 +0200 Subject: [PATCH 08/15] Universal/PrecisionAlignment: set redundant default values These variables are only accessed within conditions and those conditions already sufficiently ensure that the variables will be set for the conditions path. Even so, PHPStan cannot handle this, so we may as well declare sensible defaults for each of those variables to make things more explicit. --- Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php b/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php index 79210db3..32d04654 100644 --- a/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php +++ b/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php @@ -208,7 +208,11 @@ public function process(File $phpcsFile, $stackPtr) $origContent = $tokens[$i]['orig_content']; } - $spaces = 0; + $spaces = 0; + $length = 0; + $content = ''; + $closer = ''; + switch ($tokens[$i]['code']) { case \T_WHITESPACE: if ($this->ignoreBlankLines === true From fb7235e231d7eeed9a779d8a2916ddf566af5c84 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Aug 2023 22:09:56 +0200 Subject: [PATCH 09/15] Universal/NoEchoSprintf: bug fix The condition was checking the wrong variable against `false`. --- Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php b/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php index 3273e228..d363d674 100644 --- a/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php +++ b/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php @@ -81,7 +81,7 @@ public function process(File $phpcsFile, $stackPtr) $detectedFunction = \strtolower($tokens[$next]['content']); $openParens = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), null, true); - if ($next === false + if ($openParens === false || $tokens[$openParens]['code'] !== \T_OPEN_PARENTHESIS || isset($tokens[$openParens]['parenthesis_closer']) === false ) { From 0444986e7aca9e7b0b22a5c5b676fed2f2726fa7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Aug 2023 22:02:26 +0200 Subject: [PATCH 10/15] Universal/DisallowInlineTabs: increase type safety ... by casting to `int` for a property which expects `int`. --- Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php b/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php index 3499506e..95899698 100644 --- a/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php +++ b/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php @@ -91,11 +91,11 @@ public function register() public function process(File $phpcsFile, $stackPtr) { if (isset($this->tabWidth) === false) { - $this->tabWidth = Helper::getTabWidth($phpcsFile); + $this->tabWidth = (int) Helper::getTabWidth($phpcsFile); } if (\defined('PHP_CODESNIFFER_IN_TESTS')) { - $this->tabWidth = Helper::getCommandLineData($phpcsFile, 'tabWidth'); + $this->tabWidth = (int) Helper::getCommandLineData($phpcsFile, 'tabWidth'); } $tokens = $phpcsFile->getTokens(); From c1c93e15b05b6e0a32ec14c21e5f1c52846936e0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Aug 2023 21:47:44 +0200 Subject: [PATCH 11/15] Docs: improve test `@return` tags ... and make these docblocks a little more consistent. --- Modernize/Tests/FunctionCalls/DirnameUnitTest.php | 10 ++-------- .../Tests/Arrays/ArrayBraceSpacingUnitTest.php | 4 ++-- .../Tests/Arrays/CommaAfterLastUnitTest.php | 4 ++-- .../Tests/Arrays/DisallowShortArraySyntaxUnitTest.php | 10 ++-------- Universal/Tests/Arrays/DuplicateArrayKeyUnitTest.php | 4 ++-- Universal/Tests/Arrays/MixedArrayKeyTypesUnitTest.php | 4 ++-- .../Tests/Arrays/MixedKeyedUnkeyedArrayUnitTest.php | 4 ++-- .../Classes/DisallowAnonClassParenthesesUnitTest.php | 4 ++-- Universal/Tests/Classes/DisallowFinalClassUnitTest.php | 4 ++-- .../Tests/Classes/ModifierKeywordOrderUnitTest.php | 4 ++-- .../Classes/RequireAnonClassParenthesesUnitTest.php | 4 ++-- Universal/Tests/Classes/RequireFinalClassUnitTest.php | 4 ++-- .../ConstructorDestructorReturnUnitTest.php | 4 ++-- .../CodeAnalysis/ForeachUniqueAssignmentUnitTest.php | 4 ++-- Universal/Tests/CodeAnalysis/NoEchoSprintfUnitTest.php | 4 ++-- .../Tests/CodeAnalysis/StaticInFinalClassUnitTest.php | 4 ++-- .../LowercaseClassResolutionKeywordUnitTest.php | 4 ++-- .../Tests/Constants/ModifierKeywordOrderUnitTest.php | 4 ++-- .../Constants/UppercaseMagicConstantsUnitTest.php | 4 ++-- .../DisallowAlternativeSyntaxUnitTest.php | 4 ++-- .../ControlStructures/DisallowLonelyIfUnitTest.php | 4 ++-- .../ControlStructures/IfElseDeclarationUnitTest.php | 4 ++-- .../Tests/Files/SeparateFunctionsFromOOUnitTest.php | 4 ++-- .../FunctionDeclarations/NoLongClosuresUnitTest.php | 4 ++-- .../RequireFinalMethodsInTraitsUnitTest.php | 4 ++-- .../Tests/Lists/DisallowLongListSyntaxUnitTest.php | 10 ++-------- .../Tests/Lists/DisallowShortListSyntaxUnitTest.php | 10 ++-------- .../Namespaces/DisallowCurlyBraceSyntaxUnitTest.php | 4 ++-- .../DisallowDeclarationWithoutNameUnitTest.php | 4 ++-- .../Namespaces/EnforceCurlyBraceSyntaxUnitTest.php | 4 ++-- .../Tests/Namespaces/OneDeclarationPerFileUnitTest.php | 4 ++-- .../NoReservedKeywordParameterNamesUnitTest.php | 4 ++-- .../AlphabeticExtendsImplementsUnitTest.php | 4 ++-- .../Tests/Operators/DisallowLogicalAndOrUnitTest.php | 4 ++-- .../Tests/Operators/DisallowShortTernaryUnitTest.php | 10 ++-------- ...isallowStandalonePostIncrementDecrementUnitTest.php | 4 ++-- .../Tests/Operators/StrictComparisonsUnitTest.php | 4 ++-- .../Tests/Operators/TypeSeparatorSpacingUnitTest.php | 4 ++-- .../Tests/PHP/OneStatementInShortEchoTagUnitTest.php | 4 ++-- .../UseStatements/DisallowMixedGroupUseUnitTest.php | 4 ++-- .../Tests/UseStatements/DisallowUseClassUnitTest.php | 4 ++-- .../Tests/UseStatements/DisallowUseConstUnitTest.php | 4 ++-- .../UseStatements/DisallowUseFunctionUnitTest.php | 4 ++-- .../Tests/UseStatements/KeywordSpacingUnitTest.php | 4 ++-- .../UseStatements/LowercaseFunctionConstUnitTest.php | 4 ++-- .../Tests/UseStatements/NoLeadingBackslashUnitTest.php | 4 ++-- .../Tests/UseStatements/NoUselessAliasesUnitTest.php | 4 ++-- .../WhiteSpace/AnonClassKeywordSpacingUnitTest.php | 4 ++-- Universal/Tests/WhiteSpace/CommaSpacingUnitTest.php | 4 ++-- .../Tests/WhiteSpace/DisallowInlineTabsUnitTest.php | 4 ++-- .../Tests/WhiteSpace/PrecisionAlignmentUnitTest.php | 4 ++-- 51 files changed, 102 insertions(+), 132 deletions(-) diff --git a/Modernize/Tests/FunctionCalls/DirnameUnitTest.php b/Modernize/Tests/FunctionCalls/DirnameUnitTest.php index 00a8aad0..6ff6d899 100644 --- a/Modernize/Tests/FunctionCalls/DirnameUnitTest.php +++ b/Modernize/Tests/FunctionCalls/DirnameUnitTest.php @@ -55,12 +55,9 @@ public function setCliValues($testFile, $config) /** * Returns the lines where errors should occur. * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * * @param string $testFile The name of the file being tested. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -119,10 +116,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/NormalizedArrays/Tests/Arrays/ArrayBraceSpacingUnitTest.php b/NormalizedArrays/Tests/Arrays/ArrayBraceSpacingUnitTest.php index 14d3713d..4c2c724d 100644 --- a/NormalizedArrays/Tests/Arrays/ArrayBraceSpacingUnitTest.php +++ b/NormalizedArrays/Tests/Arrays/ArrayBraceSpacingUnitTest.php @@ -25,7 +25,7 @@ final class ArrayBraceSpacingUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -82,7 +82,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/NormalizedArrays/Tests/Arrays/CommaAfterLastUnitTest.php b/NormalizedArrays/Tests/Arrays/CommaAfterLastUnitTest.php index b528729f..fbffdc12 100644 --- a/NormalizedArrays/Tests/Arrays/CommaAfterLastUnitTest.php +++ b/NormalizedArrays/Tests/Arrays/CommaAfterLastUnitTest.php @@ -27,7 +27,7 @@ final class CommaAfterLastUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -74,7 +74,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php b/Universal/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php index 453ce81e..ba11aefd 100644 --- a/Universal/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php +++ b/Universal/Tests/Arrays/DisallowShortArraySyntaxUnitTest.php @@ -25,10 +25,7 @@ final class DisallowShortArraySyntaxUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -45,10 +42,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Arrays/DuplicateArrayKeyUnitTest.php b/Universal/Tests/Arrays/DuplicateArrayKeyUnitTest.php index a623a210..1ee95d9c 100644 --- a/Universal/Tests/Arrays/DuplicateArrayKeyUnitTest.php +++ b/Universal/Tests/Arrays/DuplicateArrayKeyUnitTest.php @@ -25,7 +25,7 @@ final class DuplicateArrayKeyUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -121,7 +121,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Arrays/MixedArrayKeyTypesUnitTest.php b/Universal/Tests/Arrays/MixedArrayKeyTypesUnitTest.php index b8195c50..a39a7f61 100644 --- a/Universal/Tests/Arrays/MixedArrayKeyTypesUnitTest.php +++ b/Universal/Tests/Arrays/MixedArrayKeyTypesUnitTest.php @@ -25,7 +25,7 @@ final class MixedArrayKeyTypesUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -39,7 +39,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Arrays/MixedKeyedUnkeyedArrayUnitTest.php b/Universal/Tests/Arrays/MixedKeyedUnkeyedArrayUnitTest.php index 3a4a62ae..95a16e42 100644 --- a/Universal/Tests/Arrays/MixedKeyedUnkeyedArrayUnitTest.php +++ b/Universal/Tests/Arrays/MixedKeyedUnkeyedArrayUnitTest.php @@ -25,7 +25,7 @@ final class MixedKeyedUnkeyedArrayUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -38,7 +38,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Classes/DisallowAnonClassParenthesesUnitTest.php b/Universal/Tests/Classes/DisallowAnonClassParenthesesUnitTest.php index 0bb81bed..024e2a6d 100644 --- a/Universal/Tests/Classes/DisallowAnonClassParenthesesUnitTest.php +++ b/Universal/Tests/Classes/DisallowAnonClassParenthesesUnitTest.php @@ -27,7 +27,7 @@ final class DisallowAnonClassParenthesesUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -49,7 +49,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Classes/DisallowFinalClassUnitTest.php b/Universal/Tests/Classes/DisallowFinalClassUnitTest.php index b3d105b6..ab5fab04 100644 --- a/Universal/Tests/Classes/DisallowFinalClassUnitTest.php +++ b/Universal/Tests/Classes/DisallowFinalClassUnitTest.php @@ -25,7 +25,7 @@ final class DisallowFinalClassUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -44,7 +44,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Classes/ModifierKeywordOrderUnitTest.php b/Universal/Tests/Classes/ModifierKeywordOrderUnitTest.php index 78b9f509..f9f2df6c 100644 --- a/Universal/Tests/Classes/ModifierKeywordOrderUnitTest.php +++ b/Universal/Tests/Classes/ModifierKeywordOrderUnitTest.php @@ -25,7 +25,7 @@ final class ModifierKeywordOrderUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -43,7 +43,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Classes/RequireAnonClassParenthesesUnitTest.php b/Universal/Tests/Classes/RequireAnonClassParenthesesUnitTest.php index c4bb0897..fd741396 100644 --- a/Universal/Tests/Classes/RequireAnonClassParenthesesUnitTest.php +++ b/Universal/Tests/Classes/RequireAnonClassParenthesesUnitTest.php @@ -25,7 +25,7 @@ final class RequireAnonClassParenthesesUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -39,7 +39,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Classes/RequireFinalClassUnitTest.php b/Universal/Tests/Classes/RequireFinalClassUnitTest.php index 386e0786..9732b74d 100644 --- a/Universal/Tests/Classes/RequireFinalClassUnitTest.php +++ b/Universal/Tests/Classes/RequireFinalClassUnitTest.php @@ -25,7 +25,7 @@ final class RequireFinalClassUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -41,7 +41,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/CodeAnalysis/ConstructorDestructorReturnUnitTest.php b/Universal/Tests/CodeAnalysis/ConstructorDestructorReturnUnitTest.php index a8de33ac..2280f9a2 100644 --- a/Universal/Tests/CodeAnalysis/ConstructorDestructorReturnUnitTest.php +++ b/Universal/Tests/CodeAnalysis/ConstructorDestructorReturnUnitTest.php @@ -53,7 +53,7 @@ public function setCliValues($testFile, $config) * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -97,7 +97,7 @@ public function getErrorList($testFile = '') * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList($testFile = '') { diff --git a/Universal/Tests/CodeAnalysis/ForeachUniqueAssignmentUnitTest.php b/Universal/Tests/CodeAnalysis/ForeachUniqueAssignmentUnitTest.php index 675acb7a..b19f99f6 100644 --- a/Universal/Tests/CodeAnalysis/ForeachUniqueAssignmentUnitTest.php +++ b/Universal/Tests/CodeAnalysis/ForeachUniqueAssignmentUnitTest.php @@ -25,7 +25,7 @@ final class ForeachUniqueAssignmentUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -44,7 +44,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/CodeAnalysis/NoEchoSprintfUnitTest.php b/Universal/Tests/CodeAnalysis/NoEchoSprintfUnitTest.php index 3b7d11ff..240cb9ad 100644 --- a/Universal/Tests/CodeAnalysis/NoEchoSprintfUnitTest.php +++ b/Universal/Tests/CodeAnalysis/NoEchoSprintfUnitTest.php @@ -27,7 +27,7 @@ final class NoEchoSprintfUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -50,7 +50,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.php b/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.php index e4564df0..99afecae 100644 --- a/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.php +++ b/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.php @@ -25,7 +25,7 @@ final class StaticInFinalClassUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -57,7 +57,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Constants/LowercaseClassResolutionKeywordUnitTest.php b/Universal/Tests/Constants/LowercaseClassResolutionKeywordUnitTest.php index c8a9b2a2..2c08a661 100644 --- a/Universal/Tests/Constants/LowercaseClassResolutionKeywordUnitTest.php +++ b/Universal/Tests/Constants/LowercaseClassResolutionKeywordUnitTest.php @@ -25,7 +25,7 @@ final class LowercaseClassResolutionKeywordUnitTest extends AbstractSniffUnitTes /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -38,7 +38,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Constants/ModifierKeywordOrderUnitTest.php b/Universal/Tests/Constants/ModifierKeywordOrderUnitTest.php index b14514d7..cb0dd542 100644 --- a/Universal/Tests/Constants/ModifierKeywordOrderUnitTest.php +++ b/Universal/Tests/Constants/ModifierKeywordOrderUnitTest.php @@ -25,7 +25,7 @@ final class ModifierKeywordOrderUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -43,7 +43,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Constants/UppercaseMagicConstantsUnitTest.php b/Universal/Tests/Constants/UppercaseMagicConstantsUnitTest.php index 83ac50a8..fd4ed45a 100644 --- a/Universal/Tests/Constants/UppercaseMagicConstantsUnitTest.php +++ b/Universal/Tests/Constants/UppercaseMagicConstantsUnitTest.php @@ -25,7 +25,7 @@ final class UppercaseMagicConstantsUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -52,7 +52,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/ControlStructures/DisallowAlternativeSyntaxUnitTest.php b/Universal/Tests/ControlStructures/DisallowAlternativeSyntaxUnitTest.php index 9630a2cc..6bb598c7 100644 --- a/Universal/Tests/ControlStructures/DisallowAlternativeSyntaxUnitTest.php +++ b/Universal/Tests/ControlStructures/DisallowAlternativeSyntaxUnitTest.php @@ -27,7 +27,7 @@ final class DisallowAlternativeSyntaxUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -78,7 +78,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/ControlStructures/DisallowLonelyIfUnitTest.php b/Universal/Tests/ControlStructures/DisallowLonelyIfUnitTest.php index 386aef8a..99771e27 100644 --- a/Universal/Tests/ControlStructures/DisallowLonelyIfUnitTest.php +++ b/Universal/Tests/ControlStructures/DisallowLonelyIfUnitTest.php @@ -25,7 +25,7 @@ final class DisallowLonelyIfUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -60,7 +60,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/ControlStructures/IfElseDeclarationUnitTest.php b/Universal/Tests/ControlStructures/IfElseDeclarationUnitTest.php index beb3afa6..cad6ceff 100644 --- a/Universal/Tests/ControlStructures/IfElseDeclarationUnitTest.php +++ b/Universal/Tests/ControlStructures/IfElseDeclarationUnitTest.php @@ -38,7 +38,7 @@ public function setCliValues($testFile, $config) /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -62,7 +62,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Files/SeparateFunctionsFromOOUnitTest.php b/Universal/Tests/Files/SeparateFunctionsFromOOUnitTest.php index 21bcbf80..907646f6 100644 --- a/Universal/Tests/Files/SeparateFunctionsFromOOUnitTest.php +++ b/Universal/Tests/Files/SeparateFunctionsFromOOUnitTest.php @@ -27,7 +27,7 @@ final class SeparateFunctionsFromOOUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -55,7 +55,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/FunctionDeclarations/NoLongClosuresUnitTest.php b/Universal/Tests/FunctionDeclarations/NoLongClosuresUnitTest.php index 8a812650..acbba01d 100644 --- a/Universal/Tests/FunctionDeclarations/NoLongClosuresUnitTest.php +++ b/Universal/Tests/FunctionDeclarations/NoLongClosuresUnitTest.php @@ -27,7 +27,7 @@ final class NoLongClosuresUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -84,7 +84,7 @@ public function getErrorList($testFile = '') * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList($testFile = '') { diff --git a/Universal/Tests/FunctionDeclarations/RequireFinalMethodsInTraitsUnitTest.php b/Universal/Tests/FunctionDeclarations/RequireFinalMethodsInTraitsUnitTest.php index 168fa928..f821bfd8 100644 --- a/Universal/Tests/FunctionDeclarations/RequireFinalMethodsInTraitsUnitTest.php +++ b/Universal/Tests/FunctionDeclarations/RequireFinalMethodsInTraitsUnitTest.php @@ -25,7 +25,7 @@ final class RequireFinalMethodsInTraitsUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -60,7 +60,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Lists/DisallowLongListSyntaxUnitTest.php b/Universal/Tests/Lists/DisallowLongListSyntaxUnitTest.php index 38dceeb8..b99b3bfd 100644 --- a/Universal/Tests/Lists/DisallowLongListSyntaxUnitTest.php +++ b/Universal/Tests/Lists/DisallowLongListSyntaxUnitTest.php @@ -25,10 +25,7 @@ final class DisallowLongListSyntaxUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -45,10 +42,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Lists/DisallowShortListSyntaxUnitTest.php b/Universal/Tests/Lists/DisallowShortListSyntaxUnitTest.php index 09a310d7..c43f0919 100644 --- a/Universal/Tests/Lists/DisallowShortListSyntaxUnitTest.php +++ b/Universal/Tests/Lists/DisallowShortListSyntaxUnitTest.php @@ -25,10 +25,7 @@ final class DisallowShortListSyntaxUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -46,10 +43,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Namespaces/DisallowCurlyBraceSyntaxUnitTest.php b/Universal/Tests/Namespaces/DisallowCurlyBraceSyntaxUnitTest.php index b2e716eb..68ae0772 100644 --- a/Universal/Tests/Namespaces/DisallowCurlyBraceSyntaxUnitTest.php +++ b/Universal/Tests/Namespaces/DisallowCurlyBraceSyntaxUnitTest.php @@ -25,7 +25,7 @@ final class DisallowCurlyBraceSyntaxUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -39,7 +39,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Namespaces/DisallowDeclarationWithoutNameUnitTest.php b/Universal/Tests/Namespaces/DisallowDeclarationWithoutNameUnitTest.php index 957d6ca1..194817b5 100644 --- a/Universal/Tests/Namespaces/DisallowDeclarationWithoutNameUnitTest.php +++ b/Universal/Tests/Namespaces/DisallowDeclarationWithoutNameUnitTest.php @@ -27,7 +27,7 @@ final class DisallowDeclarationWithoutNameUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -46,7 +46,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Namespaces/EnforceCurlyBraceSyntaxUnitTest.php b/Universal/Tests/Namespaces/EnforceCurlyBraceSyntaxUnitTest.php index 87bd1932..23a9af19 100644 --- a/Universal/Tests/Namespaces/EnforceCurlyBraceSyntaxUnitTest.php +++ b/Universal/Tests/Namespaces/EnforceCurlyBraceSyntaxUnitTest.php @@ -25,7 +25,7 @@ final class EnforceCurlyBraceSyntaxUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -38,7 +38,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Namespaces/OneDeclarationPerFileUnitTest.php b/Universal/Tests/Namespaces/OneDeclarationPerFileUnitTest.php index f0e1552c..a2f9a082 100644 --- a/Universal/Tests/Namespaces/OneDeclarationPerFileUnitTest.php +++ b/Universal/Tests/Namespaces/OneDeclarationPerFileUnitTest.php @@ -27,7 +27,7 @@ final class OneDeclarationPerFileUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -55,7 +55,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/NamingConventions/NoReservedKeywordParameterNamesUnitTest.php b/Universal/Tests/NamingConventions/NoReservedKeywordParameterNamesUnitTest.php index 96494c0b..537e1c32 100644 --- a/Universal/Tests/NamingConventions/NoReservedKeywordParameterNamesUnitTest.php +++ b/Universal/Tests/NamingConventions/NoReservedKeywordParameterNamesUnitTest.php @@ -25,7 +25,7 @@ final class NoReservedKeywordParameterNamesUnitTest extends AbstractSniffUnitTes /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -35,7 +35,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/OOStructures/AlphabeticExtendsImplementsUnitTest.php b/Universal/Tests/OOStructures/AlphabeticExtendsImplementsUnitTest.php index ed18a487..62ecbe24 100644 --- a/Universal/Tests/OOStructures/AlphabeticExtendsImplementsUnitTest.php +++ b/Universal/Tests/OOStructures/AlphabeticExtendsImplementsUnitTest.php @@ -25,7 +25,7 @@ final class AlphabeticExtendsImplementsUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -48,7 +48,7 @@ public function getErrorList() /** * Returns the lines where errors should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Operators/DisallowLogicalAndOrUnitTest.php b/Universal/Tests/Operators/DisallowLogicalAndOrUnitTest.php index 146d3529..1cf3b80f 100644 --- a/Universal/Tests/Operators/DisallowLogicalAndOrUnitTest.php +++ b/Universal/Tests/Operators/DisallowLogicalAndOrUnitTest.php @@ -25,7 +25,7 @@ final class DisallowLogicalAndOrUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -38,7 +38,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Operators/DisallowShortTernaryUnitTest.php b/Universal/Tests/Operators/DisallowShortTernaryUnitTest.php index 355abfe5..fa729e03 100644 --- a/Universal/Tests/Operators/DisallowShortTernaryUnitTest.php +++ b/Universal/Tests/Operators/DisallowShortTernaryUnitTest.php @@ -25,10 +25,7 @@ final class DisallowShortTernaryUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * The key of the array should represent the line number and the value - * should represent the number of errors that should occur on that line. - * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -42,10 +39,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * The key of the array should represent the line number and the value - * should represent the number of warnings that should occur on that line. - * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Operators/DisallowStandalonePostIncrementDecrementUnitTest.php b/Universal/Tests/Operators/DisallowStandalonePostIncrementDecrementUnitTest.php index f959e71e..9d6d980e 100644 --- a/Universal/Tests/Operators/DisallowStandalonePostIncrementDecrementUnitTest.php +++ b/Universal/Tests/Operators/DisallowStandalonePostIncrementDecrementUnitTest.php @@ -25,7 +25,7 @@ final class DisallowStandalonePostIncrementDecrementUnitTest extends AbstractSni /** * Returns the lines where errors should occur. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -51,7 +51,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Operators/StrictComparisonsUnitTest.php b/Universal/Tests/Operators/StrictComparisonsUnitTest.php index cf335529..ebbc4535 100644 --- a/Universal/Tests/Operators/StrictComparisonsUnitTest.php +++ b/Universal/Tests/Operators/StrictComparisonsUnitTest.php @@ -25,7 +25,7 @@ final class StrictComparisonsUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -39,7 +39,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/Operators/TypeSeparatorSpacingUnitTest.php b/Universal/Tests/Operators/TypeSeparatorSpacingUnitTest.php index 29427848..76c2ad7d 100644 --- a/Universal/Tests/Operators/TypeSeparatorSpacingUnitTest.php +++ b/Universal/Tests/Operators/TypeSeparatorSpacingUnitTest.php @@ -25,7 +25,7 @@ final class TypeSeparatorSpacingUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -44,7 +44,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/PHP/OneStatementInShortEchoTagUnitTest.php b/Universal/Tests/PHP/OneStatementInShortEchoTagUnitTest.php index 4fcef67e..39fdd55c 100644 --- a/Universal/Tests/PHP/OneStatementInShortEchoTagUnitTest.php +++ b/Universal/Tests/PHP/OneStatementInShortEchoTagUnitTest.php @@ -27,7 +27,7 @@ final class OneStatementInShortEchoTagUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -53,7 +53,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getWarningList() { diff --git a/Universal/Tests/UseStatements/DisallowMixedGroupUseUnitTest.php b/Universal/Tests/UseStatements/DisallowMixedGroupUseUnitTest.php index 9e2a73b1..a996bdbb 100644 --- a/Universal/Tests/UseStatements/DisallowMixedGroupUseUnitTest.php +++ b/Universal/Tests/UseStatements/DisallowMixedGroupUseUnitTest.php @@ -38,7 +38,7 @@ public function setCliValues($testFile, $config) /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -58,7 +58,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/UseStatements/DisallowUseClassUnitTest.php b/Universal/Tests/UseStatements/DisallowUseClassUnitTest.php index d6e52041..f79d2918 100644 --- a/Universal/Tests/UseStatements/DisallowUseClassUnitTest.php +++ b/Universal/Tests/UseStatements/DisallowUseClassUnitTest.php @@ -30,7 +30,7 @@ final class DisallowUseClassUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -112,7 +112,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/UseStatements/DisallowUseConstUnitTest.php b/Universal/Tests/UseStatements/DisallowUseConstUnitTest.php index a0b7529a..52f49653 100644 --- a/Universal/Tests/UseStatements/DisallowUseConstUnitTest.php +++ b/Universal/Tests/UseStatements/DisallowUseConstUnitTest.php @@ -30,7 +30,7 @@ final class DisallowUseConstUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -108,7 +108,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/UseStatements/DisallowUseFunctionUnitTest.php b/Universal/Tests/UseStatements/DisallowUseFunctionUnitTest.php index 2a6218f6..fdbb32b5 100644 --- a/Universal/Tests/UseStatements/DisallowUseFunctionUnitTest.php +++ b/Universal/Tests/UseStatements/DisallowUseFunctionUnitTest.php @@ -30,7 +30,7 @@ final class DisallowUseFunctionUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -113,7 +113,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/UseStatements/KeywordSpacingUnitTest.php b/Universal/Tests/UseStatements/KeywordSpacingUnitTest.php index b54638a0..54934e40 100644 --- a/Universal/Tests/UseStatements/KeywordSpacingUnitTest.php +++ b/Universal/Tests/UseStatements/KeywordSpacingUnitTest.php @@ -27,7 +27,7 @@ final class KeywordSpacingUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -71,7 +71,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/UseStatements/LowercaseFunctionConstUnitTest.php b/Universal/Tests/UseStatements/LowercaseFunctionConstUnitTest.php index 46318f12..2364a980 100644 --- a/Universal/Tests/UseStatements/LowercaseFunctionConstUnitTest.php +++ b/Universal/Tests/UseStatements/LowercaseFunctionConstUnitTest.php @@ -25,7 +25,7 @@ final class LowercaseFunctionConstUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -42,7 +42,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/UseStatements/NoLeadingBackslashUnitTest.php b/Universal/Tests/UseStatements/NoLeadingBackslashUnitTest.php index 5587a49d..4a2970d9 100644 --- a/Universal/Tests/UseStatements/NoLeadingBackslashUnitTest.php +++ b/Universal/Tests/UseStatements/NoLeadingBackslashUnitTest.php @@ -27,7 +27,7 @@ final class NoLeadingBackslashUnitTest extends AbstractSniffUnitTest * * @param string $testFile The name of the file being tested. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -53,7 +53,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/UseStatements/NoUselessAliasesUnitTest.php b/Universal/Tests/UseStatements/NoUselessAliasesUnitTest.php index 71df410e..dda59cbd 100644 --- a/Universal/Tests/UseStatements/NoUselessAliasesUnitTest.php +++ b/Universal/Tests/UseStatements/NoUselessAliasesUnitTest.php @@ -25,7 +25,7 @@ final class NoUselessAliasesUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -54,7 +54,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/WhiteSpace/AnonClassKeywordSpacingUnitTest.php b/Universal/Tests/WhiteSpace/AnonClassKeywordSpacingUnitTest.php index f5a9ce76..c93eb4fc 100644 --- a/Universal/Tests/WhiteSpace/AnonClassKeywordSpacingUnitTest.php +++ b/Universal/Tests/WhiteSpace/AnonClassKeywordSpacingUnitTest.php @@ -25,7 +25,7 @@ final class AnonClassKeywordSpacingUnitTest extends AbstractSniffUnitTest /** * Returns the lines where errors should occur. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -54,7 +54,7 @@ public function getErrorList() /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/WhiteSpace/CommaSpacingUnitTest.php b/Universal/Tests/WhiteSpace/CommaSpacingUnitTest.php index b140fbc4..f1188cd3 100644 --- a/Universal/Tests/WhiteSpace/CommaSpacingUnitTest.php +++ b/Universal/Tests/WhiteSpace/CommaSpacingUnitTest.php @@ -82,7 +82,7 @@ protected function getTestFiles($testFileBase) * * @param string $testFile The name of the file being tested. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -227,7 +227,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { diff --git a/Universal/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php b/Universal/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php index 262127a9..147e3361 100644 --- a/Universal/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php +++ b/Universal/Tests/WhiteSpace/DisallowInlineTabsUnitTest.php @@ -69,7 +69,7 @@ public function setCliValues($testFile, $config) * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList($testFile = '') { @@ -155,7 +155,7 @@ public function getErrorList($testFile = '') /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getWarningList() { diff --git a/Universal/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php b/Universal/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php index a0cf0d58..21ee5cee 100644 --- a/Universal/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php +++ b/Universal/Tests/WhiteSpace/PrecisionAlignmentUnitTest.php @@ -68,7 +68,7 @@ public function setCliValues($testFile, $config) /** * Returns the lines where errors should occur. * - * @return array + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { @@ -80,7 +80,7 @@ public function getErrorList() * * @param string $testFile The name of the file being tested. * - * @return array + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList($testFile = '') { From ed86bb117c340f654eab603a06b95a437ac619c9 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 26 Aug 2023 04:48:12 +0200 Subject: [PATCH 12/15] Docs: improve `@return` tags for `register()` methods ... and make them more consistent across the sniffs. --- Modernize/Sniffs/FunctionCalls/DirnameSniff.php | 2 +- NormalizedArrays/Sniffs/Arrays/ArrayBraceSpacingSniff.php | 2 +- NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php | 2 +- Universal/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php | 2 +- Universal/Sniffs/Classes/DisallowAnonClassParenthesesSniff.php | 2 +- Universal/Sniffs/Classes/DisallowFinalClassSniff.php | 2 +- Universal/Sniffs/Classes/ModifierKeywordOrderSniff.php | 2 +- Universal/Sniffs/Classes/RequireAnonClassParenthesesSniff.php | 2 +- Universal/Sniffs/Classes/RequireFinalClassSniff.php | 2 +- .../Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php | 2 +- Universal/Sniffs/CodeAnalysis/ForeachUniqueAssignmentSniff.php | 2 +- Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php | 2 +- Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php | 2 +- .../Sniffs/Constants/LowercaseClassResolutionKeywordSniff.php | 2 +- Universal/Sniffs/Constants/ModifierKeywordOrderSniff.php | 2 +- Universal/Sniffs/Constants/UppercaseMagicConstantsSniff.php | 2 +- .../Sniffs/ControlStructures/DisallowAlternativeSyntaxSniff.php | 2 +- Universal/Sniffs/ControlStructures/DisallowLonelyIfSniff.php | 2 +- Universal/Sniffs/ControlStructures/IfElseDeclarationSniff.php | 2 +- Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php | 2 +- Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php | 2 +- .../FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php | 2 +- Universal/Sniffs/Lists/DisallowLongListSyntaxSniff.php | 2 +- Universal/Sniffs/Lists/DisallowShortListSyntaxSniff.php | 2 +- Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php | 2 +- .../Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php | 2 +- Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php | 2 +- Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php | 2 +- .../NamingConventions/NoReservedKeywordParameterNamesSniff.php | 2 +- .../Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php | 2 +- Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php | 2 +- Universal/Sniffs/Operators/DisallowShortTernarySniff.php | 2 +- .../Operators/DisallowStandalonePostIncrementDecrementSniff.php | 2 +- Universal/Sniffs/Operators/StrictComparisonsSniff.php | 2 +- Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php | 2 +- Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php | 2 +- Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php | 2 +- Universal/Sniffs/UseStatements/DisallowUseClassSniff.php | 2 +- Universal/Sniffs/UseStatements/DisallowUseConstSniff.php | 2 +- Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php | 2 +- Universal/Sniffs/UseStatements/KeywordSpacingSniff.php | 2 +- Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php | 2 +- Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php | 2 +- Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php | 2 +- Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php | 2 +- Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php | 2 +- Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php | 2 +- Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php | 2 +- 48 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Modernize/Sniffs/FunctionCalls/DirnameSniff.php b/Modernize/Sniffs/FunctionCalls/DirnameSniff.php index 53b49f69..1e573ce5 100644 --- a/Modernize/Sniffs/FunctionCalls/DirnameSniff.php +++ b/Modernize/Sniffs/FunctionCalls/DirnameSniff.php @@ -40,7 +40,7 @@ final class DirnameSniff implements Sniff * * @since 1.0.0 * - * @return int|string[] + * @return array */ public function register() { diff --git a/NormalizedArrays/Sniffs/Arrays/ArrayBraceSpacingSniff.php b/NormalizedArrays/Sniffs/Arrays/ArrayBraceSpacingSniff.php index d09a336a..b6317707 100644 --- a/NormalizedArrays/Sniffs/Arrays/ArrayBraceSpacingSniff.php +++ b/NormalizedArrays/Sniffs/Arrays/ArrayBraceSpacingSniff.php @@ -102,7 +102,7 @@ final class ArrayBraceSpacingSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php b/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php index 9697ce8a..4978bab9 100644 --- a/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php +++ b/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php @@ -87,7 +87,7 @@ final class CommaAfterLastSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php b/Universal/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php index c4e8987c..829daaa9 100644 --- a/Universal/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php +++ b/Universal/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php @@ -42,7 +42,7 @@ final class DisallowShortArraySyntaxSniff implements Sniff * * @since 1.0.0 * - * @return int|string[] + * @return array */ public function register() { diff --git a/Universal/Sniffs/Classes/DisallowAnonClassParenthesesSniff.php b/Universal/Sniffs/Classes/DisallowAnonClassParenthesesSniff.php index 7a3c01cf..dae01252 100644 --- a/Universal/Sniffs/Classes/DisallowAnonClassParenthesesSniff.php +++ b/Universal/Sniffs/Classes/DisallowAnonClassParenthesesSniff.php @@ -37,7 +37,7 @@ final class DisallowAnonClassParenthesesSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Classes/DisallowFinalClassSniff.php b/Universal/Sniffs/Classes/DisallowFinalClassSniff.php index 8920958a..4e3f4719 100644 --- a/Universal/Sniffs/Classes/DisallowFinalClassSniff.php +++ b/Universal/Sniffs/Classes/DisallowFinalClassSniff.php @@ -38,7 +38,7 @@ final class DisallowFinalClassSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Classes/ModifierKeywordOrderSniff.php b/Universal/Sniffs/Classes/ModifierKeywordOrderSniff.php index b5a3330a..88fdfe20 100644 --- a/Universal/Sniffs/Classes/ModifierKeywordOrderSniff.php +++ b/Universal/Sniffs/Classes/ModifierKeywordOrderSniff.php @@ -69,7 +69,7 @@ final class ModifierKeywordOrderSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Classes/RequireAnonClassParenthesesSniff.php b/Universal/Sniffs/Classes/RequireAnonClassParenthesesSniff.php index c35f9f99..2715b392 100644 --- a/Universal/Sniffs/Classes/RequireAnonClassParenthesesSniff.php +++ b/Universal/Sniffs/Classes/RequireAnonClassParenthesesSniff.php @@ -36,7 +36,7 @@ final class RequireAnonClassParenthesesSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Classes/RequireFinalClassSniff.php b/Universal/Sniffs/Classes/RequireFinalClassSniff.php index 2c46c601..843f1add 100644 --- a/Universal/Sniffs/Classes/RequireFinalClassSniff.php +++ b/Universal/Sniffs/Classes/RequireFinalClassSniff.php @@ -38,7 +38,7 @@ final class RequireFinalClassSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php b/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php index ce66d4d1..4c577884 100644 --- a/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php +++ b/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php @@ -45,7 +45,7 @@ final class ConstructorDestructorReturnSniff implements Sniff * * @since 1.0.0 * - * @return int[] + * @return array */ public function register() { diff --git a/Universal/Sniffs/CodeAnalysis/ForeachUniqueAssignmentSniff.php b/Universal/Sniffs/CodeAnalysis/ForeachUniqueAssignmentSniff.php index 5cb5b5ee..8895c56c 100644 --- a/Universal/Sniffs/CodeAnalysis/ForeachUniqueAssignmentSniff.php +++ b/Universal/Sniffs/CodeAnalysis/ForeachUniqueAssignmentSniff.php @@ -33,7 +33,7 @@ final class ForeachUniqueAssignmentSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php b/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php index d363d674..67035f2a 100644 --- a/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php +++ b/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php @@ -44,7 +44,7 @@ final class NoEchoSprintfSniff implements Sniff * * @since 1.1.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php b/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php index 1e1a3857..f84d2ef3 100644 --- a/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php +++ b/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php @@ -43,7 +43,7 @@ final class StaticInFinalClassSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Constants/LowercaseClassResolutionKeywordSniff.php b/Universal/Sniffs/Constants/LowercaseClassResolutionKeywordSniff.php index 6df4e5fe..7a67e479 100644 --- a/Universal/Sniffs/Constants/LowercaseClassResolutionKeywordSniff.php +++ b/Universal/Sniffs/Constants/LowercaseClassResolutionKeywordSniff.php @@ -39,7 +39,7 @@ final class LowercaseClassResolutionKeywordSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Constants/ModifierKeywordOrderSniff.php b/Universal/Sniffs/Constants/ModifierKeywordOrderSniff.php index 34cf28d8..4b2e7183 100644 --- a/Universal/Sniffs/Constants/ModifierKeywordOrderSniff.php +++ b/Universal/Sniffs/Constants/ModifierKeywordOrderSniff.php @@ -71,7 +71,7 @@ final class ModifierKeywordOrderSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Constants/UppercaseMagicConstantsSniff.php b/Universal/Sniffs/Constants/UppercaseMagicConstantsSniff.php index 1b234f92..348cf65e 100644 --- a/Universal/Sniffs/Constants/UppercaseMagicConstantsSniff.php +++ b/Universal/Sniffs/Constants/UppercaseMagicConstantsSniff.php @@ -38,7 +38,7 @@ final class UppercaseMagicConstantsSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/ControlStructures/DisallowAlternativeSyntaxSniff.php b/Universal/Sniffs/ControlStructures/DisallowAlternativeSyntaxSniff.php index 86f06a6a..ab78a70a 100644 --- a/Universal/Sniffs/ControlStructures/DisallowAlternativeSyntaxSniff.php +++ b/Universal/Sniffs/ControlStructures/DisallowAlternativeSyntaxSniff.php @@ -51,7 +51,7 @@ final class DisallowAlternativeSyntaxSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/ControlStructures/DisallowLonelyIfSniff.php b/Universal/Sniffs/ControlStructures/DisallowLonelyIfSniff.php index 61825425..58c81ae1 100644 --- a/Universal/Sniffs/ControlStructures/DisallowLonelyIfSniff.php +++ b/Universal/Sniffs/ControlStructures/DisallowLonelyIfSniff.php @@ -35,7 +35,7 @@ final class DisallowLonelyIfSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/ControlStructures/IfElseDeclarationSniff.php b/Universal/Sniffs/ControlStructures/IfElseDeclarationSniff.php index 01984c2c..fb2c39d4 100644 --- a/Universal/Sniffs/ControlStructures/IfElseDeclarationSniff.php +++ b/Universal/Sniffs/ControlStructures/IfElseDeclarationSniff.php @@ -45,7 +45,7 @@ final class IfElseDeclarationSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php b/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php index c2c1be52..59940e54 100644 --- a/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php +++ b/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php @@ -62,7 +62,7 @@ final class SeparateFunctionsFromOOSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php b/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php index 13abb9fe..a9ccf78b 100644 --- a/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php +++ b/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php @@ -98,7 +98,7 @@ final class NoLongClosuresSniff implements Sniff * * @since 1.1.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php b/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php index da9e2415..505c19b3 100644 --- a/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php +++ b/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php @@ -38,7 +38,7 @@ final class RequireFinalMethodsInTraitsSniff implements Sniff * * @since 1.1.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Lists/DisallowLongListSyntaxSniff.php b/Universal/Sniffs/Lists/DisallowLongListSyntaxSniff.php index 1b57510f..de7447e0 100644 --- a/Universal/Sniffs/Lists/DisallowLongListSyntaxSniff.php +++ b/Universal/Sniffs/Lists/DisallowLongListSyntaxSniff.php @@ -27,7 +27,7 @@ final class DisallowLongListSyntaxSniff implements Sniff * * @since 1.0.0 * - * @return int[] + * @return array */ public function register() { diff --git a/Universal/Sniffs/Lists/DisallowShortListSyntaxSniff.php b/Universal/Sniffs/Lists/DisallowShortListSyntaxSniff.php index e57d243e..af2a9489 100644 --- a/Universal/Sniffs/Lists/DisallowShortListSyntaxSniff.php +++ b/Universal/Sniffs/Lists/DisallowShortListSyntaxSniff.php @@ -35,7 +35,7 @@ final class DisallowShortListSyntaxSniff implements Sniff * * @since 1.0.0 * - * @return int[] + * @return array */ public function register() { diff --git a/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php b/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php index c387ffa4..3b6ad982 100644 --- a/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php +++ b/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php @@ -36,7 +36,7 @@ final class DisallowCurlyBraceSyntaxSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php b/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php index 2ccdadf7..5348e707 100644 --- a/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php +++ b/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php @@ -36,7 +36,7 @@ final class DisallowDeclarationWithoutNameSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php b/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php index e25b0345..78fa3261 100644 --- a/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php +++ b/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php @@ -36,7 +36,7 @@ final class EnforceCurlyBraceSyntaxSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php b/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php index 04fe88df..65f3e589 100644 --- a/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php +++ b/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php @@ -45,7 +45,7 @@ final class OneDeclarationPerFileSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php b/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php index 15da4aea..5085ae87 100644 --- a/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php +++ b/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php @@ -145,7 +145,7 @@ final class NoReservedKeywordParameterNamesSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php b/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php index bbc5d1bf..4d765c2c 100644 --- a/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php +++ b/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php @@ -82,7 +82,7 @@ final class AlphabeticExtendsImplementsSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php b/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php index 501b17cf..278224b7 100644 --- a/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php +++ b/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php @@ -71,7 +71,7 @@ final class DisallowLogicalAndOrSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Operators/DisallowShortTernarySniff.php b/Universal/Sniffs/Operators/DisallowShortTernarySniff.php index 078e70bb..37a39a18 100644 --- a/Universal/Sniffs/Operators/DisallowShortTernarySniff.php +++ b/Universal/Sniffs/Operators/DisallowShortTernarySniff.php @@ -40,7 +40,7 @@ final class DisallowShortTernarySniff implements Sniff * * @since 1.0.0 * - * @return int[] + * @return array */ public function register() { diff --git a/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php b/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php index 905dd1ec..23873470 100644 --- a/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php +++ b/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php @@ -58,7 +58,7 @@ final class DisallowStandalonePostIncrementDecrementSniff implements Sniff * * @since 1.0.0 * - * @return int[] + * @return array */ public function register() { diff --git a/Universal/Sniffs/Operators/StrictComparisonsSniff.php b/Universal/Sniffs/Operators/StrictComparisonsSniff.php index e472236b..dcc27b70 100644 --- a/Universal/Sniffs/Operators/StrictComparisonsSniff.php +++ b/Universal/Sniffs/Operators/StrictComparisonsSniff.php @@ -70,7 +70,7 @@ final class StrictComparisonsSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php b/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php index 9d68b1fe..440ecc86 100644 --- a/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php +++ b/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php @@ -28,7 +28,7 @@ final class TypeSeparatorSpacingSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php b/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php index a8fc725e..f2cd7140 100644 --- a/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php +++ b/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php @@ -32,7 +32,7 @@ final class OneStatementInShortEchoTagSniff implements Sniff * * @since 1.0.0 * - * @return int[] + * @return array */ public function register() { diff --git a/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php b/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php index 5e1f6d1f..2bb240df 100644 --- a/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php +++ b/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php @@ -44,7 +44,7 @@ final class DisallowMixedGroupUseSniff implements Sniff * * @since 1.1.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php b/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php index 82c4e692..8dcf8ddb 100644 --- a/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php +++ b/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php @@ -70,7 +70,7 @@ final class DisallowUseClassSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php b/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php index 1b7ab433..44388f6a 100644 --- a/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php +++ b/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php @@ -70,7 +70,7 @@ final class DisallowUseConstSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php b/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php index 29f860ca..46a39edb 100644 --- a/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php +++ b/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php @@ -70,7 +70,7 @@ final class DisallowUseFunctionSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php b/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php index 25ac1b63..534023d2 100644 --- a/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php +++ b/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php @@ -62,7 +62,7 @@ final class KeywordSpacingSniff implements Sniff * * @since 1.1.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php b/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php index 9a123743..69970f67 100644 --- a/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php +++ b/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php @@ -52,7 +52,7 @@ final class LowercaseFunctionConstSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php b/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php index 7c73b8c8..1fccc828 100644 --- a/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php +++ b/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php @@ -41,7 +41,7 @@ final class NoLeadingBackslashSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php b/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php index 8975f694..6d699934 100644 --- a/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php +++ b/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php @@ -42,7 +42,7 @@ final class NoUselessAliasesSniff implements Sniff * * @since 1.1.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php b/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php index 05fb2ff9..31163165 100644 --- a/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php +++ b/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php @@ -37,7 +37,7 @@ final class AnonClassKeywordSpacingSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php b/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php index 4a14a1b3..376e9046 100644 --- a/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php +++ b/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php @@ -78,7 +78,7 @@ final class CommaSpacingSniff implements Sniff * * @since 1.1.0 * - * @return array + * @return array */ public function register() { diff --git a/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php b/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php index 95899698..5627eb3d 100644 --- a/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php +++ b/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php @@ -70,7 +70,7 @@ final class DisallowInlineTabsSniff implements Sniff * * @since 1.0.0 * - * @return int[] + * @return array */ public function register() { diff --git a/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php b/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php index 32d04654..c5f62620 100644 --- a/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php +++ b/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php @@ -134,7 +134,7 @@ final class PrecisionAlignmentSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { From 93dc83b252644d5d0e67d61bb128296808b7c41f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Fri, 25 Aug 2023 21:04:56 +0200 Subject: [PATCH 13/15] Docs: various `@var`/`@param`/`@return` tag improvements Definitely not claiming completeness. This is just another iteration step in improving the documented types. --- Modernize/Sniffs/FunctionCalls/DirnameSniff.php | 6 +++--- NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php | 2 +- Universal/Helpers/DummyTokenizer.php | 3 ++- Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php | 4 ++-- Universal/Sniffs/Arrays/MixedArrayKeyTypesSniff.php | 8 ++++++-- Universal/Sniffs/Arrays/MixedKeyedUnkeyedArraySniff.php | 2 +- Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php | 2 +- Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php | 5 +++-- .../NoReservedKeywordParameterNamesSniff.php | 2 +- Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php | 4 ++-- .../DisallowStandalonePostIncrementDecrementSniff.php | 5 +++-- Universal/Sniffs/Operators/StrictComparisonsSniff.php | 4 ++-- Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php | 2 +- Universal/Sniffs/UseStatements/KeywordSpacingSniff.php | 2 +- .../Sniffs/UseStatements/LowercaseFunctionConstSniff.php | 2 +- Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php | 2 +- Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php | 4 ++-- 17 files changed, 33 insertions(+), 26 deletions(-) diff --git a/Modernize/Sniffs/FunctionCalls/DirnameSniff.php b/Modernize/Sniffs/FunctionCalls/DirnameSniff.php index 1e573ce5..b064b264 100644 --- a/Modernize/Sniffs/FunctionCalls/DirnameSniff.php +++ b/Modernize/Sniffs/FunctionCalls/DirnameSniff.php @@ -357,9 +357,9 @@ public function process(File $phpcsFile, $stackPtr) * * @since 1.0.0 * - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. - * @param array|false $levelsParam The information about the parameter as retrieved - * via PassedParameters::getParameterFromStack(). + * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. + * @param array|false $levelsParam The information about the parameter as retrieved + * via PassedParameters::getParameterFromStack(). * * @return int|false Integer levels value or FALSE if the levels value couldn't be determined. */ diff --git a/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php b/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php index 4978bab9..d03d1ffc 100644 --- a/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php +++ b/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php @@ -74,7 +74,7 @@ final class CommaAfterLastSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var array */ private $validValues = [ 'enforce' => true, diff --git a/Universal/Helpers/DummyTokenizer.php b/Universal/Helpers/DummyTokenizer.php index 29a58fe6..7c172e34 100644 --- a/Universal/Helpers/DummyTokenizer.php +++ b/Universal/Helpers/DummyTokenizer.php @@ -42,10 +42,11 @@ public function __construct($content, $config, $eolChar = '\n') * * @param string $string The string to tokenize. * - * @return array + * @return array> */ protected function tokenize($string) { + return []; } /** diff --git a/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php b/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php index f9ed534b..7097fad7 100644 --- a/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php +++ b/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php @@ -35,7 +35,7 @@ final class DuplicateArrayKeySniff extends AbstractArrayDeclarationSniff * * @since 1.0.0 * - * @var array + * @var array> */ private $keysSeenLt8 = []; @@ -44,7 +44,7 @@ final class DuplicateArrayKeySniff extends AbstractArrayDeclarationSniff * * @since 1.0.0 * - * @var array + * @var array> */ private $keysSeenGt8 = []; diff --git a/Universal/Sniffs/Arrays/MixedArrayKeyTypesSniff.php b/Universal/Sniffs/Arrays/MixedArrayKeyTypesSniff.php index 391844e4..49d9260b 100644 --- a/Universal/Sniffs/Arrays/MixedArrayKeyTypesSniff.php +++ b/Universal/Sniffs/Arrays/MixedArrayKeyTypesSniff.php @@ -68,7 +68,9 @@ public function processArray(File $phpcsFile) * an array item. * @param int $itemNr Which item in the array is being handled. * - * @return void + * @return true|void Returning `TRUE` will short-circuit the array item loop and stop processing. + * In effect, this means that the sniff will not examine the double arrow, the array + * value or comma for this array item and will not process any array items after this one. */ public function processKey(File $phpcsFile, $startPtr, $endPtr, $itemNr) { @@ -141,7 +143,9 @@ public function processKey(File $phpcsFile, $startPtr, $endPtr, $itemNr) * value part of the array item. * @param int $itemNr Which item in the array is being handled. * - * @return void + * @return true|void Returning `TRUE` will short-circuit the array item loop and stop processing. + * In effect, this means that the sniff will not examine the array value or + * comma for this array item and will not process any array items after this one. */ public function processNoKey(File $phpcsFile, $startPtr, $itemNr) { diff --git a/Universal/Sniffs/Arrays/MixedKeyedUnkeyedArraySniff.php b/Universal/Sniffs/Arrays/MixedKeyedUnkeyedArraySniff.php index f8236583..c47f217f 100644 --- a/Universal/Sniffs/Arrays/MixedKeyedUnkeyedArraySniff.php +++ b/Universal/Sniffs/Arrays/MixedKeyedUnkeyedArraySniff.php @@ -36,7 +36,7 @@ final class MixedKeyedUnkeyedArraySniff extends AbstractArrayDeclarationSniff * * @since 1.0.0 * - * @var array => + * @var array Key is the item number; value the stack point to the first non empty token in the item. */ private $itemsWithoutKey = []; diff --git a/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php b/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php index f84d2ef3..2136bcdb 100644 --- a/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php +++ b/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php @@ -30,7 +30,7 @@ final class StaticInFinalClassSniff implements Sniff /** * OO Scopes in which late static binding is useless. * - * @var int|string[] + * @var array */ private $validOOScopes = [ \T_CLASS, // Only if final. diff --git a/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php b/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php index 59940e54..c274e751 100644 --- a/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php +++ b/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php @@ -49,7 +49,7 @@ final class SeparateFunctionsFromOOSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var array */ private $search = [ // Some tokens to help skip over structures we're not interested in. @@ -81,7 +81,8 @@ public function register() * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return void + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process(File $phpcsFile, $stackPtr) { diff --git a/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php b/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php index 5085ae87..7815e7e0 100644 --- a/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php +++ b/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php @@ -36,7 +36,7 @@ final class NoReservedKeywordParameterNamesSniff implements Sniff * * @since 1.0.0 * - * @var array string> Key is the lowercased keyword, value the "proper" cased keyword. + * @var array Key is the lowercased keyword, value the "proper" cased keyword. */ private $reservedNames = [ 'abstract' => 'abstract', diff --git a/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php b/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php index 278224b7..19e49717 100644 --- a/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php +++ b/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php @@ -39,7 +39,7 @@ final class DisallowLogicalAndOrSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var array */ private $metricType = [ \T_LOGICAL_AND => 'logical (and/or)', @@ -53,7 +53,7 @@ final class DisallowLogicalAndOrSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var array> */ private $targetTokenInfo = [ \T_LOGICAL_AND => [ diff --git a/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php b/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php index 23873470..b8538882 100644 --- a/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php +++ b/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php @@ -47,7 +47,7 @@ final class DisallowStandalonePostIncrementDecrementSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var array */ private $allowedTokens = [ \T_VARIABLE => \T_VARIABLE, @@ -84,7 +84,8 @@ public function register() * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return void + * @return int|void Integer stack pointer to skip forward or void to continue + * normal file processing. */ public function process(File $phpcsFile, $stackPtr) { diff --git a/Universal/Sniffs/Operators/StrictComparisonsSniff.php b/Universal/Sniffs/Operators/StrictComparisonsSniff.php index dcc27b70..c828df9e 100644 --- a/Universal/Sniffs/Operators/StrictComparisonsSniff.php +++ b/Universal/Sniffs/Operators/StrictComparisonsSniff.php @@ -38,7 +38,7 @@ final class StrictComparisonsSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var array */ private $metricType = [ \T_IS_EQUAL => 'loose', @@ -52,7 +52,7 @@ final class StrictComparisonsSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var array> */ private $targetTokenInfo = [ \T_IS_EQUAL => [ diff --git a/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php b/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php index f2cd7140..cbccb4c6 100644 --- a/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php +++ b/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php @@ -48,7 +48,7 @@ public function register() * @param int $stackPtr The position of the current token * in the stack passed in $tokens. * - * @return int Integer stack pointer to skip the rest of the file. + * @return void */ public function process(File $phpcsFile, $stackPtr) { diff --git a/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php b/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php index 534023d2..3dd47c03 100644 --- a/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php +++ b/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php @@ -50,7 +50,7 @@ final class KeywordSpacingSniff implements Sniff * * @since 1.1.0 * - * @var array(string => string) + * @var array */ protected $keywords = [ 'const' => true, diff --git a/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php b/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php index 69970f67..b9f87f24 100644 --- a/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php +++ b/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php @@ -40,7 +40,7 @@ final class LowercaseFunctionConstSniff implements Sniff * * @since 1.0.0 * - * @var array(string => string) + * @var array */ protected $keywords = [ 'const' => true, diff --git a/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php b/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php index 5627eb3d..817a44e1 100644 --- a/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php +++ b/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php @@ -56,7 +56,7 @@ final class DisallowInlineTabsSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var array */ private $find = [ \T_WHITESPACE => true, diff --git a/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php b/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php index c5f62620..af689684 100644 --- a/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php +++ b/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php @@ -42,7 +42,7 @@ final class PrecisionAlignmentSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var string[] */ public $supportedTokenizers = [ 'PHP', @@ -84,7 +84,7 @@ final class PrecisionAlignmentSniff implements Sniff * * @since 1.0.0 * - * @var array + * @var string[] */ public $ignoreAlignmentBefore = []; From 46d4a05f79506fd40768dffd469b37032574ed6d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 26 Aug 2023 06:12:42 +0200 Subject: [PATCH 14/15] Add PHPStan to QA checks PHPStan is a good addition to our QA toolkit and with improvements PHPStan has made over the years is now a viable tool for us to use (previously it would give way too many false positives). This commit: * Adds a separate job to the `basics` workflow in GH Actions. Notes: - I've **not** added PHPStan to the Composer dependencies for two reasons: 1. It doesn't allow for installation on PHP < 7.2, which would break/block the `composer install` for our test runs. 2. It would add dependencies which could conflict/cause problems for our test runs due to those defining token constants too. - [Phive](https://phar.io/) could potentially be used to still have a setup which can be used locally, but just running locally from a PHPStan PHAR file should work just fine. - For CI, PHPStan will be installed as a PHAR file by `setup-php` now. This does carry a risk _if_ PHPStan would make breaking changes or if a new release adds rules for the levels being scanned as, in that case, builds could unexpectedly start failing. Fixing the version for the `setup-php` action installs to the current release `1.10.32` could prevent that, but that adds an additional maintenance burden of having to keep updating the version as PHPStan releases pretty often. So, for now, I've elected to run the risk of random failures. If and when those start happening, this should be re-evaluated. - The PHP version for the CI run is set to PHP 7.4 to prevent PHPStan throwing some errors/notices related to the outdated PHPUnit version being used. * Adds a configuration file for PHPStan. Notes: - PHPStan needs to know about the dependencies (PHPCS et al), so I'm (re-)using the bootstrap file for the tests to load the PHPCS autoloader and register the standard with the PHPCS autoloader as adding an `autoload` directive to the `composer.json` file would cause problems with the PHPCS autoloader. - PHPStan flags type checks on properties with a documented type, while without `strict_types` we cannot always be sure the properties set will be of the correct type. For that reason, I've set `treatPhpDocTypesAsCertain` to `false` (which silences those notices). - I've gone through the scan results up to level 6 with a fine toothcomb and fixed what was reasonable to fix and ignored those things which should *not* be fixed. * Adds the configuration file to `.gitattributes` and the typical overload file for the configuration file to `.gitignore`. Refs: * https://phpstan.org/ * https://phpstan.org/config-reference --- .gitattributes | 1 + .github/workflows/basics.yml | 27 +++++++++++++++++++ .gitignore | 1 + phpstan.neon.dist | 52 ++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 phpstan.neon.dist diff --git a/.gitattributes b/.gitattributes index 09302194..cd97877c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12,6 +12,7 @@ .remarkrc export-ignore .yamllint.yml export-ignore phpcs.xml.dist export-ignore +phpstan.neon.dist export-ignore phpunit.xml.dist export-ignore phpunit-bootstrap.php export-ignore /.github/ export-ignore diff --git a/.github/workflows/basics.yml b/.github/workflows/basics.yml index 44b8614d..ec7d3420 100644 --- a/.github/workflows/basics.yml +++ b/.github/workflows/basics.yml @@ -95,6 +95,33 @@ jobs: - name: Check sniff feature completeness run: composer check-complete + phpstan: + name: "PHPStan" + runs-on: "ubuntu-latest" + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + coverage: none + tools: phpstan + + # Install dependencies and handle caching in one go. + # Dependencies need to be installed to make sure the PHPCS and PHPUnit classes are recognized. + # @link https://github.com/marketplace/actions/install-composer-dependencies + - name: Install Composer dependencies + uses: "ramsey/composer-install@v2" + with: + # Bust the cache at least once a month - output format: YYYY-MM. + custom-cache-suffix: $(date -u "+%Y-%m") + + - name: Run PHPStan + run: phpstan analyse + remark: name: 'QA Markdown' runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index de278d07..d6750447 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ vendor/ /phpcs.xml /phpunit.xml /.phpunit.result.cache +phpstan.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..ba322bbb --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,52 @@ +parameters: + #phpVersion: 50400 # Needs to be 70100 or higher... sigh... + level: 6 + paths: + - Modernize + - NormalizedArrays + - Universal + bootstrapFiles: + - phpunit-bootstrap.php + treatPhpDocTypesAsCertain: false + + ignoreErrors: + # Level 1 + # Keep to stay in line with parent class. + - + message: '`^Constructor of class PHPCSExtra\\Universal\\Helpers\\DummyTokenizer has an unused parameter \$content\.$`' + path: Universal\Helpers\DummyTokenizer.php + count: 1 + + # Level 4 + # PHPStan doesn't seem to like uninitialized properties... + - + message: '`^Property \S+Sniff::\$(phpVersion|tabWidth) \(int\) in isset\(\) is not nullable\.$`' + paths: + - Modernize\Sniffs\FunctionCalls\DirnameSniff.php + - Universal\Sniffs\Arrays\DuplicateArrayKeySniff.php + - Universal\Sniffs\CodeAnalysis\ConstructorDestructorReturnSniff.php + - Universal\Sniffs\WhiteSpace\CommaSpacingSniff.php + - Universal\Sniffs\WhiteSpace\DisallowInlineTabsSniff.php + - Universal\Sniffs\WhiteSpace\PrecisionAlignmentSniff.php + - + message: '`^Strict comparison using === between true and false will always evaluate to false\.$`' + paths: + - Modernize\Sniffs\FunctionCalls\DirnameSniff.php + - Universal\Sniffs\Arrays\DuplicateArrayKeySniff.php + - Universal\Sniffs\CodeAnalysis\ConstructorDestructorReturnSniff.php + - Universal\Sniffs\WhiteSpace\CommaSpacingSniff.php + - Universal\Sniffs\WhiteSpace\DisallowInlineTabsSniff.php + - Universal\Sniffs\WhiteSpace\PrecisionAlignmentSniff.php + - + message: '`^Property PHPCSExtra\\Universal\\Sniffs\\Arrays\\DuplicateArrayKeySniff\:\:\$currentMaxIntKey[GL]t8 \(int\) in isset\(\) is not nullable\.$`' + path: Universal\Sniffs\Arrays\DuplicateArrayKeySniff.php + count: 5 + - + message: '`^Result of && is always false\.$`' + path: Universal\Sniffs\Arrays\DuplicateArrayKeySniff.php + count: 1 + + # Level 5 + # We're not using strict types, so this will be juggled without any issues. + - '#^Parameter \#3 \$value of method \S+File::recordMetric\(\) expects string, \(?(float|int|bool)(<[^>]+>)?(\|(float|int|bool)(<[^>]+>)?)*\)? given\.$#' + - '#^Parameter \#2 \$content of method \S+Fixer::replaceToken\(\) expects string, \(?(float|int|bool)(<[^>]+>)?(\|(float|int|bool)(<[^>]+>)?)*\)? given\.$#' From 37bfe5e276862fc9858af6c242764f7c60fd282c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 26 Aug 2023 06:33:01 +0200 Subject: [PATCH 15/15] Changelog for PHPCSExtra 1.1.1 --- CHANGELOG.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e06a2e6..262b97d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,24 @@ This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/) and uses _Nothing yet._ +## [1.1.1] - 2023-08-26 + +### Changed + +#### Modernize + +* `Modernize.FunctionCalls.Dirname`: the sniff will now respect a potentially set [`php_version` configuration option][php_version-config] and only report on modernizations which are possible on the configured `php_version`. [#261] + If the `php_version` is not set, the sniff will continue to report on all modernization options. + +#### Other + +* Various documentation improvements. Props in part to [@szepeviktor]. +* Improved defensive coding in select places. +* Various housekeeping. + +[#261]: https://github.com/PHPCSStandards/PHPCSExtra/pull/261 + + ## [1.1.0] - 2023-07-19 ### Added @@ -488,6 +506,7 @@ This initial alpha release contains the following sniffs: [php_version-config]: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-php-version [Unreleased]: https://github.com/PHPCSStandards/PHPCSExtra/compare/stable...HEAD +[1.1.1]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.1.0...1.1.1 [1.1.0]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.4...1.1.0 [1.0.4]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.3...1.0.4 [1.0.3]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.2...1.0.3 @@ -498,6 +517,7 @@ This initial alpha release contains the following sniffs: [1.0.0-alpha3]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.0-alpha2...1.0.0-alpha3 [1.0.0-alpha2]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.0-alpha1...1.0.0-alpha2 -[@anomiex]: https://github.com/anomiex -[@derickr]: https://github.com/derickr -[@GaryJones]: https://github.com/GaryJones +[@anomiex]: https://github.com/anomiex +[@derickr]: https://github.com/derickr +[@GaryJones]: https://github.com/GaryJones +[@szepeviktor]: https://github.com/szepeviktor