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/Rules/Generics/PropertyVarianceRuleTest.php b/tests/PHPStan/Rules/Generics/PropertyVarianceRuleTest.php index 8998d9712e..b5aeefa8e9 100644 --- a/tests/PHPStan/Rules/Generics/PropertyVarianceRuleTest.php +++ b/tests/PHPStan/Rules/Generics/PropertyVarianceRuleTest.php @@ -132,4 +132,9 @@ public function testBug9153(): void $this->analyse([__DIR__ . '/data/bug-9153.php'], []); } + public function testBug13049(): void + { + $this->analyse([__DIR__ . '/data/bug-13049.php'], []); + } + } diff --git a/tests/PHPStan/Rules/Generics/data/bug-13049.php b/tests/PHPStan/Rules/Generics/data/bug-13049.php new file mode 100644 index 0000000000..86386bc019 --- /dev/null +++ b/tests/PHPStan/Rules/Generics/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; + } +}