diff --git a/src/Classes/FinalRule.php b/src/Classes/FinalRule.php index 04196858..144155fb 100644 --- a/src/Classes/FinalRule.php +++ b/src/Classes/FinalRule.php @@ -98,10 +98,8 @@ public function processNode( $node->namespacedName->toString(), ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::final()->toString()) ->build(), ]; diff --git a/src/Classes/NoExtendsRule.php b/src/Classes/NoExtendsRule.php index b8aa47f3..ecbdd4c6 100644 --- a/src/Classes/NoExtendsRule.php +++ b/src/Classes/NoExtendsRule.php @@ -74,10 +74,8 @@ public function processNode( $extendedClassName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noExtends()->toString()) ->build(), ]; @@ -89,10 +87,8 @@ public function processNode( $extendedClassName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noExtends()->toString()) ->build(), ]; diff --git a/src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php b/src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php index 0abb55ae..9882995d 100644 --- a/src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php +++ b/src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php @@ -87,10 +87,8 @@ public function processNode( $extendedPhpunitTestCaseClassName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::testCaseWithSuffix()->toString()) ->build(), ]; diff --git a/src/Closures/NoNullableReturnTypeDeclarationRule.php b/src/Closures/NoNullableReturnTypeDeclarationRule.php index a4eba9de..cd58ea0b 100644 --- a/src/Closures/NoNullableReturnTypeDeclarationRule.php +++ b/src/Closures/NoNullableReturnTypeDeclarationRule.php @@ -36,10 +36,8 @@ public function processNode( return []; } - $ruleErrorBuilder = Rules\RuleErrorBuilder::message('Closure has a nullable return type declaration.'); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message('Closure has a nullable return type declaration.') ->identifier(ErrorIdentifier::noNullableReturnTypeDeclaration()->toString()) ->build(), ]; diff --git a/src/Closures/NoParameterWithNullDefaultValueRule.php b/src/Closures/NoParameterWithNullDefaultValueRule.php index 41bfb75a..5b4cce55 100644 --- a/src/Closures/NoParameterWithNullDefaultValueRule.php +++ b/src/Closures/NoParameterWithNullDefaultValueRule.php @@ -60,9 +60,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithNullDefaultValue()->toString()) ->build(); }, $params)); diff --git a/src/Closures/NoParameterWithNullableTypeDeclarationRule.php b/src/Closures/NoParameterWithNullableTypeDeclarationRule.php index ab1e0442..3e7e0edb 100644 --- a/src/Closures/NoParameterWithNullableTypeDeclarationRule.php +++ b/src/Closures/NoParameterWithNullableTypeDeclarationRule.php @@ -56,9 +56,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithNullableTypeDeclaration()->toString()) ->build(); }, $params)); diff --git a/src/Expressions/NoCompactRule.php b/src/Expressions/NoCompactRule.php index 8b126950..f49bec8b 100644 --- a/src/Expressions/NoCompactRule.php +++ b/src/Expressions/NoCompactRule.php @@ -40,10 +40,8 @@ public function processNode( return []; } - $ruleErrorBuilder = Rules\RuleErrorBuilder::message('Function compact() should not be used.'); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message('Function compact() should not be used.') ->identifier(ErrorIdentifier::noCompact()->toString()) ->build(), ]; diff --git a/src/Expressions/NoErrorSuppressionRule.php b/src/Expressions/NoErrorSuppressionRule.php index aeafcafe..642fba3f 100644 --- a/src/Expressions/NoErrorSuppressionRule.php +++ b/src/Expressions/NoErrorSuppressionRule.php @@ -32,10 +32,8 @@ public function processNode( Node $node, Analyser\Scope $scope ): array { - $ruleErrorBuilder = Rules\RuleErrorBuilder::message('Error suppression via "@" should not be used.'); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message('Error suppression via "@" should not be used.') ->identifier(ErrorIdentifier::noErrorSuppression()->toString()) ->build(), ]; diff --git a/src/Expressions/NoEvalRule.php b/src/Expressions/NoEvalRule.php index 75af9872..c3440533 100644 --- a/src/Expressions/NoEvalRule.php +++ b/src/Expressions/NoEvalRule.php @@ -32,10 +32,8 @@ public function processNode( Node $node, Analyser\Scope $scope ): array { - $ruleErrorBuilder = Rules\RuleErrorBuilder::message('Language construct eval() should not be used.'); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message('Language construct eval() should not be used.') ->identifier(ErrorIdentifier::noEval()->toString()) ->build(), ]; diff --git a/src/Expressions/NoIssetRule.php b/src/Expressions/NoIssetRule.php index 12a76df4..ac2ce865 100644 --- a/src/Expressions/NoIssetRule.php +++ b/src/Expressions/NoIssetRule.php @@ -32,10 +32,8 @@ public function processNode( Node $node, Analyser\Scope $scope ): array { - $ruleErrorBuilder = Rules\RuleErrorBuilder::message('Language construct isset() should not be used.'); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message('Language construct isset() should not be used.') ->identifier(ErrorIdentifier::noIsset()->toString()) ->build(), ]; diff --git a/src/Files/DeclareStrictTypesRule.php b/src/Files/DeclareStrictTypesRule.php index 66a74fd3..4d9ccc7e 100644 --- a/src/Files/DeclareStrictTypesRule.php +++ b/src/Files/DeclareStrictTypesRule.php @@ -61,10 +61,8 @@ public function processNode( } } - $ruleErrorBuilder = Rules\RuleErrorBuilder::message('File is missing a "declare(strict_types=1)" declaration.'); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message('File is missing a "declare(strict_types=1)" declaration.') ->identifier(ErrorIdentifier::declareStrictTypes()->toString()) ->build(), ]; diff --git a/src/Functions/NoNullableReturnTypeDeclarationRule.php b/src/Functions/NoNullableReturnTypeDeclarationRule.php index 57664786..a5a50f06 100644 --- a/src/Functions/NoNullableReturnTypeDeclarationRule.php +++ b/src/Functions/NoNullableReturnTypeDeclarationRule.php @@ -45,10 +45,8 @@ public function processNode( $node->namespacedName->toString(), ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noNullableReturnTypeDeclaration()->toString()) ->build(), ]; diff --git a/src/Functions/NoParameterWithNullDefaultValueRule.php b/src/Functions/NoParameterWithNullDefaultValueRule.php index d79ba38e..fdf6e76a 100644 --- a/src/Functions/NoParameterWithNullDefaultValueRule.php +++ b/src/Functions/NoParameterWithNullDefaultValueRule.php @@ -63,9 +63,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithNullDefaultValue()->toString()) ->build(); }, $params)); diff --git a/src/Functions/NoParameterWithNullableTypeDeclarationRule.php b/src/Functions/NoParameterWithNullableTypeDeclarationRule.php index 8c2eaf5e..a6ed3064 100644 --- a/src/Functions/NoParameterWithNullableTypeDeclarationRule.php +++ b/src/Functions/NoParameterWithNullableTypeDeclarationRule.php @@ -59,9 +59,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithNullableTypeDeclaration()->toString()) ->build(); }, $params)); diff --git a/src/Methods/FinalInAbstractClassRule.php b/src/Methods/FinalInAbstractClassRule.php index 812bbf67..75b2f812 100644 --- a/src/Methods/FinalInAbstractClassRule.php +++ b/src/Methods/FinalInAbstractClassRule.php @@ -85,10 +85,8 @@ public function processNode( $node->name->toString(), ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::finalInAbstractClass()->toString()) ->build(), ]; diff --git a/src/Methods/NoConstructorParameterWithDefaultValueRule.php b/src/Methods/NoConstructorParameterWithDefaultValueRule.php index 07f532a2..ae267888 100644 --- a/src/Methods/NoConstructorParameterWithDefaultValueRule.php +++ b/src/Methods/NoConstructorParameterWithDefaultValueRule.php @@ -65,9 +65,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noConstructorParameterWithDefaultValue()->toString()) ->build(); }, $params)); @@ -88,9 +86,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noConstructorParameterWithDefaultValue()->toString()) ->build(); }, $params)); diff --git a/src/Methods/NoNullableReturnTypeDeclarationRule.php b/src/Methods/NoNullableReturnTypeDeclarationRule.php index 16afb430..04d26b2c 100644 --- a/src/Methods/NoNullableReturnTypeDeclarationRule.php +++ b/src/Methods/NoNullableReturnTypeDeclarationRule.php @@ -46,10 +46,8 @@ public function processNode( $node->name->name, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noNullableReturnTypeDeclaration()->toString()) ->build(), ]; @@ -61,10 +59,8 @@ public function processNode( $node->name->name, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noNullableReturnTypeDeclaration()->toString()) ->build(), ]; diff --git a/src/Methods/NoParameterWithContainerTypeDeclarationRule.php b/src/Methods/NoParameterWithContainerTypeDeclarationRule.php index 22cf60a7..a237b312 100644 --- a/src/Methods/NoParameterWithContainerTypeDeclarationRule.php +++ b/src/Methods/NoParameterWithContainerTypeDeclarationRule.php @@ -159,9 +159,7 @@ private static function createError( $classUsedInTypeDeclaration->getName(), ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithContainerTypeDeclaration()->toString()) ->build(); } @@ -174,9 +172,7 @@ private static function createError( $classUsedInTypeDeclaration->getName(), ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithContainerTypeDeclaration()->toString()) ->build(); } diff --git a/src/Methods/NoParameterWithNullDefaultValueRule.php b/src/Methods/NoParameterWithNullDefaultValueRule.php index 4ced62f8..828c3707 100644 --- a/src/Methods/NoParameterWithNullDefaultValueRule.php +++ b/src/Methods/NoParameterWithNullDefaultValueRule.php @@ -68,9 +68,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithNullDefaultValue()->toString()) ->build(); }, $params)); @@ -92,9 +90,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithNullDefaultValue()->toString()) ->build(); }, $params)); diff --git a/src/Methods/NoParameterWithNullableTypeDeclarationRule.php b/src/Methods/NoParameterWithNullableTypeDeclarationRule.php index 7e11eab2..c93c15cc 100644 --- a/src/Methods/NoParameterWithNullableTypeDeclarationRule.php +++ b/src/Methods/NoParameterWithNullableTypeDeclarationRule.php @@ -64,9 +64,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithContainerTypeDeclaration()->toString()) ->build(); }, $params)); @@ -88,9 +86,7 @@ public function processNode( $parameterName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - - return $ruleErrorBuilder + return Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::noParameterWithContainerTypeDeclaration()->toString()) ->build(); }, $params)); diff --git a/src/Methods/PrivateInFinalClassRule.php b/src/Methods/PrivateInFinalClassRule.php index 7b61211a..12576225 100644 --- a/src/Methods/PrivateInFinalClassRule.php +++ b/src/Methods/PrivateInFinalClassRule.php @@ -66,10 +66,8 @@ public function processNode( $methodName, ); - $ruleErrorBuilder = Rules\RuleErrorBuilder::message($message); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message($message) ->identifier(ErrorIdentifier::privateInFinalClass()->toString()) ->build(), ]; diff --git a/src/Statements/NoSwitchRule.php b/src/Statements/NoSwitchRule.php index 84122460..4a52254e 100644 --- a/src/Statements/NoSwitchRule.php +++ b/src/Statements/NoSwitchRule.php @@ -32,10 +32,8 @@ public function processNode( Node $node, Analyser\Scope $scope ): array { - $ruleErrorBuilder = Rules\RuleErrorBuilder::message('Control structures using switch should not be used.'); - return [ - $ruleErrorBuilder + Rules\RuleErrorBuilder::message('Control structures using switch should not be used.') ->identifier(ErrorIdentifier::noSwitch()->toString()) ->build(), ];