Avoid exceptions on fetching uninitialized names in ClassLikes#10730
Avoid exceptions on fetching uninitialized names in ClassLikes#10730
Conversation
|
Previous comment from
I had something similar in my mind as well, but did not find a good way to "communicate" from the specific inner parts to the outer parts that would trigger those optimizations after codebase population. Basically like:
|
|
I did test it. While my crash pre-scanning the project files does not happen anymore, I got a crash while scanning the project files. |
3f7cce4 to
c6ad31a
Compare
It seems this is a new/different issue now. Can you try running Psalm single-threaded ( |
c6ad31a to
f6c76e5
Compare
|
It does not fail without threads (more details in the mentioned issue), but as far as I know the whole issue is at least mostly related to using multithreading. |
f6c76e5 to
e1d12f8
Compare
|
While working on additional tests for unknown/undefined interfaces used in intersections, I realized that the behavior is different. Thus the Thus, it seems there might be a much simpler solution than reprocessing, which is more in line with the rest of the assumptions in PsalmPHP:
I've updated the PR accordingly... |
Similar to the behavior of `ClassLikes::classImplements()` (vimeo#5984), the following methods will return a false/empty value in case a specific class name has not been initialized yet: + `ClassLikes::classExtends()` returns `false` + `ClassLikes::getParentInterfaces()` returns `[]`
e1d12f8 to
93e2c3e
Compare
|
Test cases explicitly expect an exception to infer further type checks... which feels super weird: psalm/tests/Internal/Codebase/InternalCallMapHandlerTest.php Lines 649 to 659 in 1c36da6
|
46c5e35 to
14da91a
Compare
Since the method `ClassLikes::classExtends()` is not throwning an exception anymore for unknown class names, the `CallMap` tests had to be adjusted to make the tested behavior a bit more explicit. Previously any class name that was unknown to the class-like storage of PsalmPHP, which however was existing in the native PHP scope (classes, interfaces or enums) was alread enough to make the type comparison succeed...
14da91a to
f80f840
Compare
|
I'll surrender now... still |
|
→ Phew... I'm dropping this change in favor of the original PR at #10720 |
Similar to the behavior of
ClassLikes::classImplements()(#5984),the following methods will return a false/empty value in case a
specific class name has not been initialized yet:
ClassLikes::classExtends()returnsfalseClassLikes::getParentInterfaces()returns[]Fixes: #7520
Fixes: #10350
Fixes: #10152