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:
parent
d06510833b
commit
1bb204db76
@ -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;
|
||||
|
@ -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',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user