Commit 978114e
Use AlwaysRememberedExpr to bypass impurity check for class_exists type narrowing
Instead of incorrectly marking class_exists, interface_exists, trait_exists,
and enum_exists as having no side effects (they trigger autoloading),
wrap the FuncCall in AlwaysRememberedExpr in ClassExistsFunctionTypeSpecifyingExtension.
This bypasses the rememberPossiblyImpureFunctionValues check in TypeSpecifier::createForExpr()
while keeping the correct hasSideEffects semantics.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 910e8bc commit 978114e
3 files changed
Lines changed: 7 additions & 8 deletions
File tree
- resources
- src/Type/Php
- tests/PHPStan/Reflection/BetterReflection/SourceLocator
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
812 | 812 | | |
813 | 813 | | |
814 | 814 | | |
815 | | - | |
816 | 815 | | |
817 | 816 | | |
818 | 817 | | |
| |||
911 | 910 | | |
912 | 911 | | |
913 | 912 | | |
914 | | - | |
915 | 913 | | |
916 | 914 | | |
917 | 915 | | |
| |||
1192 | 1190 | | |
1193 | 1191 | | |
1194 | 1192 | | |
1195 | | - | |
1196 | 1193 | | |
1197 | 1194 | | |
1198 | 1195 | | |
| |||
1726 | 1723 | | |
1727 | 1724 | | |
1728 | 1725 | | |
1729 | | - | |
1730 | 1726 | | |
1731 | 1727 | | |
1732 | 1728 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
50 | 55 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 56 | + | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
0 commit comments