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:
parent
c8ea4b4e8b
commit
39cc96a9d6
@ -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;
|
||||
}',
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user