@@ -69,4 +69,70 @@ public function testUseStatementWithBracesAndBackslashAreCompiledCorrectly()
6969 $ string = "Foo @use(\SomeNamespace\{Foo, Bar}) bar " ;
7070 $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
7171 }
72+
73+ public function testUseStatementsWithModifiersAreCompiled ()
74+ {
75+ $ expected = 'Foo <?php use function \SomeNamespace\SomeFunction as Foo; ?> bar ' ;
76+
77+ $ string = "Foo @use('function SomeNamespace\SomeFunction', 'Foo') bar " ;
78+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
79+
80+ $ string = 'Foo @use(function SomeNamespace\SomeFunction, Foo) bar ' ;
81+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
82+ }
83+
84+ public function testUseStatementsWithModifiersWithoutAliasAreCompiled ()
85+ {
86+ $ expected = 'Foo <?php use const \SomeNamespace\SOME_CONST; ?> bar ' ;
87+
88+ $ string = "Foo @use('const SomeNamespace\SOME_CONST') bar " ;
89+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
90+
91+ $ string = 'Foo @use(const SomeNamespace\SOME_CONST) bar ' ;
92+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
93+ }
94+
95+ public function testUseStatementsWithModifiersAndBackslashAtBeginningAreCompiled ()
96+ {
97+ $ expected = 'Foo <?php use function \SomeNamespace\SomeFunction; ?> bar ' ;
98+
99+ $ string = "Foo @use('function \SomeNamespace\SomeFunction') bar " ;
100+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
101+
102+ $ string = 'Foo @use(function \SomeNamespace\SomeFunction) bar ' ;
103+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
104+ }
105+
106+ public function testUseStatementsWithModifiersBackslashAtBeginningAndAliasedAreCompiled ()
107+ {
108+ $ expected = 'Foo <?php use const \SomeNamespace\SOME_CONST as Foo; ?> bar ' ;
109+
110+ $ string = "Foo @use('const \SomeNamespace\SOME_CONST', 'Foo') bar " ;
111+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
112+
113+ $ string = 'Foo @use(const \SomeNamespace\SOME_CONST, Foo) bar ' ;
114+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
115+ }
116+
117+ public function testUseStatementsWithModifiersWithBracesAreCompiledCorrectly ()
118+ {
119+ $ expected = 'Foo <?php use function \SomeNamespace\{Foo, Bar}; ?> bar ' ;
120+
121+ $ string = "Foo @use('function SomeNamespace\{Foo, Bar}') bar " ;
122+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
123+
124+ $ string = 'Foo @use(function SomeNamespace\{Foo, Bar}) bar ' ;
125+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
126+ }
127+
128+ public function testUseFunctionStatementWithBracesAndBackslashAreCompiledCorrectly ()
129+ {
130+ $ expected = 'Foo <?php use const \SomeNamespace\{FOO, BAR}; ?> bar ' ;
131+
132+ $ string = "Foo @use('const \SomeNamespace\{FOO, BAR}') bar " ;
133+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
134+
135+ $ string = 'Foo @use(const \SomeNamespace\{FOO, BAR}) bar ' ;
136+ $ this ->assertEquals ($ expected , $ this ->compiler ->compileString ($ string ));
137+ }
72138}
0 commit comments