Skip to content

Commit

Permalink
Merge pull request #42 from localheinz/fix/wording
Browse files Browse the repository at this point in the history
Fix: Wording of error messages
  • Loading branch information
localheinz authored Dec 3, 2018
2 parents 49a84e2 + 36f151b commit 42a1d1b
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 54 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ For a full diff see [`0.3.0...0.4.0`](https://github.com/localheinz/phpstan-rule
### Changed

* Removed double-quotes from error messages to be more consistent with error messages generated by `phpstan/phstan` ([#39](https://github.com/localheinz/phpstan-rules/pull/39)), by [@localheinz](https://github.com/localheinz)
* Modified wording and placement of method, function, and parameter names in error messages to be more consistent with error messages generated by `phpstan/phstan` ([#42](https://github.com/localheinz/phpstan-rules/pull/42)), by [@localheinz](https://github.com/localheinz)

## [`0.3.0`](https://github.com/localheinz/phpstan-rules/releases/tag/0.3.0)

Expand Down
2 changes: 1 addition & 1 deletion src/Classes/AbstractOrFinalRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function processNode(Node $node, Scope $scope): array

return [
\sprintf(
'Class %s should be marked as abstract or final.',
'Class %s is neither abstract nor final.',
$node->namespacedName
),
];
Expand Down
2 changes: 1 addition & 1 deletion src/Classes/FinalRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function processNode(Node $node, Scope $scope): array

return [
\sprintf(
'Class %s should be marked as final.',
'Class %s is not final.',
$node->namespacedName
),
];
Expand Down
2 changes: 1 addition & 1 deletion src/Closures/NoNullableReturnTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function processNode(Node $node, Scope $scope): array
}

return [
'Closure should not have a nullable return type declaration.',
'Closure has a nullable return type declaration.',
];
}
}
2 changes: 1 addition & 1 deletion src/Closures/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function processNode(Node $node, Scope $scope): array
$parameterName = $variable->name;

return \sprintf(
'Parameter $%s of closure should not have null as default value.',
'Closure has parameter $%s with null as default value.',
$parameterName
);
}, $params);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function processNode(Node $node, Scope $scope): array
$parameterName = $variable->name;

return \sprintf(
'Parameter $%s of closure should not have a nullable type declaration.',
'Closure has parameter $%s with a nullable type declaration.',
$parameterName
);
}, $params);
Expand Down
2 changes: 1 addition & 1 deletion src/Functions/NoNullableReturnTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function processNode(Node $node, Scope $scope): array

return [
\sprintf(
'Function %s() should not have a nullable return type declaration.',
'Function %s() has a nullable return type declaration.',
$node->namespacedName
),
];
Expand Down
6 changes: 3 additions & 3 deletions src/Functions/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public function processNode(Node $node, Scope $scope): array
$parameterName = $variable->name;

return \sprintf(
'Parameter $%s of function %s() should not have null as default value.',
$parameterName,
$functionName
'Function %s() has parameter $%s with null as default value.',
$functionName,
$parameterName
);
}, $params);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Functions/NoParameterWithNullableTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public function processNode(Node $node, Scope $scope): array
$parameterName = $variable->name;

return \sprintf(
'Parameter $%s of function "%s()" should not have a nullable type declaration.',
$parameterName,
$functionName
'Function %s() has parameter $%s with a nullable type declaration.',
$functionName,
$parameterName
);
}, $params);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Methods/NoNullableReturnTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ public function processNode(Node $node, Scope $scope): array
if ($classReflection->isAnonymous()) {
return [
\sprintf(
'Method %s() in anonymous class should not have a nullable return type declaration.',
'Method %s() in anonymous class has a nullable return type declaration.',
$node->name->name
),
];
}

return [
\sprintf(
'Method %s::%s() should not have a nullable return type declaration.',
'Method %s::%s() has a nullable return type declaration.',
$classReflection->getName(),
$node->name->name
),
Expand Down
12 changes: 6 additions & 6 deletions src/Methods/NoParameterWithNullDefaultValueRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ public function processNode(Node $node, Scope $scope): array
$parameterName = $variable->name;

return \sprintf(
'Parameter $%s of method %s() in anonymous class should not have null as default value.',
$parameterName,
$methodName
'Method %s() in anonymous class has parameter $%s with null as default value.',
$methodName,
$parameterName
);
}, $params);
}
Expand All @@ -80,10 +80,10 @@ public function processNode(Node $node, Scope $scope): array
$parameterName = $variable->name;

