diff --git a/MO4/Sniffs/Arrays/ArrayDoubleArrowAlignmentSniff.php b/MO4/Sniffs/Arrays/ArrayDoubleArrowAlignmentSniff.php index d4ee76b0..839d6e04 100644 --- a/MO4/Sniffs/Arrays/ArrayDoubleArrowAlignmentSniff.php +++ b/MO4/Sniffs/Arrays/ArrayDoubleArrowAlignmentSniff.php @@ -96,7 +96,7 @@ public function process(File $phpcsFile, $stackPtr): void $previous = $tokens[($i - 1)]; // Skip nested arrays. - if (true === \in_array($current['code'], $this->arrayTokens, true)) { + if (\in_array($current['code'], $this->arrayTokens, true)) { $i = T_ARRAY === $current['code'] ? ($current['parenthesis_closer'] + 1) : ($current['bracket_closer'] + 1); continue; @@ -145,7 +145,7 @@ public function process(File $phpcsFile, $stackPtr): void $j = ($i - 1); while (($j >= 0) && ($tokens[$j]['line'] === $current['line'])) { - if (false === \in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$emptyTokens, true)) { + if (!\in_array($tokens[$j]['code'], PHP_CodeSniffer_Tokens::$emptyTokens, true)) { $hasKeyInLine = true; } diff --git a/MO4/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php b/MO4/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php index 86f00e2f..02b4ff9a 100644 --- a/MO4/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php +++ b/MO4/Sniffs/Formatting/AlphabeticalUseStatementsSniff.php @@ -89,7 +89,7 @@ class AlphabeticalUseStatementsSniff extends UseDeclarationSniff */ public function process(File $phpcsFile, $stackPtr): void { - if (false === \in_array($this->order, self::SUPPORTED_ORDERING_METHODS, true)) { + if (!\in_array($this->order, self::SUPPORTED_ORDERING_METHODS, true)) { $error = \sprintf( "'%s' is not a valid order function for %s! Pick one of: %s", $this->order, diff --git a/MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php b/MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php index 28860e98..0f3ccb30 100644 --- a/MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php +++ b/MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php @@ -125,7 +125,7 @@ public function process(File $phpcsFile, $stackPtr): void foreach ($tokens[$nsSep]['comment_tags'] as $tag) { $content = $tokens[$tag]['content']; - if (false === \array_key_exists($content, $docCommentTags)) { + if (!\array_key_exists($content, $docCommentTags)) { continue; } @@ -179,7 +179,7 @@ public function process(File $phpcsFile, $stackPtr): void // phpcs:enable foreach ($typeTokens as $typeToken) { - if (true === \in_array($typeToken, $useStatements, true)) { + if (\in_array($typeToken, $useStatements, true)) { continue; } @@ -341,7 +341,7 @@ private function checkShorthandPossible(File $phpcsFile, array $useStatements, s $fullClassName = $this->getFullyQualifiedClassName($className); - if (true === \array_key_exists($fullClassName, $useStatements)) { + if (\array_key_exists($fullClassName, $useStatements)) { $replacement = $useStatements[$fullClassName]; $data = [ diff --git a/composer.json b/composer.json index 475b6a22..7fa6848b 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,8 @@ "require-dev": { "ergebnis/composer-normalize": ">=2.19 <2.30", "phan/phan": "^5.4.2", - "phpstan/phpstan": "^1.0", - "phpstan/phpstan-strict-rules": "^1.0", + "phpstan/phpstan": "^1.12", + "phpstan/phpstan-strict-rules": "^1.6", "phpunit/phpunit": "^7.5.20 || ^8.5.36 || ^9.6.15", "psalm/plugin-phpunit": "^0.18", "vimeo/psalm": "^4.30" diff --git a/phpstan.neon b/phpstan.neon index 603b51ee..bab22017 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,10 +1,11 @@ parameters: level: max bootstrapFiles: - - %rootDir%/../../../tests/bootstrap.php + - %rootDir%/../../../tests/static_analysis_bootstrap.php paths: - %rootDir%/../../../MO4 - %rootDir%/../../../tests - checkMissingIterableValueType: false + ignoreErrors: + - identifier: missingType.iterableValue includes: - vendor/phpstan/phpstan-strict-rules/rules.neon diff --git a/psalm.xml b/psalm.xml index f4813e50..ab2a6a33 100644 --- a/psalm.xml +++ b/psalm.xml @@ -4,7 +4,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" - autoloader="tests/bootstrap.php" + autoloader="tests/static_analysis_bootstrap.php" > diff --git a/tests/static_analysis_bootstrap.php b/tests/static_analysis_bootstrap.php new file mode 100644 index 00000000..5953ddf3 --- /dev/null +++ b/tests/static_analysis_bootstrap.php @@ -0,0 +1,18 @@ + + * + * @license http://spdx.org/licenses/MIT MIT License + * + * @link https://github.com/mayflower/mo4-coding-standard + */ + +declare(strict_types=1); + +require_once __DIR__.'/../vendor/squizlabs/php_codesniffer/autoload.php'; +require_once __DIR__.'/../vendor/squizlabs/php_codesniffer/src/Util/Tokens.php';