Skip to content

Commit ab70ce5

Browse files
authored
Merge pull request #79 from sasezaki/strict-rules
Use phpstan-strict-rules
2 parents 29ef15c + 507befd commit ab70ce5

8 files changed

+11
-8
lines changed

composer-require-checker.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"PhpParser\\Node\\Scalar\\String_",
1313
"PHPStan\\Analyser\\Scope",
1414
"PHPStan\\Rules\\Rule",
15+
"PHPStan\\Rules\\RuleError",
1516
"PHPStan\\Rules\\RuleErrorBuilder",
1617
"PHPStan\\Type\\ArrayType",
1718
"PHPStan\\Type\\Constant\\ConstantStringType",

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"laminas/laminas-coding-standard": "^2.0.0",
1616
"maglnet/composer-require-checker": "^2|^3|^4",
1717
"phpstan/phpstan-phpunit": "^1.3",
18+
"phpstan/phpstan-strict-rules": "^1.5",
1819
"phpunit/phpunit": "^8.5.31 || ^9.5.10",
1920
"roave/security-advisories": "dev-master",
2021
"squizlabs/php_codesniffer": "^3.7",

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ includes:
1010
- phar://phpstan.phar/conf/bleedingEdge.neon
1111
- vendor/phpstan/phpstan-phpunit/extension.neon
1212
- vendor/phpstan/phpstan-phpunit/rules.neon
13+
- vendor/phpstan/phpstan-strict-rules/rules.neon

src/Rules/ContextKeyRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function processNode(Node $node, Scope $scope): array
6666

6767
$methodName = $node->name->toLowerString();
6868

69-
if ($methodName !== 'log' && ! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS)) {
69+
if ($methodName !== 'log' && ! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS, true)) {
7070
// @codeCoverageIgnoreStart
7171
return []; // @codeCoverageIgnoreEnd
7272
}

src/Rules/ContextRequireExceptionKeyRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function processNode(Node $node, Scope $scope): array
9393
}
9494

9595
$contextArgumentNo = 2;
96-
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS)) {
96+
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS, true)) {
9797
return [];
9898
}
9999

src/Rules/MessageStaticStringRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function processNode(Node $node, Scope $scope): array
6363
}
6464

6565
$messageArgumentNo = 1;
66-
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS)) {
66+
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS, true)) {
6767
// @codeCoverageIgnoreStart
6868
return []; // @codeCoverageIgnoreEnd
6969
}

src/Rules/PlaceholderCharactersRule.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function processNode(Node $node, Scope $scope): array
6868
}
6969

7070
$messageArgumentNo = 1;
71-
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS)) {
71+
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS, true)) {
7272
// @codeCoverageIgnoreStart
7373
return []; // @codeCoverageIgnoreEnd
7474
}
@@ -86,13 +86,13 @@ public function processNode(Node $node, Scope $scope): array
8686
$message = $constantStringType->getValue();
8787

8888
$doubleBraceError = self::checkDoubleBrace($message, $methodName);
89-
if ($doubleBraceError) {
89+
if ($doubleBraceError instanceof RuleError) {
9090
$errors[] = $doubleBraceError;
9191
continue;
9292
}
9393

9494
$invalidCharError = self::checkInvalidChar($message, $methodName);
95-
if ($invalidCharError) {
95+
if ($invalidCharError instanceof RuleError) {
9696
$errors[] = $invalidCharError;
9797
}
9898
}

src/Rules/PlaceholderCorrespondToKeysRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function processNode(Node $node, Scope $scope): array
6666
}
6767

6868
$contextArgumentNo = 2;
69-
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS)) {
69+
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS, true)) {
7070
// @codeCoverageIgnoreStart
7171
return []; // @codeCoverageIgnoreEnd
7272
}
@@ -99,7 +99,7 @@ public function processNode(Node $node, Scope $scope): array
9999
$context = $args[$contextArgumentNo];
100100

101101
$doesNohHaveError = self::contextDoesNotHavePlaceholderKey($scope->getType($context->value), $methodName, $matches[0], $matches[1]);
102-
if ($doesNohHaveError) {
102+
if ($doesNohHaveError instanceof RuleError) {
103103
$errors[] = $doesNohHaveError;
104104
}
105105
}

0 commit comments

Comments
 (0)