return \sprintf(
'Parameter $%s of method %s::%s() should not have null as default value.',
$parameterName,
'Method %s::%s() has parameter $%s with null as default value.',
$className,
$methodName
$methodName,
$parameterName
);
}, $params);
}
Expand Down
12 changes: 6 additions & 6 deletions src/Methods/NoParameterWithNullableTypeDeclarationRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function processNode(Node $node, Scope $scope): array
$parameterName = $variable->name;

return \sprintf(
'Parameter $%s of method %s() in anonymous class should not have a nullable type declaration.',
$parameterName,
$methodName
'Method %s() in anonymous class has parameter $%s with a nullable type declaration.',
$methodName,
$parameterName
);
}, $params);
}
Expand All @@ -76,10 +76,10 @@ public function processNode(Node $node, Scope $scope): array
$parameterName = $variable->name;

return \sprintf(
'Parameter $%s of method %s::%s() should not have a nullable type declaration.',
$parameterName,
'Method %s::%s() has parameter $%s with a nullable type declaration.',
$className,
$methodName
$methodName,
$parameterName
);
}, $params);
}
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/Classes/AbstractOrFinalRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function providerAnalysisFails(): \Generator
__DIR__ . '/../../Fixture/Classes/AbstractOrFinalRule/Failure/NeitherAbstractNorFinalClass.php',
[
\sprintf(
'Class %s should be marked as abstract or final.',
'Class %s is neither abstract nor final.',
Fixture\Classes\AbstractOrFinalRule\Failure\NeitherAbstractNorFinalClass::class
),
7,
Expand Down
4 changes: 2 additions & 2 deletions test/Integration/Classes/FinalRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function providerAnalysisFails(): \Generator
__DIR__ . '/../../Fixture/Classes/FinalRule/Failure/AbstractClass.php',
[
\sprintf(
'Class %s should be marked as final.',
'Class %s is not final.',
Fixture\Classes\FinalRule\Failure\AbstractClass::class
),
7,
Expand All @@ -59,7 +59,7 @@ public function providerAnalysisFails(): \Generator
__DIR__ . '/../../Fixture/Classes/FinalRule/Failure/NeitherAbstractNorFinalClass.php',
[
\sprintf(
'Class %s should be marked as final.',
'Class %s is not final.',
Fixture\Classes\FinalRule\Failure\NeitherAbstractNorFinalClass::class
),
7,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function providerAnalysisFails(): \Generator
'closure-with-nullable-return-type-declaration' => [
__DIR__ . '/../../Fixture/Closures/NoNullableReturnTypeDeclarationRule/Failure/closure-with-nullable-return-type-declaration.php',
[
'Closure should not have a nullable return type declaration.',
'Closure has a nullable return type declaration.',
7,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ public function providerAnalysisFails(): \Generator
'closure-with-parameter-with-null-default-value' => [
__DIR__ . '/../../Fixture/Closures/NoParameterWithNullDefaultValueRule/Failure/closure-with-parameter-with-null-default-value.php',
[
'Parameter $bar of closure should not have null as default value.',
'Closure has parameter $bar with null as default value.',
7,
],
],
'closure-with-parameter-with-root-namespace-referenced-null-default-value' => [
__DIR__ . '/../../Fixture/Closures/NoParameterWithNullDefaultValueRule/Failure/closure-with-parameter-with-root-namespace-referenced-null-default-value.php',
[
'Parameter $bar of closure should not have null as default value.',
'Closure has parameter $bar with null as default value.',
7,
],
],
'closure-with-parameter-with-wrongly-capitalized-null-default-value' => [
__DIR__ . '/../../Fixture/Closures/NoParameterWithNullDefaultValueRule/Failure/closure-with-parameter-with-wrongly-capitalized-null-default-value.php',
[
'Parameter $bar of closure should not have null as default value.',
'Closure has parameter $bar with null as default value.',
7,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function providerAnalysisFails(): \Generator
'closure-with-parameter-with-nullable-type-declaration' => [
__DIR__ . '/../../Fixture/Closures/NoParameterWithNullableTypeDeclarationRule/Failure/closure-with-parameter-with-nullable-type-declaration.php',
[
'Parameter $bar of closure should not have a nullable type declaration.',
'Closure has parameter $bar with a nullable type declaration.',
7,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function providerAnalysisFails(): \Generator
'function-with-nullable-return-type-declaration' => [
__DIR__ . '/../../Fixture/Functions/NoNullableReturnTypeDeclarationRule/Failure/function-with-nullable-return-type-declaration.php',
[
'Function Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoNullableReturnTypeDeclarationRule\Failure\foo() should not have a nullable return type declaration.',
'Function Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoNullableReturnTypeDeclarationRule\Failure\foo() has a nullable return type declaration.',
7,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ public function providerAnalysisFails(): \Generator
'function-with-parameter-with-null-default-value' => [
__DIR__ . '/../../Fixture/Functions/NoParameterWithNullDefaultValueRule/Failure/function-with-parameter-with-null-default-value.php',
[
'Parameter $bar of function Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoParameterWithNullDefaultValueRule\Failure\foo() should not have null as default value.',
'Function Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoParameterWithNullDefaultValueRule\Failure\foo() has parameter $bar with null as default value.',
7,
],
],
'function-with-parameter-with-root-namespace-referenced-null-default-value' => [
__DIR__ . '/../../Fixture/Functions/NoParameterWithNullDefaultValueRule/Failure/function-with-parameter-with-root-namespace-referenced-null-default-value.php',
[
'Parameter $bar of function Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoParameterWithNullDefaultValueRule\Failure\foo() should not have null as default value.',
'Function Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoParameterWithNullDefaultValueRule\Failure\foo() has parameter $bar with null as default value.',
7,
],
],
'function-with-parameter-with-wrongly-capitalized-null-default-value' => [
__DIR__ . '/../../Fixture/Functions/NoParameterWithNullDefaultValueRule/Failure/function-with-parameter-with-wrongly-capitalized-null-default-value.php',
[
'Parameter $bar of function Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoParameterWithNullDefaultValueRule\Failure\foo() should not have null as default value.',
'Function Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoParameterWithNullDefaultValueRule\Failure\foo() has parameter $bar with null as default value.',
7,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function providerAnalysisFails(): \Generator
'function-with-parameter-with-nullable-type-declaration' => [
__DIR__ . '/../../Fixture/Functions/NoParameterWithNullableTypeDeclarationRule/Failure/function-with-parameter-with-nullable-type-declaration.php',
[
'Parameter $bar of function "Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoParameterWithNullableTypeDeclarationRule\Failure\foo()" should not have a nullable type declaration.',
'Function Localheinz\PHPStan\Rules\Test\Fixture\Functions\NoParameterWithNullableTypeDeclarationRule\Failure\foo() has parameter $bar with a nullable type declaration.',
7,
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ public function providerAnalysisFails(): \Generator
'method-in-anonymous-class-with-nullable-return-type-declaration' => [
__DIR__ . '/../../Fixture/Methods/NoNullableReturnTypeDeclarationRule/Failure/MethodInAnonymousClassWithNullableReturnTypeDeclaration.php',
[
'Method toString() in anonymous class should not have a nullable return type declaration.',
'Method toString() in anonymous class has a nullable return type declaration.',
12,
],
],
'method-in-class-with-nullable-return-type-declaration' => [
__DIR__ . '/../../Fixture/Methods/NoNullableReturnTypeDeclarationRule/Failure/MethodInClassWithNullableReturnTypeDeclaration.php',
[
\sprintf(
'Method %s::toString() should not have a nullable return type declaration.',
'Method %s::toString() has a nullable return type declaration.',
Fixture\Methods\NoNullableReturnTypeDeclarationRule\Failure\MethodInClassWithNullableReturnTypeDeclaration::class
),
9,
Expand All @@ -69,7 +69,7 @@ public function providerAnalysisFails(): \Generator
__DIR__ . '/../../Fixture/Methods/NoNullableReturnTypeDeclarationRule/Failure/MethodInInterfaceWithNullableReturnTypeDeclaration.php',
[
\sprintf(
'Method %s::toString() should not have a nullable return type declaration.',
'Method %s::toString() has a nullable return type declaration.',
Fixture\Methods\NoNullableReturnTypeDeclarationRule\Failure\MethodInInterfaceWithNullableReturnTypeDeclaration::class
),
9,
Expand Down
Loading

0 comments on commit 42a1d1b

Please sign in to comment.