1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Allow modification after clone in pure context

This commit is contained in:
Brown 2020-08-23 10:58:43 -04:00
parent c8ea4b4e8b
commit 39cc96a9d6

View File

@ -358,6 +358,32 @@ class PureAnnotationTest extends TestCase
return true;
}
return false;
}',
],
'allowPropertyAccessOnImmutableClassAfterCloneModification' => [
'<?php
namespace Bar;
/** @psalm-immutable */
class A {
public int $a;
public function __construct(int $a) {
$this->a = $a;
}
}
/** @psalm-pure */
function filterOdd(A $a) : bool {
$a = clone $a;
$a->a += 5;
if ($a->a % 2 === 0) {
return true;
}
return false;
}',
],