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