diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 009e36ddf6..246d46dee0 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -150,12 +150,6 @@ parameters: count: 1 path: src/Collectors/Registry.php - - - rawMessage: Anonymous function has an unused use $container. - identifier: closure.unusedUse - count: 1 - path: src/Command/CommandHelper.php - - rawMessage: 'Call to static method expand() of internal class Nette\DI\Helpers from outside its root namespace Nette.' identifier: staticMethod.internalClass @@ -771,12 +765,6 @@ parameters: count: 1 path: src/Testing/LevelsTestCase.php - - - rawMessage: Anonymous function has an unused use $container. - identifier: closure.unusedUse - count: 1 - path: src/Testing/PHPStanTestCase.php - - rawMessage: 'Doing instanceof PHPStan\Type\ConstantScalarType is error-prone and deprecated. Use Type::isConstantScalarValue() or Type::getConstantScalarTypes() or Type::getConstantScalarValues() instead.' identifier: phpstanApi.instanceofType diff --git a/src/Rules/UnusedFunctionParametersCheck.php b/src/Rules/UnusedFunctionParametersCheck.php index d35d5c4a36..f577eaa39b 100644 --- a/src/Rules/UnusedFunctionParametersCheck.php +++ b/src/Rules/UnusedFunctionParametersCheck.php @@ -79,6 +79,9 @@ private function getUsedVariables(Scope $scope, $node): array return $scope->getDefinedVariables(); } } + if ($node instanceof Node\Expr\Include_ || $node instanceof Node\Expr\Eval_) { + return $scope->getDefinedVariables(); + } if ($node instanceof Variable && is_string($node->name) && $node->name !== 'this') { return [$node->name]; } diff --git a/tests/PHPStan/Rules/Classes/UnusedConstructorParametersRuleTest.php b/tests/PHPStan/Rules/Classes/UnusedConstructorParametersRuleTest.php index 3550be5799..0977a37b1b 100644 --- a/tests/PHPStan/Rules/Classes/UnusedConstructorParametersRuleTest.php +++ b/tests/PHPStan/Rules/Classes/UnusedConstructorParametersRuleTest.php @@ -76,4 +76,9 @@ public function testBug11454(): void $this->analyse([__DIR__ . '/data/bug-11454.php'], []); } + public function testParameterUsedInIncludedFile(): void + { + $this->analyse([__DIR__ . '/data/unused-constructor-parameters-include.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Classes/data/unused-constructor-parameters-include.php b/tests/PHPStan/Rules/Classes/data/unused-constructor-parameters-include.php new file mode 100644 index 0000000000..790f535f6e --- /dev/null +++ b/tests/PHPStan/Rules/Classes/data/unused-constructor-parameters-include.php @@ -0,0 +1,15 @@ +