diff --git a/src/PhpDoc/ResolvedPhpDocBlock.php b/src/PhpDoc/ResolvedPhpDocBlock.php index 67715871fda..f69a49e254f 100644 --- a/src/PhpDoc/ResolvedPhpDocBlock.php +++ b/src/PhpDoc/ResolvedPhpDocBlock.php @@ -180,9 +180,11 @@ public function merge(array $parents, array $parentPhpDocBlocks): self // skip $result->phpDocNode // skip $result->phpDocString - just for stubs $phpDocNodes = $this->phpDocNodes; + $acceptsNamedArguments = $this->acceptsNamedArguments(); foreach ($parents as $parent) { foreach ($parent->phpDocNodes as $phpDocNode) { $phpDocNodes[] = $phpDocNode; + $acceptsNamedArguments = $acceptsNamedArguments && $parent->acceptsNamedArguments(); } } $result->phpDocNodes = $phpDocNodes; @@ -210,7 +212,7 @@ public function merge(array $parents, array $parentPhpDocBlocks): self $result->isPure = $this->isPure(); $result->isReadOnly = $this->isReadOnly(); $result->hasConsistentConstructor = $this->hasConsistentConstructor(); - $result->acceptsNamedArguments = $this->acceptsNamedArguments(); + $result->acceptsNamedArguments = $acceptsNamedArguments; return $result; } diff --git a/tests/PHPStan/Analyser/data/no-named-arguments.php b/tests/PHPStan/Analyser/data/no-named-arguments.php index 9e0ef479d6a..6b9e6507cb8 100644 --- a/tests/PHPStan/Analyser/data/no-named-arguments.php +++ b/tests/PHPStan/Analyser/data/no-named-arguments.php @@ -12,7 +12,7 @@ function noNamedArgumentsInFunction(float ...$args) assertType('array', $args); } -class Baz +class Baz extends Foo implements Bar { /** * @no-named-arguments @@ -21,4 +21,30 @@ public function noNamedArgumentsInMethod(float ...$args) { assertType('array', $args); } + + public function noNamedArgumentsInParent(float ...$args) + { + assertType('array', $args); + } + + public function noNamedArgumentsInInterface(float ...$args) + { + assertType('array', $args); + } +} + +abstract class Foo +{ + /** + * @no-named-arguments + */ + abstract public function noNamedArgumentsInParent(float ...$args); +} + +interface Bar +{ + /** + * @no-named-arguments + */ + public function noNamedArgumentsInInterface(); }