Commit 3dd91e2
committed
Generic/DuplicateClassName: bug fix - namespace is reset on PHP open tag
As things were, the sniff listens to the `T_OPEN_TAG` token, processes the file until the first `T_CLOSE_TAG` and then waits again for a new `T_OPEN_TAG`.
However, every time the sniff is called, the namespace is reset, even when still processing the same file, i.e. when the namespace is still in effect.
This led to both false positives as well as false negatives.
Fixed now, by always processing the complete file in one go and not returning on a `T_CLOSE_TAG`.
Includes unit tests.1 parent 9c7cffe commit 3dd91e2
File tree
4 files changed
+24
-7
lines changed- src/Standards/Generic
- Sniffs/Classes
- Tests/Classes
4 files changed
+24
-7
lines changedLines changed: 2 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
63 | 62 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | 63 | | |
71 | 64 | | |
72 | 65 | | |
| |||
120 | 113 | | |
121 | 114 | | |
122 | 115 | | |
| 116 | + | |
| 117 | + | |
123 | 118 | | |
124 | 119 | | |
125 | 120 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 13 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 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
| |||
0 commit comments