Skip to content

Commit dcdfcfa

Browse files
committed
FunctionCallParametersCheck - sprintf refactoring
1 parent 2732c60 commit dcdfcfa

File tree

6 files changed

+13
-16
lines changed

6 files changed

+13
-16
lines changed

src/Rules/Classes/InstantiationRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ private function checkClassName(string $class, Node $node, Scope $scope): array
186186
'Class ' . $classReflection->getDisplayName() . ' constructor invoked with %d parameters, at least %d required.',
187187
'Class ' . $classReflection->getDisplayName() . ' constructor invoked with %d parameter, %d-%d required.',
188188
'Class ' . $classReflection->getDisplayName() . ' constructor invoked with %d parameters, %d-%d required.',
189-
'Parameter #%d %s of class ' . $classReflection->getDisplayName() . ' constructor expects %s, %s given.',
189+
'Parameter %s of class ' . $classReflection->getDisplayName() . ' constructor expects %s, %s given.',
190190
'', // constructor does not have a return type
191-
'Parameter #%d %s of class ' . $classReflection->getDisplayName() . ' constructor is passed by reference, so it expects variables only',
191+
'Parameter %s of class ' . $classReflection->getDisplayName() . ' constructor is passed by reference, so it expects variables only',
192192
'Unable to resolve the template type %s in instantiation of class ' . $classReflection->getDisplayName(),
193193
'Missing parameter $%s in call to ' . $classReflection->getDisplayName() . ' constructor.',
194194
'Unknown parameter $%s in call to ' . $classReflection->getDisplayName() . ' constructor.',

