Skip to content
Permalink
Browse files

Fix #1869 - don’t memoize magic properties after set

  • Loading branch information...
muglug committed Jul 6, 2019
1 parent cd33430 commit d29c7b42d93f9f06cfd9f45cd176b63e70015cda
@@ -365,6 +365,16 @@ public static function analyzeInstance(
}
if ($assignment_value) {
if ($var_id) {
$context->removeVarFromConflictingClauses(
$var_id,
Type::getMixed(),
$statements_analyzer
);
unset($context->vars_in_scope[$var_id]);
}
$fake_method_call = new PhpParser\Node\Expr\MethodCall(
$stmt->var,
new PhpParser\Node\Identifier('__set', $stmt->name->getAttributes()),
@@ -517,6 +517,35 @@ public function takesString(string $s): void {}
$a = new A();
$a->takesString($a->foo);',
],
'removeAssertionsAfterCall' => [
'<?php
class C {
/**
* @return mixed
*/
public function __get(string $name) {
return rand();
}
/**
* @param mixed $value
* @return void
*/
public function __set(string $name, $value) {}
public function main() : void {
if (!isset($this->a)) {
$this->a = ["something"];
/**
* @psalm-suppress MixedArrayAccess
* @psalm-suppress MixedArgument
*/
echo $this->a[0];
}
}
}'
],
];
}

0 comments on commit d29c7b4

Please sign in to comment.
You can’t perform that action at this time.