diff --git a/rules.neon b/rules.neon index 123cc83b..7f827de8 100644 --- a/rules.neon +++ b/rules.neon @@ -141,6 +141,9 @@ parametersSchema: ]) services: + - + class: Ergebnis\PHPStan\Rules\Analyzer + - class: Ergebnis\PHPStan\Rules\Classes\FinalRule arguments: diff --git a/src/Analyzer.php b/src/Analyzer.php new file mode 100644 index 00000000..827ecdd4 --- /dev/null +++ b/src/Analyzer.php @@ -0,0 +1,55 @@ +types as $type) { + if (!$type instanceof Node\Identifier) { + continue; + } + + if ('null' === $type->toLowerString()) { + return true; + } + } + } + + return false; + } + + public function hasNullDefaultValue(Node\Param $parameter): bool + { + if (!$parameter->default instanceof Node\Expr\ConstFetch) { + return false; + } + + return 'null' === $parameter->default->name->toLowerString(); + } +} diff --git a/src/Closures/NoNullableReturnTypeDeclarationRule.php b/src/Closures/NoNullableReturnTypeDeclarationRule.php index 28aef1db..64351579 100644 --- a/src/Closures/NoNullableReturnTypeDeclarationRule.php +++ b/src/Closures/NoNullableReturnTypeDeclarationRule.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPStan\Rules\Closures; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\ErrorIdentifier; use PhpParser\Node; use PHPStan\Analyser; @@ -23,6 +24,13 @@ */ final class NoNullableReturnTypeDeclarationRule implements Rules\Rule { + private Analyzer $analyzer; + + public function __construct(Analyzer $analyzer) + { + $this->analyzer = $analyzer; + } + public function getNodeType(): string { return Node\Expr\Closure::class; @@ -32,7 +40,7 @@ public function processNode( Node $node, Analyser\Scope $scope ): array { - if (!self::hasNullableReturnTypeDeclaration($node)) { + if (!$this->analyzer->isNullableTypeDeclaration($node->getReturnType())) { return []; } @@ -42,27 +50,4 @@ public function processNode( ->build(), ]; } - - private static function hasNullableReturnTypeDeclaration(Node\Expr\Closure $closure): bool - { - $returnType = $closure->getReturnType(); - - if ($returnType instanceof Node\NullableType) { - return true; - } - - if ($returnType instanceof Node\UnionType) { - foreach ($returnType->types as $type) { - if (!$type instanceof Node\Identifier) { - continue; - } - - if ('null' === $type->toString()) { - return true; - } - } - } - - return false; - } } diff --git a/src/Closures/NoParameterWithNullDefaultValueRule.php b/src/Closures/NoParameterWithNullDefaultValueRule.php index be414f70..94bd1463 100644 --- a/src/Closures/NoParameterWithNullDefaultValueRule.php +++ b/src/Closures/NoParameterWithNullDefaultValueRule.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPStan\Rules\Closures; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\ErrorIdentifier; use PhpParser\Node; use PHPStan\Analyser; @@ -23,6 +24,13 @@ */ final class NoParameterWithNullDefaultValueRule implements Rules\Rule { + private Analyzer $analyzer; + + public function __construct(Analyzer $analyzer) + { + $this->analyzer = $analyzer; + } + public function getNodeType(): string { return Node\Expr\Closure::class; @@ -36,8 +44,8 @@ public function processNode( return []; } - $parametersWithNullDefaultValue = \array_values(\array_filter($node->params, static function (Node\Param $parameter): bool { - return self::hasNullDefaultValue($parameter); + $parametersWithNullDefaultValue = \array_values(\array_filter($node->params, function (Node\Param $parameter): bool { + return $this->analyzer->hasNullDefaultValue($parameter); })); if (0 === \count($parametersWithNullDefaultValue)) { @@ -61,13 +69,4 @@ public function processNode( ->build(); }, $parametersWithNullDefaultValue); } - - private static function hasNullDefaultValue(Node\Param $parameter): bool - { - if (!$parameter->default instanceof Node\Expr\ConstFetch) { - return false; - } - - return 'null' === $parameter->default->name->toLowerString(); - } } diff --git a/src/Closures/NoParameterWithNullableTypeDeclarationRule.php b/src/Closures/NoParameterWithNullableTypeDeclarationRule.php index 2a539da2..3cff6ee6 100644 --- a/src/Closures/NoParameterWithNullableTypeDeclarationRule.php +++ b/src/Closures/NoParameterWithNullableTypeDeclarationRule.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPStan\Rules\Closures; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\ErrorIdentifier; use PhpParser\Node; use PHPStan\Analyser; @@ -23,6 +24,13 @@ */ final class NoParameterWithNullableTypeDeclarationRule implements Rules\Rule { + private Analyzer $analyzer; + + public function __construct(Analyzer $analyzer) + { + $this->analyzer = $analyzer; + } + public function getNodeType(): string { return Node\Expr\Closure::class; @@ -36,8 +44,8 @@ public function processNode( return []; } - $parametersWithNullableTypeDeclaration = \array_values(\array_filter($node->params, static function (Node\Param $parameter): bool { - return self::hasNullableTypeDeclaration($parameter); + $parametersWithNullableTypeDeclaration = \array_values(\array_filter($node->params, function (Node\Param $parameter): bool { + return $this->analyzer->isNullableTypeDeclaration($parameter->type); })); if (0 === \count($parametersWithNullableTypeDeclaration)) { @@ -61,27 +69,4 @@ public function processNode( ->build(); }, $parametersWithNullableTypeDeclaration); } - - private static function hasNullableTypeDeclaration(Node\Param $parameter): bool - { - if ($parameter->type instanceof Node\NullableType) { - return true; - } - - if ($parameter->type instanceof Node\UnionType) { - foreach ($parameter->type->types as $type) { - if (!$type instanceof Node\Identifier) { - continue; - } - - if ('null' !== $type->toString()) { - continue; - } - - return true; - } - } - - return false; - } } diff --git a/src/Functions/NoNullableReturnTypeDeclarationRule.php b/src/Functions/NoNullableReturnTypeDeclarationRule.php index 9346eea7..06da4f72 100644 --- a/src/Functions/NoNullableReturnTypeDeclarationRule.php +++ b/src/Functions/NoNullableReturnTypeDeclarationRule.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPStan\Rules\Functions; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\ErrorIdentifier; use PhpParser\Node; use PHPStan\Analyser; @@ -23,6 +24,13 @@ */ final class NoNullableReturnTypeDeclarationRule implements Rules\Rule { + private Analyzer $analyzer; + + public function __construct(Analyzer $analyzer) + { + $this->analyzer = $analyzer; + } + public function getNodeType(): string { return Node\Stmt\Function_::class; @@ -36,7 +44,7 @@ public function processNode( return []; } - if (!self::hasNullableReturnTypeDeclaration($node)) { + if (!$this->analyzer->isNullableTypeDeclaration($node->getReturnType())) { return []; } @@ -51,27 +59,4 @@ public function processNode( ->build(), ]; } - - private static function hasNullableReturnTypeDeclaration(Node\Stmt\Function_ $function): bool - { - $returnType = $function->getReturnType(); - - if ($returnType instanceof Node\NullableType) { - return true; - } - - if ($returnType instanceof Node\UnionType) { - foreach ($returnType->types as $type) { - if (!$type instanceof Node\Identifier) { - continue; - } - - if ('null' === $type->toString()) { - return true; - } - } - } - - return false; - } } diff --git a/src/Functions/NoParameterWithNullDefaultValueRule.php b/src/Functions/NoParameterWithNullDefaultValueRule.php index 3f8b3d47..fe82a4e3 100644 --- a/src/Functions/NoParameterWithNullDefaultValueRule.php +++ b/src/Functions/NoParameterWithNullDefaultValueRule.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPStan\Rules\Functions; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\ErrorIdentifier; use PhpParser\Node; use PHPStan\Analyser; @@ -23,6 +24,13 @@ */ final class NoParameterWithNullDefaultValueRule implements Rules\Rule { + private Analyzer $analyzer; + + public function __construct(Analyzer $analyzer) + { + $this->analyzer = $analyzer; + } + public function getNodeType(): string { return Node\Stmt\Function_::class; @@ -36,8 +44,8 @@ public function processNode( return []; } - $parametersWithNullDefaultValue = \array_values(\array_filter($node->params, static function (Node\Param $parameter): bool { - return self::hasNullDefaultValue($parameter); + $parametersWithNullDefaultValue = \array_values(\array_filter($node->params, function (Node\Param $parameter): bool { + return $this->analyzer->hasNullDefaultValue($parameter); })); if (0 === \count($parametersWithNullDefaultValue)) { @@ -64,13 +72,4 @@ public function processNode( ->build(); }, $parametersWithNullDefaultValue); } - - private static function hasNullDefaultValue(Node\Param $parameter): bool - { - if (!$parameter->default instanceof Node\Expr\ConstFetch) { - return false; - } - - return 'null' === $parameter->default->name->toLowerString(); - } } diff --git a/src/Functions/NoParameterWithNullableTypeDeclarationRule.php b/src/Functions/NoParameterWithNullableTypeDeclarationRule.php index 40a7025f..90275530 100644 --- a/src/Functions/NoParameterWithNullableTypeDeclarationRule.php +++ b/src/Functions/NoParameterWithNullableTypeDeclarationRule.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPStan\Rules\Functions; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\ErrorIdentifier; use PhpParser\Node; use PHPStan\Analyser; @@ -23,6 +24,13 @@ */ final class NoParameterWithNullableTypeDeclarationRule implements Rules\Rule { + private Analyzer $analyzer; + + public function __construct(Analyzer $analyzer) + { + $this->analyzer = $analyzer; + } + public function getNodeType(): string { return Node\Stmt\Function_::class; @@ -36,8 +44,8 @@ public function processNode( return []; } - $parametersWithNullableTypeDeclaration = \array_values(\array_filter($node->params, static function (Node\Param $parameter): bool { - return self::hasNullableTypeDeclaration($parameter); + $parametersWithNullableTypeDeclaration = \array_values(\array_filter($node->params, function (Node\Param $parameter): bool { + return $this->analyzer->isNullableTypeDeclaration($parameter->type); })); if (0 === \count($parametersWithNullableTypeDeclaration)) { @@ -64,27 +72,4 @@ public function processNode( ->build(); }, $parametersWithNullableTypeDeclaration); } - - private static function hasNullableTypeDeclaration(Node\Param $parameter): bool - { - if ($parameter->type instanceof Node\NullableType) { - return true; - } - - if ($parameter->type instanceof Node\UnionType) { - foreach ($parameter->type->types as $type) { - if (!$type instanceof Node\Identifier) { - continue; - } - - if ('null' !== $type->toString()) { - continue; - } - - return true; - } - } - - return false; - } } diff --git a/src/Methods/NoNullableReturnTypeDeclarationRule.php b/src/Methods/NoNullableReturnTypeDeclarationRule.php index 6a822670..e0e84c94 100644 --- a/src/Methods/NoNullableReturnTypeDeclarationRule.php +++ b/src/Methods/NoNullableReturnTypeDeclarationRule.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPStan\Rules\Methods; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\ErrorIdentifier; use PhpParser\Node; use PHPStan\Analyser; @@ -24,6 +25,13 @@ */ final class NoNullableReturnTypeDeclarationRule implements Rules\Rule { + private Analyzer $analyzer; + + public function __construct(Analyzer $analyzer) + { + $this->analyzer = $analyzer; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; @@ -33,7 +41,7 @@ public function processNode( Node $node, Analyser\Scope $scope ): array { - if (!self::hasNullableReturnTypeDeclaration($node)) { + if (!$this->analyzer->isNullableTypeDeclaration($node->getReturnType())) { return []; } @@ -65,27 +73,4 @@ public function processNode( ->build(), ]; } - - private static function hasNullableReturnTypeDeclaration(Node\Stmt\ClassMethod $method): bool - { - $returnType = $method->getReturnType(); - - if ($returnType instanceof Node\NullableType) { - return true; - } - - if ($returnType instanceof Node\UnionType) { - foreach ($returnType->types as $type) { - if (!$type instanceof Node\Identifier) { - continue; - } - - if ('null' === $type->toString()) { - return true; - } - } - } - - return false; - } } diff --git a/src/Methods/NoParameterWithNullDefaultValueRule.php b/src/Methods/NoParameterWithNullDefaultValueRule.php index 0e93f1e5..9888974c 100644 --- a/src/Methods/NoParameterWithNullDefaultValueRule.php +++ b/src/Methods/NoParameterWithNullDefaultValueRule.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPStan\Rules\Methods; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\ErrorIdentifier; use PhpParser\Node; use PHPStan\Analyser; @@ -24,6 +25,13 @@ */ final class NoParameterWithNullDefaultValueRule implements Rules\Rule { + private Analyzer $analyzer; + + public function __construct(Analyzer $analyzer) + { + $this->analyzer = $analyzer; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; @@ -37,8 +45,8 @@ public function processNode( return []; } - $parametersWithNullDefaultValue = \array_values(\array_filter($node->params, static function (Node\Param $parameter): bool { - return self::hasNullDefaultValue($parameter); + $parametersWithNullDefaultValue = \array_values(\array_filter($node->params, function (Node\Param $parameter): bool { + return $this->analyzer->hasNullDefaultValue($parameter); })); if (0 === \count($parametersWithNullDefaultValue)) { @@ -91,13 +99,4 @@ public function processNode( ->build(); }, $parametersWithNullDefaultValue); } - - private static function hasNullDefaultValue(Node\Param $parameter): bool - { - if (!$parameter->default instanceof Node\Expr\ConstFetch) { - return false; - } - - return 'null' === $parameter->default->name->toLowerString(); - } } diff --git a/src/Methods/NoParameterWithNullableTypeDeclarationRule.php b/src/Methods/NoParameterWithNullableTypeDeclarationRule.php index e06fd0fb..fdf5c5cb 100644 --- a/src/Methods/NoParameterWithNullableTypeDeclarationRule.php +++ b/src/Methods/NoParameterWithNullableTypeDeclarationRule.php @@ -13,6 +13,7 @@ namespace Ergebnis\PHPStan\Rules\Methods; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\ErrorIdentifier; use PhpParser\Node; use PHPStan\Analyser; @@ -24,6 +25,13 @@ */ final class NoParameterWithNullableTypeDeclarationRule implements Rules\Rule { + private Analyzer $analyzer; + + public function __construct(Analyzer $analyzer) + { + $this->analyzer = $analyzer; + } + public function getNodeType(): string { return Node\Stmt\ClassMethod::class; @@ -37,8 +45,8 @@ public function processNode( return []; } - $parametersWithNullableTypeDeclaration = \array_values(\array_filter($node->params, static function (Node\Param $parameter): bool { - return self::hasNullableTypeDeclaration($parameter); + $parametersWithNullableTypeDeclaration = \array_values(\array_filter($node->params, function (Node\Param $parameter): bool { + return $this->analyzer->isNullableTypeDeclaration($parameter->type); })); if (0 === \count($parametersWithNullableTypeDeclaration)) { @@ -91,27 +99,4 @@ public function processNode( ->build(); }, $parametersWithNullableTypeDeclaration); } - - private static function hasNullableTypeDeclaration(Node\Param $parameter): bool - { - if ($parameter->type instanceof Node\NullableType) { - return true; - } - - if ($parameter->type instanceof Node\UnionType) { - foreach ($parameter->type->types as $type) { - if (!$type instanceof Node\Identifier) { - continue; - } - - if ('null' !== $type->toString()) { - continue; - } - - return true; - } - } - - return false; - } } diff --git a/test/Integration/Closures/NoNullableReturnTypeDeclarationRuleTest.php b/test/Integration/Closures/NoNullableReturnTypeDeclarationRuleTest.php index a2e61cc9..3bb4a879 100644 --- a/test/Integration/Closures/NoNullableReturnTypeDeclarationRuleTest.php +++ b/test/Integration/Closures/NoNullableReturnTypeDeclarationRuleTest.php @@ -13,12 +13,14 @@ namespace Ergebnis\PHPStan\Rules\Test\Integration\Closures; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\Closures; use Ergebnis\PHPStan\Rules\Test; use PHPStan\Rules; use PHPStan\Testing; /** + * @covers \Ergebnis\PHPStan\Rules\Analyzer * @covers \Ergebnis\PHPStan\Rules\Closures\NoNullableReturnTypeDeclarationRule * * @uses \Ergebnis\PHPStan\Rules\ErrorIdentifier @@ -48,6 +50,6 @@ public function testNoNullableReturnTypeDeclarationRule(): void protected function getRule(): Rules\Rule { - return new Closures\NoNullableReturnTypeDeclarationRule(); + return new Closures\NoNullableReturnTypeDeclarationRule(new Analyzer()); } } diff --git a/test/Integration/Closures/NoParameterWithNullDefaultValueRuleTest.php b/test/Integration/Closures/NoParameterWithNullDefaultValueRuleTest.php index 9b3d4847..8422e47f 100644 --- a/test/Integration/Closures/NoParameterWithNullDefaultValueRuleTest.php +++ b/test/Integration/Closures/NoParameterWithNullDefaultValueRuleTest.php @@ -13,12 +13,14 @@ namespace Ergebnis\PHPStan\Rules\Test\Integration\Closures; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\Closures; use Ergebnis\PHPStan\Rules\Test; use PHPStan\Rules; use PHPStan\Testing; /** + * @covers \Ergebnis\PHPStan\Rules\Analyzer * @covers \Ergebnis\PHPStan\Rules\Closures\NoParameterWithNullDefaultValueRule * * @uses \Ergebnis\PHPStan\Rules\ErrorIdentifier @@ -52,6 +54,6 @@ public function testNoParameterWithNullDefaultValueRule(): void protected function getRule(): Rules\Rule { - return new Closures\NoParameterWithNullDefaultValueRule(); + return new Closures\NoParameterWithNullDefaultValueRule(new Analyzer()); } } diff --git a/test/Integration/Closures/NoParameterWithNullableTypeDeclarationRuleTest.php b/test/Integration/Closures/NoParameterWithNullableTypeDeclarationRuleTest.php index 5e6f09dc..52f8e04d 100644 --- a/test/Integration/Closures/NoParameterWithNullableTypeDeclarationRuleTest.php +++ b/test/Integration/Closures/NoParameterWithNullableTypeDeclarationRuleTest.php @@ -13,12 +13,14 @@ namespace Ergebnis\PHPStan\Rules\Test\Integration\Closures; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\Closures; use Ergebnis\PHPStan\Rules\Test; use PHPStan\Rules; use PHPStan\Testing; /** + * @covers \Ergebnis\PHPStan\Rules\Analyzer * @covers \Ergebnis\PHPStan\Rules\Closures\NoParameterWithNullableTypeDeclarationRule * * @uses \Ergebnis\PHPStan\Rules\ErrorIdentifier @@ -48,6 +50,6 @@ public function testNoParameterWithNullableTypeDeclarationRule(): void protected function getRule(): Rules\Rule { - return new Closures\NoParameterWithNullableTypeDeclarationRule(); + return new Closures\NoParameterWithNullableTypeDeclarationRule(new Analyzer()); } } diff --git a/test/Integration/Functions/NoNullableReturnTypeDeclarationRuleTest.php b/test/Integration/Functions/NoNullableReturnTypeDeclarationRuleTest.php index c1d94b7e..ee88039e 100644 --- a/test/Integration/Functions/NoNullableReturnTypeDeclarationRuleTest.php +++ b/test/Integration/Functions/NoNullableReturnTypeDeclarationRuleTest.php @@ -13,12 +13,14 @@ namespace Ergebnis\PHPStan\Rules\Test\Integration\Functions; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\Functions; use Ergebnis\PHPStan\Rules\Test; use PHPStan\Rules; use PHPStan\Testing; /** + * @covers \Ergebnis\PHPStan\Rules\Analyzer * @covers \Ergebnis\PHPStan\Rules\Functions\NoNullableReturnTypeDeclarationRule * * @uses \Ergebnis\PHPStan\Rules\ErrorIdentifier @@ -48,6 +50,6 @@ public function testNoNullableReturnTypeDeclarationRule(): void protected function getRule(): Rules\Rule { - return new Functions\NoNullableReturnTypeDeclarationRule(); + return new Functions\NoNullableReturnTypeDeclarationRule(new Analyzer()); } } diff --git a/test/Integration/Functions/NoParameterWithNullDefaultValueRuleTest.php b/test/Integration/Functions/NoParameterWithNullDefaultValueRuleTest.php index 62753184..81e6b45a 100644 --- a/test/Integration/Functions/NoParameterWithNullDefaultValueRuleTest.php +++ b/test/Integration/Functions/NoParameterWithNullDefaultValueRuleTest.php @@ -13,12 +13,14 @@ namespace Ergebnis\PHPStan\Rules\Test\Integration\Functions; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\Functions; use Ergebnis\PHPStan\Rules\Test; use PHPStan\Rules; use PHPStan\Testing; /** + * @covers \Ergebnis\PHPStan\Rules\Analyzer * @covers \Ergebnis\PHPStan\Rules\Functions\NoParameterWithNullDefaultValueRule * * @uses \Ergebnis\PHPStan\Rules\ErrorIdentifier @@ -52,6 +54,6 @@ public function testNoParameterWithNullDefaultValueRule(): void protected function getRule(): Rules\Rule { - return new Functions\NoParameterWithNullDefaultValueRule(); + return new Functions\NoParameterWithNullDefaultValueRule(new Analyzer()); } } diff --git a/test/Integration/Functions/NoParameterWithNullableTypeDeclarationRuleTest.php b/test/Integration/Functions/NoParameterWithNullableTypeDeclarationRuleTest.php index 031ab514..380eefe4 100644 --- a/test/Integration/Functions/NoParameterWithNullableTypeDeclarationRuleTest.php +++ b/test/Integration/Functions/NoParameterWithNullableTypeDeclarationRuleTest.php @@ -13,12 +13,14 @@ namespace Ergebnis\PHPStan\Rules\Test\Integration\Functions; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\Functions; use Ergebnis\PHPStan\Rules\Test; use PHPStan\Rules; use PHPStan\Testing; /** + * @covers \Ergebnis\PHPStan\Rules\Analyzer * @covers \Ergebnis\PHPStan\Rules\Functions\NoParameterWithNullableTypeDeclarationRule * * @uses \Ergebnis\PHPStan\Rules\ErrorIdentifier @@ -48,6 +50,6 @@ public function testNoParameterWithNullableTypeDeclarationRule(): void protected function getRule(): Rules\Rule { - return new Functions\NoParameterWithNullableTypeDeclarationRule(); + return new Functions\NoParameterWithNullableTypeDeclarationRule(new Analyzer()); } } diff --git a/test/Integration/Methods/NoNullableReturnTypeDeclarationRuleTest.php b/test/Integration/Methods/NoNullableReturnTypeDeclarationRuleTest.php index a565a4b7..d0cad8e6 100644 --- a/test/Integration/Methods/NoNullableReturnTypeDeclarationRuleTest.php +++ b/test/Integration/Methods/NoNullableReturnTypeDeclarationRuleTest.php @@ -13,12 +13,14 @@ namespace Ergebnis\PHPStan\Rules\Test\Integration\Methods; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\Methods; use Ergebnis\PHPStan\Rules\Test; use PHPStan\Rules; use PHPStan\Testing; /** + * @covers \Ergebnis\PHPStan\Rules\Analyzer * @covers \Ergebnis\PHPStan\Rules\Methods\NoNullableReturnTypeDeclarationRule * * @uses \Ergebnis\PHPStan\Rules\ErrorIdentifier @@ -76,6 +78,6 @@ public function testNoNullableReturnTypeDeclarationRule(): void protected function getRule(): Rules\Rule { - return new Methods\NoNullableReturnTypeDeclarationRule(); + return new Methods\NoNullableReturnTypeDeclarationRule(new Analyzer()); } } diff --git a/test/Integration/Methods/NoParameterWithNullDefaultValueRuleTest.php b/test/Integration/Methods/NoParameterWithNullDefaultValueRuleTest.php index 6783d93b..8c2e7c9d 100644 --- a/test/Integration/Methods/NoParameterWithNullDefaultValueRuleTest.php +++ b/test/Integration/Methods/NoParameterWithNullDefaultValueRuleTest.php @@ -13,12 +13,14 @@ namespace Ergebnis\PHPStan\Rules\Test\Integration\Methods; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\Methods; use Ergebnis\PHPStan\Rules\Test; use PHPStan\Rules; use PHPStan\Testing; /** + * @covers \Ergebnis\PHPStan\Rules\Analyzer * @covers \Ergebnis\PHPStan\Rules\Methods\NoParameterWithNullDefaultValueRule * * @uses \Ergebnis\PHPStan\Rules\ErrorIdentifier @@ -94,6 +96,6 @@ public function testNoParameterWithNullDefaultValueRule(): void protected function getRule(): Rules\Rule { - return new Methods\NoParameterWithNullDefaultValueRule(); + return new Methods\NoParameterWithNullDefaultValueRule(new Analyzer()); } } diff --git a/test/Integration/Methods/NoParameterWithNullableTypeDeclarationRuleTest.php b/test/Integration/Methods/NoParameterWithNullableTypeDeclarationRuleTest.php index c4f81442..fc7eceed 100644 --- a/test/Integration/Methods/NoParameterWithNullableTypeDeclarationRuleTest.php +++ b/test/Integration/Methods/NoParameterWithNullableTypeDeclarationRuleTest.php @@ -13,12 +13,14 @@ namespace Ergebnis\PHPStan\Rules\Test\Integration\Methods; +use Ergebnis\PHPStan\Rules\Analyzer; use Ergebnis\PHPStan\Rules\Methods; use Ergebnis\PHPStan\Rules\Test; use PHPStan\Rules; use PHPStan\Testing; /** + * @covers \Ergebnis\PHPStan\Rules\Analyzer * @covers \Ergebnis\PHPStan\Rules\Methods\NoParameterWithNullableTypeDeclarationRule * * @uses \Ergebnis\PHPStan\Rules\ErrorIdentifier @@ -76,6 +78,6 @@ public function testNoParameterWithNullableTypeDeclarationRule(): void protected function getRule(): Rules\Rule { - return new Methods\NoParameterWithNullableTypeDeclarationRule(); + return new Methods\NoParameterWithNullableTypeDeclarationRule(new Analyzer()); } }