Skip to content

Commit

Permalink
Fix #2170 - allow @method annotations to override inherited immutable…
Browse files Browse the repository at this point in the history
… ones
  • Loading branch information
muglug committed Sep 25, 2019
1 parent 648dda6 commit 5e47cda
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Psalm/Internal/Analyzer/MethodAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ public static function compareMethods(

if ($guide_method_storage->external_mutation_free
&& !$implementer_method_storage->external_mutation_free
&& !$guide_method_storage->mutation_free_inferred
) {
if (IssueBuffer::accepts(
new MissingImmutableAnnotation(
Expand Down
17 changes: 17 additions & 0 deletions tests/ImmutableAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,23 @@ public function getData(): string {
}
}'
],
'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 {}',
],
];
}

Expand Down

0 comments on commit 5e47cda

Please sign in to comment.