Skip to content

Commit

Permalink
Merge pull request #8749 from Nicelocal/fix_8748
Browse files Browse the repository at this point in the history
Fix #8748
  • Loading branch information
orklah committed Nov 24, 2022
2 parents 40df3f3 + 5ac60dd commit bca202b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Expand Up @@ -158,7 +158,7 @@ public static function analyze(
&& !isset($class_storage->declaring_property_ids[$name]);

if ($this_property_didnt_exist) {
$context->vars_in_scope[$mutation_var_id] = Type::getMixed();
unset($context->vars_in_scope[$mutation_var_id]);
} else {
$new_type = AssignmentAnalyzer::getExpandedPropertyType(
$codebase,
Expand Down
35 changes: 35 additions & 0 deletions tests/MagicPropertyTest.php
Expand Up @@ -731,6 +731,41 @@ public function __set(string $_prop, $_value) {}
$a->type = A::TYPE_B;
',
],
'impureMethodTest' => [
'code' => '<?php
/**
* @property array<string, string> $errors
*
* @psalm-seal-properties
*/
final class OrganizationObject {
public function __get(string $key)
{
return [];
}
/**
* @param mixed $a
*/
public function __set(string $key, $a): void
{
}
public function updateErrors(): void {
/** @var array<string, string> */
$errors = [];
$this->errors = $errors;
}
/** @return array<string, string> */
public function updateStatus(): array {
$_ = $this->errors;
$this->updateErrors();
$errors = $this->errors;
return $errors;
}
}'
]
];
}

Expand Down

0 comments on commit bca202b

Please sign in to comment.