mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Fix #2170 - allow @method annotations to override inherited immutable ones
This commit is contained in:
parent
648dda67ed
commit
5e47cda6e5
@ -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(
|
||||
|
@ -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 {}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user