Skip to content

Commit b65af1d

Browse files
authored
Merge pull request glayzzle#934 from czosel/subnamespace-test-2
fix: correctly parse subnamespaces
2 parents 2add1b6 + f496b4e commit b65af1d

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

src/parser/namespace.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ module.exports = {
169169
this.next();
170170
if (typed) {
171171
if (
172+
this.token !== this.tok.T_NAME_RELATIVE &&
173+
this.token !== this.tok.T_NAME_QUALIFIED &&
174+
this.token !== this.tok.T_NAME_FULLY_QUALIFIED &&
172175
this.token !== this.tok.T_FUNCTION &&
173176
this.token !== this.tok.T_CONST &&
174177
this.token !== this.tok.T_STRING

test/snapshot/__snapshots__/usegroup.test.js.snap

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,34 @@ Program {
173173
}
174174
`;
175175

176+
exports[`usegroup nested 4 1`] = `
177+
Program {
178+
"children": Array [
179+
UseGroup {
180+
"items": Array [
181+
UseItem {
182+
"alias": null,
183+
"kind": "useitem",
184+
"name": "SubnamespaceOne\\\\ClassA",
185+
"type": null,
186+
},
187+
UseItem {
188+
"alias": null,
189+
"kind": "useitem",
190+
"name": "SubnamespaceOne\\\\ClassB",
191+
"type": null,
192+
},
193+
],
194+
"kind": "usegroup",
195+
"name": "Vendor\\\\Package\\\\SomeNamespace",
196+
"type": null,
197+
},
198+
],
199+
"errors": Array [],
200+
"kind": "program",
201+
}
202+
`;
203+
176204
exports[`usegroup simple 1`] = `
177205
Program {
178206
"children": Array [

test/snapshot/usegroup.test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,14 @@ describe("usegroup", () => {
3535
)
3636
).toMatchSnapshot();
3737
});
38+
it("nested 4", () => {
39+
expect(
40+
parser.parseEval(
41+
`use Vendor\\Package\\SomeNamespace\\{
42+
SubnamespaceOne\\ClassA,
43+
SubnamespaceOne\\ClassB
44+
};`
45+
)
46+
).toMatchSnapshot();
47+
});
3848
});

0 commit comments

Comments
 (0)