src/Rules/FunctionCallParametersCheck.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ static function (Type $type): bool {
257257
$verbosityLevel = VerbosityLevel::getRecommendedLevelByType($parameterType);
258258
$errors[] = RuleErrorBuilder::message(sprintf(
259259
$messages[6],
260-
$i + 1,
261-
sprintf('%s$%s', $parameter->isVariadic() ? '...' : '', $parameter->getName()),
260+
sprintf('#%d %s', $i + 1, sprintf('%s$%s', $parameter->isVariadic() ? '...' : '', $parameter->getName())),
262261
$parameterType->describe($verbosityLevel),
263262
$argumentValueType->describe($verbosityLevel)
264263
))->build();
@@ -274,8 +273,7 @@ static function (Type $type): bool {
274273
if ($this->nullsafeCheck->containsNullSafe($argumentValue)) {
275274
$errors[] = RuleErrorBuilder::message(sprintf(
276275
$messages[8],
277-
$i + 1,
278-
sprintf('%s$%s', $parameter->isVariadic() ? '...' : '', $parameter->getName())
276+
sprintf('#%d %s', $i + 1, sprintf('%s$%s', $parameter->isVariadic() ? '...' : '', $parameter->getName()))
279277
))->build();
280278
continue;
281279
}
@@ -289,8 +287,7 @@ static function (Type $type): bool {
289287

290288
$errors[] = RuleErrorBuilder::message(sprintf(
291289
$messages[8],
292-
$i + 1,
293-
sprintf('%s$%s', $parameter->isVariadic() ? '...' : '', $parameter->getName())
290+
sprintf('#%d %s', $i + 1, sprintf('%s$%s', $parameter->isVariadic() ? '...' : '', $parameter->getName()))
294291
))->build();
295292
}
296293

src/Rules/Functions/CallCallablesRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ static function (Type $type): bool {
120120
ucfirst($callableDescription) . ' invoked with %d parameters, at least %d required.',
121121
ucfirst($callableDescription) . ' invoked with %d parameter, %d-%d required.',
122122
ucfirst($callableDescription) . ' invoked with %d parameters, %d-%d required.',
123-
'Parameter #%d %s of ' . $callableDescription . ' expects %s, %s given.',
123+
'Parameter %s of ' . $callableDescription . ' expects %s, %s given.',
124124
'Result of ' . $callableDescription . ' (void) is used.',
125-
'Parameter #%d %s of ' . $callableDescription . ' is passed by reference, so it expects variables only.',
125+
'Parameter %s of ' . $callableDescription . ' is passed by reference, so it expects variables only.',
126126
'Unable to resolve the template type %s in call to ' . $callableDescription,
127127
'Missing parameter $%s in call to ' . $callableDescription . '.',
128128
'Unknown parameter $%s in call to ' . $callableDescription . '.',

src/Rules/Functions/CallToFunctionParametersRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function processNode(Node $node, Scope $scope): array
5757
'Function ' . $function->getName() . ' invoked with %d parameters, at least %d required.',
5858
'Function ' . $function->getName() . ' invoked with %d parameter, %d-%d required.',
5959
'Function ' . $function->getName() . ' invoked with %d parameters, %d-%d required.',
60-
'Parameter #%d %s of function ' . $function->getName() . ' expects %s, %s given.',
60+
'Parameter %s of function ' . $function->getName() . ' expects %s, %s given.',
6161
'Result of function ' . $function->getName() . ' (void) is used.',
62-
'Parameter #%d %s of function ' . $function->getName() . ' is passed by reference, so it expects variables only.',
62+
'Parameter %s of function ' . $function->getName() . ' is passed by reference, so it expects variables only.',
6363
'Unable to resolve the template type %s in call to function ' . $function->getName(),
6464
'Missing parameter $%s in call to function ' . $function->getName() . '.',
6565
'Unknown parameter $%s in call to function ' . $function->getName() . '.',

src/Rules/Methods/CallMethodsRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ static function (Type $type) use ($name): bool {
149149
'Method ' . $messagesMethodName . ' invoked with %d parameters, at least %d required.',
150150
'Method ' . $messagesMethodName . ' invoked with %d parameter, %d-%d required.',
151151
'Method ' . $messagesMethodName . ' invoked with %d parameters, %d-%d required.',
152-
'Parameter #%d %s of method ' . $messagesMethodName . ' expects %s, %s given.',
152+
'Parameter %s of method ' . $messagesMethodName . ' expects %s, %s given.',
153153
'Result of method ' . $messagesMethodName . ' (void) is used.',
154-
'Parameter #%d %s of method ' . $messagesMethodName . ' is passed by reference, so it expects variables only.',
154+
'Parameter %s of method ' . $messagesMethodName . ' is passed by reference, so it expects variables only.',
155155
'Unable to resolve the template type %s in call to method ' . $messagesMethodName,
156156
'Missing parameter $%s in call to method ' . $messagesMethodName . '.',
157157
'Unknown parameter $%s in call to method ' . $messagesMethodName . '.',

src/Rules/Methods/CallStaticMethodsRule.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,9 @@ static function (Type $type) use ($methodName): bool {
286286
$displayMethodName . ' invoked with %d parameters, at least %d required.',
287287
$displayMethodName . ' invoked with %d parameter, %d-%d required.',
288288
$displayMethodName . ' invoked with %d parameters, %d-%d required.',
289-
'Parameter #%d %s of ' . $lowercasedMethodName . ' expects %s, %s given.',
289+
'Parameter %s of ' . $lowercasedMethodName . ' expects %s, %s given.',
290290
'Result of ' . $lowercasedMethodName . ' (void) is used.',
291-
'Parameter #%d %s of ' . $lowercasedMethodName . ' is passed by reference, so it expects variables only.',
291+
'Parameter %s of ' . $lowercasedMethodName . ' is passed by reference, so it expects variables only.',
292292
'Unable to resolve the template type %s in call to method ' . $lowercasedMethodName,
293293
'Missing parameter $%s in call to ' . $lowercasedMethodName . '.',
294294
'Unknown parameter $%s in call to ' . $lowercasedMethodName . '.',

0 commit comments

Comments
 (0)