1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix #2170 - allow @method annotations to override inherited immutable ones

This commit is contained in:
Brown 2019-09-25 17:39:32 -04:00
parent 648dda67ed
commit 5e47cda6e5
2 changed files with 18 additions and 0 deletions

View File

@ -613,6 +613,7 @@ class MethodAnalyzer extends FunctionLikeAnalyzer
if ($guide_method_storage->external_mutation_free
&& !$implementer_method_storage->external_mutation_free
&& !$guide_method_storage->mutation_free_inferred
) {
if (IssueBuffer::accepts(
new MissingImmutableAnnotation(

View File

@ -219,6 +219,23 @@ class ImmutableAnnotationTest extends TestCase
}
}'
],
'allowMethodOverriding' => [
'<?php
class A {
private string $a;
public function __construct(string $a) {
$this->a = $a;
}
public function getA() : string {
return $this->a;
}
}
/** @method string getA() */
class B extends A {}',
],
];
}