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/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 diff --git a/Modernize/Sniffs/FunctionCalls/DirnameSniff.php b/Modernize/Sniffs/FunctionCalls/DirnameSniff.php index 63e9c680..b064b264 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,12 +26,21 @@ 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. * * @since 1.0.0 * - * @return int|string[] + * @return array */ public function register() { @@ -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') { @@ -125,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); @@ -182,6 +209,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; } @@ -218,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; @@ -320,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/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.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 @@ + + * @return array Key is the line number, value is the number of expected errors. */ - 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, + ]; + + case 'DirnameUnitTest.3.inc': + return [ + 10 => 1, + ]; + + case 'DirnameUnitTest.4.inc': + return [ + 9 => 1, + 10 => 1, + ]; + + default: + return []; + } } /** * 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/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/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..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, @@ -87,7 +87,7 @@ final class CommaAfterLastSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { 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/README.md b/README.md index 51c90888..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 @@ -220,16 +223,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 +422,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 +430,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. 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 @@ ]]> - + - + > */ protected function tokenize($string) { + return []; } /** 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/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/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 3273e228..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() { @@ -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 ) { diff --git a/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php b/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php index 1e1a3857..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. @@ -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..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. @@ -62,7 +62,7 @@ final class SeparateFunctionsFromOOSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { @@ -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/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 00384ac6..3b6ad982 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; /** @@ -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 b3200278..5348e707 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; /** @@ -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 b6676c26..78fa3261 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; /** @@ -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 c53cdf0b..65f3e589 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; /** @@ -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..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', @@ -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 33c9609c..4d765c2c 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; @@ -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 b654c280..19e49717 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. @@ -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 => [ @@ -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..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, @@ -58,7 +58,7 @@ final class DisallowStandalonePostIncrementDecrementSniff implements Sniff * * @since 1.0.0 * - * @return int[] + * @return array */ public function register() { @@ -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 c1fead35..c828df9e 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. @@ -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 => [ @@ -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 cfed01dc..440ecc86 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; @@ -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..cbccb4c6 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() { @@ -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/DisallowMixedGroupUseSniff.php b/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php index 3303eac1..2bb240df 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; @@ -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 3ac22c3b..8dcf8ddb 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; @@ -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 b0a69755..44388f6a 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; @@ -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 64aaa130..46a39edb 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; @@ -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 ffef7cb8..3dd47c03 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; @@ -50,7 +50,7 @@ final class KeywordSpacingSniff implements Sniff * * @since 1.1.0 * - * @var array(string => string) + * @var array */ protected $keywords = [ 'const' => true, @@ -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 6cfb8313..b9f87f24 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; @@ -40,7 +40,7 @@ final class LowercaseFunctionConstSniff implements Sniff * * @since 1.0.0 * - * @var array(string => string) + * @var array */ protected $keywords = [ 'const' => true, @@ -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 811210b8..1fccc828 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; @@ -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 ebf7fe27..6d699934 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; @@ -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 4cde4b26..31163165 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; @@ -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 29e5b335..376e9046 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; @@ -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 2deee1a8..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, @@ -70,7 +70,7 @@ final class DisallowInlineTabsSniff implements Sniff * * @since 1.0.0 * - * @return int[] + * @return array */ public function register() { @@ -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(); @@ -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 diff --git a/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php b/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php index c4f970f9..af689684 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; @@ -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 = []; @@ -134,7 +134,7 @@ final class PrecisionAlignmentSniff implements Sniff * * @since 1.0.0 * - * @return array + * @return array */ public function register() { @@ -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 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.inc b/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.inc index 9c8215e5..ec81ec29 100644 --- a/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.inc +++ b/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.inc @@ -26,11 +26,11 @@ trait UseContextUnknown { } } -final class ClosuresAreNotTargettedByThisSniff { +final class ClosuresAreNotTargetedByThisSniff { public static $className = 'Bar'; public function foobar() { $closure = static function(): static { - // Returns new instance of Closure, not of ClosuresAreNotTargettedByThisSniff. + // Returns new instance of Closure, not of ClosuresAreNotTargetedByThisSniff. // Still unnecessary, but not the target of this sniff. // Should possibly get its own sniff. return new static(); @@ -97,7 +97,7 @@ class ValidUseOfStaticInConcrete extends Foo } interface NeverFinal { - public function typedMethod(): static|ArrrayAccess; + public function typedMethod(): static|ArrayAccess; } @@ -156,7 +156,7 @@ class NonFinalClassWithNesting { } enum FinalByDesign { - public function typedMethod(): static|ArrrayAccess { + public function typedMethod(): static|ArrayAccess { $var = static::functionCall(); $var = static::class; diff --git a/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.inc.fixed b/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.inc.fixed index dd279c33..37a46cce 100644 --- a/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.inc.fixed +++ b/Universal/Tests/CodeAnalysis/StaticInFinalClassUnitTest.inc.fixed @@ -26,11 +26,11 @@ trait UseContextUnknown { } } -final class ClosuresAreNotTargettedByThisSniff { +final class ClosuresAreNotTargetedByThisSniff { public static $className = 'Bar'; public function foobar() { $closure = static function(): static { - // Returns new instance of Closure, not of ClosuresAreNotTargettedByThisSniff. + // Returns new instance of Closure, not of ClosuresAreNotTargetedByThisSniff. // Still unnecessary, but not the target of this sniff. // Should possibly get its own sniff. return new static(); @@ -97,7 +97,7 @@ class ValidUseOfStaticInConcrete extends Foo } interface NeverFinal { - public function typedMethod(): static|ArrrayAccess; + public function typedMethod(): static|ArrayAccess; } @@ -156,7 +156,7 @@ class NonFinalClassWithNesting { } enum FinalByDesign { - public function typedMethod(): self|ArrrayAccess { + public function typedMethod(): self|ArrayAccess { $var = self::functionCall(); $var = self::class; 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 = '') { 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\.$#'