diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6906e22da9..7c5d2f6b20 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -132,12 +132,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 @@ -759,12 +753,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..7f1b497d05 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_) { + return $scope->getDefinedVariables(); + } if ($node instanceof Variable && is_string($node->name) && $node->name !== 'this') { return [$node->name]; } diff --git a/tests/PHPStan/Rules/Functions/UnusedClosureUsesRuleTest.php b/tests/PHPStan/Rules/Functions/UnusedClosureUsesRuleTest.php index 137257162c..86ff28ca4e 100644 --- a/tests/PHPStan/Rules/Functions/UnusedClosureUsesRuleTest.php +++ b/tests/PHPStan/Rules/Functions/UnusedClosureUsesRuleTest.php @@ -35,4 +35,9 @@ public function testUnusedClosureUses(): void ]); } + public function testBug13960(): void + { + $this->analyse([__DIR__ . '/data/bug-13960.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Functions/data/bug-13960.php b/tests/PHPStan/Rules/Functions/data/bug-13960.php new file mode 100644 index 0000000000..82dcb25e1b --- /dev/null +++ b/tests/PHPStan/Rules/Functions/data/bug-13960.php @@ -0,0 +1,21 @@ +