1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix detecting readonly promoted property visibility

This commit is contained in:
Aaron Piotrowski 2021-11-13 12:50:02 -06:00
parent d06510833b
commit 1bb204db76
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
2 changed files with 15 additions and 1 deletions

View File

@ -637,7 +637,7 @@ class FunctionLikeNodeScanner
$property_id = $fq_classlike_name . '::$' . $param_storage->name;
switch ($param->flags) {
switch ($param->flags & \PhpParser\Node\Stmt\Class_::VISIBILITY_MODIFIER_MASK) {
case \PhpParser\Node\Stmt\Class_::MODIFIER_PUBLIC:
$property_storage->visibility = ClassLikeAnalyzer::VISIBILITY_PUBLIC;
$classlike_storage->inheritable_property_ids[$param_storage->name] = $property_id;

View File

@ -257,6 +257,20 @@ class ReadonlyPropertyTest extends TestCase
false,
'8.1',
],
'readonlyPromotedPropertyAccess' => [
'<?php
class A {
public function __construct(private readonly string $bar) {
}
}
$a = new A("hello");
$b = $a->bar;',
'error_message' => 'InaccessibleProperty - src' . DIRECTORY_SEPARATOR . 'somefile.php:8:26',
[],
false,
'8.1',
],
];
}
}