Commit 112deba
[Php81] ArrayToFirstClassCallableRector should not skip non-public methods from owning scope (#7760)
* test: Prove ArrayToFirstClassCallableRector skips internal callbacks
If a class contains array callbacks with a non-public method, they are
not converted into first-class callables. This is due to a fix for a bug
that was specific to skipping non-public methods referenced from
*outside* the owning class - there was no previous coverage for what
should happen when a callable is referenced within a valid scope.
* fix: ArrayToFirstClassCallableRector should convert private in own scope
If an array callable is explicitly referencing `$this`, then it should
always be safe to convert it to a first-class callable even if the
method is private / protected.
This was the original behaviour of the 8.1 fixers, but it changed in
v1.1.1 following a fix for cases where a private / protected method was
being referenced from outside the owning scope.
* Apply fixture class naming changes from code review
Co-authored-by: Abdul Malik Ikhsan <[email protected]>
---------
Co-authored-by: Abdul Malik Ikhsan <[email protected]>1 parent 7d158ab commit 112deba
File tree
2 files changed
+60
-7
lines changed- rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture
- rules/Php81/Rector/Array_
2 files changed
+60
-7
lines changedLines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
Lines changed: 25 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
126 | | - | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
| |||
133 | 134 | | |
134 | 135 | | |
135 | 136 | | |
136 | | - | |
137 | 137 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
| 138 | + | |
| 139 | + | |
143 | 140 | | |
144 | 141 | | |
145 | 142 | | |
| |||
174 | 171 | | |
175 | 172 | | |
176 | 173 | | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
177 | 195 | | |
0 commit comments