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

Clean up unnecessary annotation

Ref #2111
This commit is contained in:
Brown 2019-09-09 11:20:47 -04:00
parent b49444b8ad
commit a1ea5c38c2
2 changed files with 2 additions and 11 deletions

View File

@ -627,8 +627,8 @@ class AssignmentAnalyzer
$method_pure_compatible = !empty($assign_var->var->inferredType->external_mutation_free)
|| isset($assign_var->var->pure);
if (($context->mutation_free
|| ($context->external_mutation_free && !$method_pure_compatible))
if (($context->mutation_free || $context->external_mutation_free)
&& !$method_pure_compatible
&& !$context->collect_mutations
&& !$context->collect_initializations
) {

View File

@ -125,9 +125,6 @@ class ImmutableAnnotationTest extends TestCase
$this->bar = $bar;
}
/**
* @psalm-external-mutation-free
*/
public function withBar(string $bar): self {
$new = new Foo("hello");
/** @psalm-suppress InaccessibleProperty */
@ -149,9 +146,6 @@ class ImmutableAnnotationTest extends TestCase
$this->bar = $bar;
}
/**
* @psalm-external-mutation-free
*/
public function withBar(string $bar): self {
$new = clone $this;
/** @psalm-suppress InaccessibleProperty */
@ -280,9 +274,6 @@ class ImmutableAnnotationTest extends TestCase
$this->bar = $bar;
}
/**
* @psalm-external-mutation-free
*/
public function withBar(Bar $b): Bar {
$new = clone $b;
$b->a = $this->bar;