psalm
psalm copied to clipboard
Assigment to private property of current class given child class is broken
https://psalm.dev/r/afe6df2159
I found these snippets:
https://psalm.dev/r/afe6df2159
<?php
class a {
private int $value = 0;
public function handle(a $v): void {
if ($v instanceof b) {
$v->value = 123;
} else {
$v->value = 321;
}
}
}
class b extends a {}
Psalm output (using commit f315647):
ERROR: UndefinedPropertyAssignment - 7:13 - Instance property b::$value is not defined
Ugh, I hate this thing so much I made a plugin to forbid this: https://github.com/orklah/psalm-strict-visibility
But I guess it's a valid issue still