vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.57k stars 660 forks source link

Can't template based on the output of a pure function called on an input param #11121

Open jnvsor opened 1 month ago

jnvsor commented 1 month ago

https://psalm.dev/r/9f37666cc3

ReflectionFunctionAbstract->isInternal is stubbed pure in psalm, but there's no way to template based on the output of it.

It would also be nice to be able to template based on arbitrary constructor assignments to uninitialized properties.

psalm-github-bot[bot] commented 1 month ago

I found these snippets:

https://psalm.dev/r/9f37666cc3 ```php internal = $callable->isInternal(); $t = $callable->getFileName(); $this->filename = false === $t ? null : $t; $t = $callable->getStartLine(); $this->startline = false === $t ? null : $t; $t = $callable->getEndLine(); $this->endline = false === $t ? null : $t; } } ``` ``` Psalm output (using commit 03ee02c): ERROR: InvalidPropertyAssignmentValue - 21:27 - $this->internal with declared type 'I:DeclaredCallableBag as bool' cannot be assigned type 'bool' ```