Commit 7d6a5c4
Use traverseSimultaneously to properly handle null removal in GenericObjectType type arguments
Instead of completely blocking traversal into GenericObjectType, use
traverseSimultaneously to pair up accepted and accepting type arguments.
Only remove null from accepted type arguments where the corresponding
accepting type argument does not contain null.
This ensures that:
- Container<string|null> accepted where Container<string|null> is expected
does not produce a false positive (null not removed when accepting also has null)
- Container<string|null> accepted where Container<string> is expected
correctly has null removed (accepted matches after transformation)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent b47de29 commit 7d6a5c4
File tree
2 files changed
+36
-0
lines changed- src/Rules
- tests/PHPStan/Rules/Methods/data
2 files changed
+36
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
131 | 141 | | |
132 | 142 | | |
133 | 143 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
0 commit comments