Skip to content

Commit

Permalink
Merge pull request #79 from sasezaki/strict-rules
Browse files Browse the repository at this point in the history
Use phpstan-strict-rules
  • Loading branch information
sasezaki committed Feb 10, 2024
2 parents 29ef15c + 507befd commit ab70ce5
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions composer-require-checker.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"PhpParser\\Node\\Scalar\\String_",
"PHPStan\\Analyser\\Scope",
"PHPStan\\Rules\\Rule",
"PHPStan\\Rules\\RuleError",
"PHPStan\\Rules\\RuleErrorBuilder",
"PHPStan\\Type\\ArrayType",
"PHPStan\\Type\\Constant\\ConstantStringType",
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"laminas/laminas-coding-standard": "^2.0.0",
"maglnet/composer-require-checker": "^2|^3|^4",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "^8.5.31 || ^9.5.10",
"roave/security-advisories": "dev-master",
"squizlabs/php_codesniffer": "^3.7",
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
2 changes: 1 addition & 1 deletion src/Rules/ContextKeyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function processNode(Node $node, Scope $scope): array

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

if ($methodName !== 'log' && ! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS)) {
if ($methodName !== 'log' && ! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS, true)) {
// @codeCoverageIgnoreStart
return []; // @codeCoverageIgnoreEnd
}
Expand Down
2 changes: 1 addition & 1 deletion src/Rules/ContextRequireExceptionKeyRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function processNode(Node $node, Scope $scope): array
}

$contextArgumentNo = 2;
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS)) {
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS, true)) {
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Rules/MessageStaticStringRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function processNode(Node $node, Scope $scope): array
}

$messageArgumentNo = 1;
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS)) {
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS, true)) {
// @codeCoverageIgnoreStart
return []; // @codeCoverageIgnoreEnd
}
Expand Down
6 changes: 3 additions & 3 deletions src/Rules/PlaceholderCharactersRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function processNode(Node $node, Scope $scope): array
}

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

$doubleBraceError = self::checkDoubleBrace($message, $methodName);
if ($doubleBraceError) {
if ($doubleBraceError instanceof RuleError) {
$errors[] = $doubleBraceError;
continue;
}

$invalidCharError = self::checkInvalidChar($message, $methodName);
if ($invalidCharError) {
if ($invalidCharError instanceof RuleError) {
$errors[] = $invalidCharError;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Rules/PlaceholderCorrespondToKeysRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function processNode(Node $node, Scope $scope): array
}

$contextArgumentNo = 2;
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS)) {
} elseif (! in_array($methodName, LogLevelListInterface::LOGGER_LEVEL_METHODS, true)) {
// @codeCoverageIgnoreStart
return []; // @codeCoverageIgnoreEnd
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public function processNode(Node $node, Scope $scope): array
$context = $args[$contextArgumentNo];

$doesNohHaveError = self::contextDoesNotHavePlaceholderKey($scope->getType($context->value), $methodName, $matches[0], $matches[1]);
if ($doesNohHaveError) {
if ($doesNohHaveError instanceof RuleError) {
$errors[] = $doesNohHaveError;
}
}
Expand Down

0 comments on commit ab70ce5

Please sign in to comment.