Skip to content

Commit

Permalink
Fix: Inline variable
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Dec 13, 2024
1 parent 8ad6f71 commit 7533af7
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 84 deletions.
4 changes: 1 addition & 3 deletions src/Classes/FinalRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
8 changes: 2 additions & 6 deletions src/Classes/NoExtendsRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ public function processNode(
$extendedClassName,
);

$ruleErrorBuilder = Rules\RuleErrorBuilder::message($message);

return [
$ruleErrorBuilder
Rules\RuleErrorBuilder::message($message)
->identifier(ErrorIdentifier::noExtends()->toString())
->build(),
];
Expand All @@ -89,10 +87,8 @@ public function processNode(
$extendedClassName,
);

$ruleErrorBuilder = Rules\RuleErrorBuilder::message($message);

return [
$ruleErrorBuilder
Rules\RuleErrorBuilder::message($message)
->identifier(ErrorIdentifier::noExtends()->toString())
->build(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Classes/PHPUnit/Framework/TestCaseWithSuffixRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,8 @@ public function processNode(
$extendedPhpunitTestCaseClassName,
);

$ruleErrorBuilder = Rules\RuleErrorBuilder::message($message);

return [
$ruleErrorBuilder
Rules\RuleErrorBuilder::message($message)
->identifier(ErrorIdentifier::testCaseWithSuffix()->toString())
->build(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Closures/NoNullableReturnTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Closures/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions src/Closures/NoParameterWithNullableTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions src/Expressions/NoCompactRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Expressions/NoErrorSuppressionRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Expressions/NoEvalRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Expressions/NoIssetRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Files/DeclareStrictTypesRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Functions/NoNullableReturnTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Functions/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions src/Functions/NoParameterWithNullableTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions src/Methods/FinalInAbstractClassRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down
8 changes: 2 additions & 6 deletions src/Methods/NoConstructorParameterWithDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down
8 changes: 2 additions & 6 deletions src/Methods/NoNullableReturnTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand All @@ -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(),
];
Expand Down
8 changes: 2 additions & 6 deletions src/Methods/NoParameterWithContainerTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down
8 changes: 2 additions & 6 deletions src/Methods/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down
8 changes: 2 additions & 6 deletions src/Methods/NoParameterWithNullableTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions src/Methods/PrivateInFinalClassRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ public function processNode(
$methodName,
);

$ruleErrorBuilder = Rules\RuleErrorBuilder::message($message);

return [
$ruleErrorBuilder
Rules\RuleErrorBuilder::message($message)
->identifier(ErrorIdentifier::privateInFinalClass()->toString())
->build(),
];
Expand Down
4 changes: 1 addition & 3 deletions src/Statements/NoSwitchRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
];
Expand Down

0 comments on commit 7533af7

Please sign in to comment.