diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 9ebc98502..0cc08a99d 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -12,6 +12,8 @@ includes: rules: - pocketmine\phpstan\rules\DisallowEnumComparisonRule + - pocketmine\phpstan\rules\DisallowLogicalAndOperatorRule + - pocketmine\phpstan\rules\DisallowLogicalOrOperatorRule - pocketmine\phpstan\rules\UnsafeForeachArrayOfStringRule # - pocketmine\phpstan\rules\ThreadedSupportedTypesRule diff --git a/tests/phpstan/rules/DisallowLogicalAndOperatorRule.php b/tests/phpstan/rules/DisallowLogicalAndOperatorRule.php new file mode 100644 index 000000000..49e6bbcc4 --- /dev/null +++ b/tests/phpstan/rules/DisallowLogicalAndOperatorRule.php @@ -0,0 +1,44 @@ + + */ +final class DisallowLogicalAndOperatorRule implements Rule{ + + public function getNodeType() : string{ + return LogicalAnd::class; + } + + public function processNode(Node $node, Scope $scope) : array{ + return [RuleErrorBuilder::message('Use of the "and" operator is discouraged. Use && instead.')->build()]; + } +} diff --git a/tests/phpstan/rules/DisallowLogicalOrOperatorRule.php b/tests/phpstan/rules/DisallowLogicalOrOperatorRule.php new file mode 100644 index 000000000..7aa43c706 --- /dev/null +++ b/tests/phpstan/rules/DisallowLogicalOrOperatorRule.php @@ -0,0 +1,44 @@ + + */ +final class DisallowLogicalOrOperatorRule implements Rule{ + + public function getNodeType() : string{ + return LogicalOr::class; + } + + public function processNode(Node $node, Scope $scope) : array{ + return [RuleErrorBuilder::message('Use of the "or" operator is discouraged. Use || instead.')->build()]; + } +}