diff --git a/src/Analyser/NodeScopeResolver.php b/src/Analyser/NodeScopeResolver.php index 8ff656bb57..bbfdb61615 100644 --- a/src/Analyser/NodeScopeResolver.php +++ b/src/Analyser/NodeScopeResolver.php @@ -651,7 +651,7 @@ private function processStmtNode( $throwPoints = []; $impurePoints = []; $this->processAttributeGroups($stmt, $stmt->attrGroups, $scope, $nodeCallback); - [$templateTypeMap, $phpDocParameterTypes, $phpDocImmediatelyInvokedCallableParameters, $phpDocClosureThisTypeParameters, $phpDocReturnType, $phpDocThrowType, $deprecatedDescription, $isDeprecated, $isInternal, $isFinal, $isPure, $acceptsNamedArguments, , $phpDocComment, $asserts, $selfOutType, $phpDocParameterOutTypes] = $this->getPhpDocs($scope, $stmt); + [$templateTypeMap, $phpDocParameterTypes, $phpDocImmediatelyInvokedCallableParameters, $phpDocClosureThisTypeParameters, $phpDocReturnType, $phpDocThrowType, $deprecatedDescription, $isDeprecated, $isInternal, $isFinal, $isPure, $acceptsNamedArguments, $isReadOnly, $phpDocComment, $asserts, $selfOutType, $phpDocParameterOutTypes] = $this->getPhpDocs($scope, $stmt); foreach ($stmt->params as $param) { $this->processParamNode($stmt, $param, $scope, $nodeCallback); @@ -718,7 +718,7 @@ private function processStmtNode( true, $isFromTrait, $param, - false, + $isReadOnly, $scope->isInTrait(), $classReflection->isReadOnly(), false, diff --git a/tests/PHPStan/Analyser/Bug13049Test.php b/tests/PHPStan/Analyser/Bug13049Test.php new file mode 100644 index 0000000000..e37a2d94d1 --- /dev/null +++ b/tests/PHPStan/Analyser/Bug13049Test.php @@ -0,0 +1,26 @@ + + */ +class Bug13049Test extends RuleTestCase +{ + + protected function getRule(): Rule + { + return new PropertyVarianceRule(new VarianceCheck()); + } + + public function testRule(): void + { + $this->analyse([__DIR__ . '/data/bug-13049.php'], []); + } + +} diff --git a/tests/PHPStan/Analyser/data/bug-13049.php b/tests/PHPStan/Analyser/data/bug-13049.php new file mode 100644 index 0000000000..86386bc019 --- /dev/null +++ b/tests/PHPStan/Analyser/data/bug-13049.php @@ -0,0 +1,41 @@ += 8.0 + +declare(strict_types = 1); + +namespace Bug13049; + +/** + * @template-covariant Value of string|list + * + * @immutable + */ +final class LanguageProperty +{ + + /** @var Value */ + public $value; + + /** + * @param Value $value + */ + public function __construct($value) + { + $this->value = $value; + } +} + +/** + * @template-covariant Value of string|list + * + * @immutable + */ +final class LanguageProperty2 +{ + /** + * @param Value $value + */ + public function __construct(public $value) + { + $this->value = $value; + } +}