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

Fix #2116 - allow property set inside unserialize

This commit is contained in:
Brown 2019-09-10 10:31:46 -04:00
parent deb36e8b27
commit 8784812739
2 changed files with 28 additions and 1 deletions

View File

@ -628,7 +628,8 @@ class PropertyAssignmentAnalyzer
&& ($appearing_property_class === $context->self
|| $codebase->classExtends($context->self, $appearing_property_class))
&& (!$context->calling_method_id
|| \strpos($context->calling_method_id, '::__construct'))
|| \strpos($context->calling_method_id, '::__construct')
|| \strpos($context->calling_method_id, '::unserialize'))
)
) {
if (IssueBuffer::accepts(

View File

@ -193,6 +193,32 @@ class ImmutableAnnotationTest extends TestCase
}
}'
],
'allowPropertyAssignmentInUnserialize' => [
'<?php
/**
* @psalm-immutable
*/
class Foo implements \Serializable {
/** @var string */
private $data;
public function __construct() {
$this->data = "Foo";
}
public function serialize() {
return $this->data;
}
public function unserialize($data) {
$this->data = $data;
}
public function getData(): string {
return $this->data;
}
}'
],
];
}