diff --git a/src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php b/src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php index 1e3309a5..a266d851 100644 --- a/src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php +++ b/src/Rules/BooleansInConditions/BooleanInBooleanAndRule.php @@ -38,7 +38,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only booleans are allowed in &&, %s given on the left side.', $leftType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('booleanAnd.leftNotBoolean')->build(); } $rightScope = $node->getRightScope(); @@ -47,7 +47,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only booleans are allowed in &&, %s given on the right side.', $rightType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('booleanAnd.rightNotBoolean')->build(); } return $messages; diff --git a/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php b/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php index 9d8a592d..6fcdd06c 100644 --- a/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php +++ b/src/Rules/BooleansInConditions/BooleanInBooleanNotRule.php @@ -41,7 +41,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Only booleans are allowed in a negated boolean, %s given.', $expressionType->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('booleanNot.exprNotBoolean')->build(), ]; } diff --git a/src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php b/src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php index c98da42c..144bda22 100644 --- a/src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php +++ b/src/Rules/BooleansInConditions/BooleanInBooleanOrRule.php @@ -38,7 +38,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only booleans are allowed in ||, %s given on the left side.', $leftType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('booleanOr.leftNotBoolean')->build(); } $rightScope = $node->getRightScope(); @@ -47,7 +47,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only booleans are allowed in ||, %s given on the right side.', $rightType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('booleanOr.rightNotBoolean')->build(); } return $messages; diff --git a/src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php b/src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php index ae94956e..2501b828 100644 --- a/src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php +++ b/src/Rules/BooleansInConditions/BooleanInElseIfConditionRule.php @@ -41,7 +41,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Only booleans are allowed in an elseif condition, %s given.', $conditionExpressionType->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('elseif.condNotBoolean')->build(), ]; } diff --git a/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php b/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php index fe858f92..5adb10ed 100644 --- a/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php +++ b/src/Rules/BooleansInConditions/BooleanInIfConditionRule.php @@ -41,7 +41,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Only booleans are allowed in an if condition, %s given.', $conditionExpressionType->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('if.condNotBoolean')->build(), ]; } diff --git a/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php b/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php index 5c04c283..e1ac9ccb 100644 --- a/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php +++ b/src/Rules/BooleansInConditions/BooleanInTernaryOperatorRule.php @@ -45,7 +45,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Only booleans are allowed in a ternary operator condition, %s given.', $conditionExpressionType->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('ternary.condNotBoolean')->build(), ]; } diff --git a/src/Rules/Cast/UselessCastRule.php b/src/Rules/Cast/UselessCastRule.php index 1bb526f0..adc20e14 100644 --- a/src/Rules/Cast/UselessCastRule.php +++ b/src/Rules/Cast/UselessCastRule.php @@ -62,7 +62,7 @@ public function processNode(Node $node, Scope $scope): array 'Casting to %s something that\'s already %s.', $castType->describe(VerbosityLevel::typeOnly()), $expressionType->describe(VerbosityLevel::typeOnly()) - )))->build(), + )))->identifier('cast.useless')->build(), ]; } diff --git a/src/Rules/Classes/RequireParentConstructCallRule.php b/src/Rules/Classes/RequireParentConstructCallRule.php index b533fe53..76d3d16c 100644 --- a/src/Rules/Classes/RequireParentConstructCallRule.php +++ b/src/Rules/Classes/RequireParentConstructCallRule.php @@ -60,7 +60,7 @@ public function processNode(Node $node, Scope $scope): array '%s::__construct() does not call parent constructor from %s.', $classReflection->getName(), $parentClass->getName() - ))->build(), + ))->identifier('constructor.missingParentCall')->build(), ]; } diff --git a/src/Rules/DisallowedConstructs/DisallowedBacktickRule.php b/src/Rules/DisallowedConstructs/DisallowedBacktickRule.php index d2b4bc66..76e401ce 100644 --- a/src/Rules/DisallowedConstructs/DisallowedBacktickRule.php +++ b/src/Rules/DisallowedConstructs/DisallowedBacktickRule.php @@ -23,6 +23,7 @@ public function processNode(Node $node, Scope $scope): array { return [ RuleErrorBuilder::message('Backtick operator is not allowed. Use shell_exec() instead.') + ->identifier('backtick.notAllowed') ->build(), ]; } diff --git a/src/Rules/DisallowedConstructs/DisallowedEmptyRule.php b/src/Rules/DisallowedConstructs/DisallowedEmptyRule.php index 4e0be7b2..d19f5ea2 100644 --- a/src/Rules/DisallowedConstructs/DisallowedEmptyRule.php +++ b/src/Rules/DisallowedConstructs/DisallowedEmptyRule.php @@ -23,6 +23,7 @@ public function processNode(Node $node, Scope $scope): array { return [ RuleErrorBuilder::message('Construct empty() is not allowed. Use more strict comparison.') + ->identifier('empty.notAllowed') ->build(), ]; } diff --git a/src/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRule.php b/src/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRule.php index f775dc47..cee777ce 100644 --- a/src/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRule.php +++ b/src/Rules/DisallowedConstructs/DisallowedImplicitArrayCreationRule.php @@ -46,6 +46,7 @@ public function processNode(Node $node, Scope $scope): array if ($certainty->no()) { return [ RuleErrorBuilder::message(sprintf('Implicit array creation is not allowed - variable $%s does not exist.', $node->name)) + ->identifier('variable.implicitArray') ->build(), ]; } @@ -53,6 +54,7 @@ public function processNode(Node $node, Scope $scope): array if ($certainty->maybe()) { return [ RuleErrorBuilder::message(sprintf('Implicit array creation is not allowed - variable $%s might not exist.', $node->name)) + ->identifier('variable.implicitArray') ->build(), ]; } diff --git a/src/Rules/DisallowedConstructs/DisallowedLooseComparisonRule.php b/src/Rules/DisallowedConstructs/DisallowedLooseComparisonRule.php index a1425c76..9b709be9 100644 --- a/src/Rules/DisallowedConstructs/DisallowedLooseComparisonRule.php +++ b/src/Rules/DisallowedConstructs/DisallowedLooseComparisonRule.php @@ -27,14 +27,18 @@ public function processNode(Node $node, Scope $scope): array return [ RuleErrorBuilder::message( 'Loose comparison via "==" is not allowed.' - )->tip('Use strict comparison via "===" instead.')->build(), + )->tip('Use strict comparison via "===" instead.') + ->identifier('equal.notAllowed') + ->build(), ]; } if ($node instanceof NotEqual) { return [ RuleErrorBuilder::message( 'Loose comparison via "!=" is not allowed.' - )->tip('Use strict comparison via "!==" instead.')->build(), + )->tip('Use strict comparison via "!==" instead.') + ->identifier('notEqual.notAllowed') + ->build(), ]; } diff --git a/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php b/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php index 349f6ca2..fac42790 100644 --- a/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php +++ b/src/Rules/DisallowedConstructs/DisallowedShortTernaryRule.php @@ -27,6 +27,7 @@ public function processNode(Node $node, Scope $scope): array return [ RuleErrorBuilder::message('Short ternary operator is not allowed. Use null coalesce operator if applicable or consider using long ternary.') + ->identifier('ternary.shortNotAllowed') ->build(), ]; } diff --git a/src/Rules/ForLoop/OverwriteVariablesWithForLoopInitRule.php b/src/Rules/ForLoop/OverwriteVariablesWithForLoopInitRule.php index 89861a99..f710474e 100644 --- a/src/Rules/ForLoop/OverwriteVariablesWithForLoopInitRule.php +++ b/src/Rules/ForLoop/OverwriteVariablesWithForLoopInitRule.php @@ -7,8 +7,8 @@ use PhpParser\Node\Expr\Assign; use PhpParser\Node\Stmt\For_; use PHPStan\Analyser\Scope; +use PHPStan\Rules\IdentifierRuleError; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; use PHPStan\Rules\RuleErrorBuilder; use function is_string; use function sprintf; @@ -41,7 +41,7 @@ public function processNode(Node $node, Scope $scope): array } /** - * @return list + * @return list */ private function checkValueVar(Scope $scope, Expr $expr): array { @@ -52,6 +52,7 @@ private function checkValueVar(Scope $scope, Expr $expr): array && $scope->hasVariableType($expr->name)->yes() ) { $errors[] = RuleErrorBuilder::message(sprintf('For loop initial assignment overwrites variable $%s.', $expr->name)) + ->identifier('for.variableOverwrite') ->build(); } diff --git a/src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php b/src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php index e3932121..0cf620c3 100644 --- a/src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php +++ b/src/Rules/ForeachLoop/OverwriteVariablesWithForeachRule.php @@ -6,6 +6,7 @@ use PhpParser\Node\Expr; use PhpParser\Node\Stmt\Foreach_; use PHPStan\Analyser\Scope; +use PHPStan\Rules\IdentifierRuleError; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use function is_string; @@ -31,6 +32,7 @@ public function processNode(Node $node, Scope $scope): array && $scope->hasVariableType($node->keyVar->name)->yes() ) { $errors[] = RuleErrorBuilder::message(sprintf('Foreach overwrites $%s with its key variable.', $node->keyVar->name)) + ->identifier('foreach.keyOverwrite') ->build(); } @@ -42,7 +44,7 @@ public function processNode(Node $node, Scope $scope): array } /** - * @return string[] + * @return list */ private function checkValueVar(Scope $scope, Expr $expr): array { @@ -53,6 +55,7 @@ private function checkValueVar(Scope $scope, Expr $expr): array && $scope->hasVariableType($expr->name)->yes() ) { $errors[] = RuleErrorBuilder::message(sprintf('Foreach overwrites $%s with its value variable.', $expr->name)) + ->identifier('foreach.valueOverwrite') ->build(); } diff --git a/src/Rules/Functions/ClosureUsesThisRule.php b/src/Rules/Functions/ClosureUsesThisRule.php index fbce62f9..d2cb4a45 100644 --- a/src/Rules/Functions/ClosureUsesThisRule.php +++ b/src/Rules/Functions/ClosureUsesThisRule.php @@ -43,6 +43,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf('Anonymous function uses $this assigned to variable $%s. Use $this directly in the function body.', $closureUse->var->name)) ->line($closureUse->getLine()) + ->identifier('closure.useThis') ->build(); } return $messages; diff --git a/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php b/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php index bb8fc5cc..1cca26ed 100644 --- a/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php +++ b/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php @@ -6,8 +6,8 @@ use PHPStan\Analyser\Scope; use PHPStan\Node\InClassMethodNode; use PHPStan\Reflection\ClassReflection; +use PHPStan\Rules\IdentifierRuleError; use PHPStan\Rules\Rule; -use PHPStan\Rules\RuleError; use PHPStan\Rules\RuleErrorBuilder; use function sprintf; @@ -62,7 +62,7 @@ private function findMethod( ClassReflection $declaringClass, ClassReflection $classReflection, string $methodName - ): ?RuleError + ): ?IdentifierRuleError { if (!$classReflection->hasNativeMethod($methodName)) { return null; @@ -80,7 +80,7 @@ private function findMethod( $classReflection->isInterface() ? 'interface' : 'parent', $classReflection->getDisplayName(), $parentMethod->getName() - ))->build(); + ))->identifier('method.nameCase')->build(); } } diff --git a/src/Rules/Operators/OperandInArithmeticIncrementOrDecrementRule.php b/src/Rules/Operators/OperandInArithmeticIncrementOrDecrementRule.php index 56b590d9..af82a08c 100644 --- a/src/Rules/Operators/OperandInArithmeticIncrementOrDecrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticIncrementOrDecrementRule.php @@ -46,7 +46,7 @@ public function processNode(Node $node, Scope $scope): array 'Only numeric types are allowed in %s, %s given.', $this->describeOperation(), $varType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier(sprintf('%s.nonNumeric', $this->getIdentifier()))->build(); } return $messages; @@ -54,4 +54,9 @@ public function processNode(Node $node, Scope $scope): array abstract protected function describeOperation(): string; + /** + * @return 'preInc'|'postInc'|'preDec'|'postDec' + */ + abstract protected function getIdentifier(): string; + } diff --git a/src/Rules/Operators/OperandInArithmeticPostDecrementRule.php b/src/Rules/Operators/OperandInArithmeticPostDecrementRule.php index 88298ec9..d0e08099 100644 --- a/src/Rules/Operators/OperandInArithmeticPostDecrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticPostDecrementRule.php @@ -20,4 +20,9 @@ protected function describeOperation(): string return 'post-decrement'; } + protected function getIdentifier(): string + { + return 'postDec'; + } + } diff --git a/src/Rules/Operators/OperandInArithmeticPostIncrementRule.php b/src/Rules/Operators/OperandInArithmeticPostIncrementRule.php index e9367dcb..400d8288 100644 --- a/src/Rules/Operators/OperandInArithmeticPostIncrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticPostIncrementRule.php @@ -20,4 +20,9 @@ protected function describeOperation(): string return 'post-increment'; } + protected function getIdentifier(): string + { + return 'postInc'; + } + } diff --git a/src/Rules/Operators/OperandInArithmeticPreDecrementRule.php b/src/Rules/Operators/OperandInArithmeticPreDecrementRule.php index 643f8d31..9d583560 100644 --- a/src/Rules/Operators/OperandInArithmeticPreDecrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticPreDecrementRule.php @@ -20,4 +20,9 @@ protected function describeOperation(): string return 'pre-decrement'; } + protected function getIdentifier(): string + { + return 'preDec'; + } + } diff --git a/src/Rules/Operators/OperandInArithmeticPreIncrementRule.php b/src/Rules/Operators/OperandInArithmeticPreIncrementRule.php index 3ad29af7..d5d81f2a 100644 --- a/src/Rules/Operators/OperandInArithmeticPreIncrementRule.php +++ b/src/Rules/Operators/OperandInArithmeticPreIncrementRule.php @@ -20,4 +20,9 @@ protected function describeOperation(): string return 'pre-increment'; } + protected function getIdentifier(): string + { + return 'preInc'; + } + } diff --git a/src/Rules/Operators/OperandsInArithmeticAdditionRule.php b/src/Rules/Operators/OperandsInArithmeticAdditionRule.php index 2dbf3efc..246b609d 100644 --- a/src/Rules/Operators/OperandsInArithmeticAdditionRule.php +++ b/src/Rules/Operators/OperandsInArithmeticAdditionRule.php @@ -59,13 +59,13 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in +, %s given on the left side.', $leftType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('plus.leftNonNumeric')->build(); } if (!$this->helper->isValidForArithmeticOperation($scope, $right)) { $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in +, %s given on the right side.', $rightType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('plus.rightNonNumeric')->build(); } return $messages; diff --git a/src/Rules/Operators/OperandsInArithmeticDivisionRule.php b/src/Rules/Operators/OperandsInArithmeticDivisionRule.php index 423455f3..8a146ded 100644 --- a/src/Rules/Operators/OperandsInArithmeticDivisionRule.php +++ b/src/Rules/Operators/OperandsInArithmeticDivisionRule.php @@ -53,7 +53,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in /, %s given on the left side.', $leftType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('div.leftNonNumeric')->build(); } $rightType = $scope->getType($right); @@ -61,7 +61,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in /, %s given on the right side.', $rightType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('div.rightNonNumeric')->build(); } return $messages; diff --git a/src/Rules/Operators/OperandsInArithmeticExponentiationRule.php b/src/Rules/Operators/OperandsInArithmeticExponentiationRule.php index b2b67f3d..fe809ef7 100644 --- a/src/Rules/Operators/OperandsInArithmeticExponentiationRule.php +++ b/src/Rules/Operators/OperandsInArithmeticExponentiationRule.php @@ -53,7 +53,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in **, %s given on the left side.', $leftType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('pow.leftNonNumeric')->build(); } $rightType = $scope->getType($right); @@ -61,7 +61,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in **, %s given on the right side.', $rightType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('pow.rightNonNumeric')->build(); } return $messages; diff --git a/src/Rules/Operators/OperandsInArithmeticModuloRule.php b/src/Rules/Operators/OperandsInArithmeticModuloRule.php index 1932945d..4aad3661 100644 --- a/src/Rules/Operators/OperandsInArithmeticModuloRule.php +++ b/src/Rules/Operators/OperandsInArithmeticModuloRule.php @@ -53,7 +53,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in %%, %s given on the left side.', $leftType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('mod.leftNonNumeric')->build(); } $rightType = $scope->getType($right); @@ -61,7 +61,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in %%, %s given on the right side.', $rightType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('mod.rightNonNumeric')->build(); } return $messages; diff --git a/src/Rules/Operators/OperandsInArithmeticMultiplicationRule.php b/src/Rules/Operators/OperandsInArithmeticMultiplicationRule.php index 1c99f70f..f662bdce 100644 --- a/src/Rules/Operators/OperandsInArithmeticMultiplicationRule.php +++ b/src/Rules/Operators/OperandsInArithmeticMultiplicationRule.php @@ -53,7 +53,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in *, %s given on the left side.', $leftType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('mul.leftNonNumeric')->build(); } $rightType = $scope->getType($right); @@ -61,7 +61,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in *, %s given on the right side.', $rightType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('mul.rightNonNumeric')->build(); } return $messages; diff --git a/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php b/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php index 4ac61d53..9bec287d 100644 --- a/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php +++ b/src/Rules/Operators/OperandsInArithmeticSubtractionRule.php @@ -53,7 +53,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in -, %s given on the left side.', $leftType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('minus.leftNonNumeric')->build(); } $rightType = $scope->getType($right); @@ -61,7 +61,7 @@ public function processNode(Node $node, Scope $scope): array $messages[] = RuleErrorBuilder::message(sprintf( 'Only numeric types are allowed in -, %s given on the right side.', $rightType->describe(VerbosityLevel::typeOnly()) - ))->build(); + ))->identifier('minus.rightNonNumeric')->build(); } return $messages; diff --git a/src/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRule.php b/src/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRule.php index 73ea10a4..d14b5678 100644 --- a/src/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRule.php +++ b/src/Rules/StrictCalls/DynamicCallOnStaticMethodsCallableRule.php @@ -58,7 +58,7 @@ static function (Type $type) use ($name): bool { 'Dynamic call to static method %s::%s().', $methodReflection->getDeclaringClass()->getDisplayName(), $methodReflection->getName() - ))->build(), + ))->identifier('staticMethod.dynamicCall')->build(), ]; } diff --git a/src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php b/src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php index 269f6132..44b180c0 100644 --- a/src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php +++ b/src/Rules/StrictCalls/DynamicCallOnStaticMethodsRule.php @@ -69,7 +69,7 @@ static function (Type $type) use ($name): bool { 'Dynamic call to static method %s::%s().', $methodReflection->getDeclaringClass()->getDisplayName(), $methodReflection->getName() - ))->build(), + ))->identifier('staticMethod.dynamicCall')->build(), ]; } diff --git a/src/Rules/StrictCalls/StrictFunctionCallsRule.php b/src/Rules/StrictCalls/StrictFunctionCallsRule.php index 04508699..2b6cd899 100644 --- a/src/Rules/StrictCalls/StrictFunctionCallsRule.php +++ b/src/Rules/StrictCalls/StrictFunctionCallsRule.php @@ -67,7 +67,7 @@ public function processNode(Node $node, Scope $scope): array 'Call to function %s() requires parameter #%d to be set.', $functionName, $argumentPosition + 1 - ))->build(), + ))->identifier('function.strict')->build(), ]; } @@ -79,7 +79,7 @@ public function processNode(Node $node, Scope $scope): array 'Call to function %s() requires parameter #%d to be true.', $functionName, $argumentPosition + 1 - ))->build(), + ))->identifier('function.strict')->build(), ]; } diff --git a/src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php b/src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php index bb4bebbf..e52195a1 100644 --- a/src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php +++ b/src/Rules/SwitchConditions/MatchingTypeInSwitchCaseConditionRule.php @@ -49,7 +49,10 @@ public function processNode(Node $node, Scope $scope): array $conditionType->describe(VerbosityLevel::value()), $this->printer->prettyPrintExpr($case->cond), $caseType->describe(VerbosityLevel::typeOnly()) - ))->line($case->getLine())->build(); + )) + ->line($case->getLine()) + ->identifier('switch.type') + ->build(); } return $messages; diff --git a/src/Rules/VariableVariables/VariableMethodCallRule.php b/src/Rules/VariableVariables/VariableMethodCallRule.php index 6d18a2eb..f92f84c1 100644 --- a/src/Rules/VariableVariables/VariableMethodCallRule.php +++ b/src/Rules/VariableVariables/VariableMethodCallRule.php @@ -31,7 +31,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Variable method call on %s.', $scope->getType($node->var)->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('method.dynamicName')->build(), ]; } diff --git a/src/Rules/VariableVariables/VariableMethodCallableRule.php b/src/Rules/VariableVariables/VariableMethodCallableRule.php index be904f95..6a5fd518 100644 --- a/src/Rules/VariableVariables/VariableMethodCallableRule.php +++ b/src/Rules/VariableVariables/VariableMethodCallableRule.php @@ -31,7 +31,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Variable method call on %s.', $scope->getType($node->getVar())->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('method.dynamicName')->build(), ]; } diff --git a/src/Rules/VariableVariables/VariablePropertyFetchRule.php b/src/Rules/VariableVariables/VariablePropertyFetchRule.php index 0b2e9b7b..73ff0888 100644 --- a/src/Rules/VariableVariables/VariablePropertyFetchRule.php +++ b/src/Rules/VariableVariables/VariablePropertyFetchRule.php @@ -59,7 +59,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Variable property access on %s.', $fetchedOnType->describe(VerbosityLevel::typeOnly()) - ))->build(), + ))->identifier('property.dynamicName')->build(), ]; } diff --git a/src/Rules/VariableVariables/VariableStaticMethodCallRule.php b/src/Rules/VariableVariables/VariableStaticMethodCallRule.php index 5250dd6e..eb3a770c 100644 --- a/src/Rules/VariableVariables/VariableStaticMethodCallRule.php +++ b/src/Rules/VariableVariables/VariableStaticMethodCallRule.php @@ -37,7 +37,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Variable static method call on %s.', $methodCalledOn - ))->build(), + ))->identifier('staticMethod.dynamicName')->build(), ]; } diff --git a/src/Rules/VariableVariables/VariableStaticMethodCallableRule.php b/src/Rules/VariableVariables/VariableStaticMethodCallableRule.php index 1dc6280a..f765da66 100644 --- a/src/Rules/VariableVariables/VariableStaticMethodCallableRule.php +++ b/src/Rules/VariableVariables/VariableStaticMethodCallableRule.php @@ -37,7 +37,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Variable static method call on %s.', $methodCalledOn - ))->build(), + ))->identifier('staticMethod.dynamicName')->build(), ]; } diff --git a/src/Rules/VariableVariables/VariableStaticPropertyFetchRule.php b/src/Rules/VariableVariables/VariableStaticPropertyFetchRule.php index 72d937ef..f27c7792 100644 --- a/src/Rules/VariableVariables/VariableStaticPropertyFetchRule.php +++ b/src/Rules/VariableVariables/VariableStaticPropertyFetchRule.php @@ -37,7 +37,7 @@ public function processNode(Node $node, Scope $scope): array RuleErrorBuilder::message(sprintf( 'Variable static property access on %s.', $propertyAccessedOn - ))->build(), + ))->identifier('staticProperty.dynamicName')->build(), ]; } diff --git a/src/Rules/VariableVariables/VariableVariablesRule.php b/src/Rules/VariableVariables/VariableVariablesRule.php index fee986a7..f78e4ef4 100644 --- a/src/Rules/VariableVariables/VariableVariablesRule.php +++ b/src/Rules/VariableVariables/VariableVariablesRule.php @@ -28,6 +28,7 @@ public function processNode(Node $node, Scope $scope): array return [ RuleErrorBuilder::message('Variable variables are not allowed.') + ->identifier('variable.dynamicName') ->build(), ]; }