Open Sahtii opened 3 months ago
Looks like it works as designed: the __get
always throws an exception (and returns never
), so:
code 1
$row->variable
code 2
"code 2" in this example will not be executed.
What here I do not understand?
Anyway, feel free to create a small reproducing repository, so I can better understand the problem. Thanks.
Problem is that $row can have property variable (it is universal objevt crate) but PHPStan thinks it always terminates.
@MartinMystikJonas Exactly, $row->variable
works without any issues and doesn't throw any errors (in our code), because the column variable
is selected from the database.
I understand now. The class doesn't have __set
so properties are assigned as "dynamic" properties. The __get
is only executed for properties that do not exist.
I say this class needs to be removed from universalObjectCratesClasses
(https://github.com/phpstan/phpstan-nette/blob/8af94743efcc6d1e685f2ffd7ab279e39c96429c/extension.neon#L31) and needs its own PropertiesClassReflectionExtension.
And is this work for you or for someone else?
Anyone who wants it fixed ;) (I'll probably not get to it anytime soon.)
Unreachable statement - code above always terminates. PHPStan wrongly assumes that this code in Nette\Database\Row always throws Exception and assumes that the further code will not execute. This was not a case in Nette 3.1, problem occured after updating to Nette 3.2
This happens for example for code