@@ -153,4 +153,29 @@ public function testParseAssignOperator(): void
153153 $ this ->assertSame (18 , $ vars [13 ]->lineNumber );
154154 $ this ->assertSame (true , $ vars [13 ]->assigned );
155155 }
156+
157+ public function testInterpolatedStringFunction (): void
158+ {
159+ $ parser = new VariableParser ();
160+ $ content = file_get_contents ($ this ->fixtureDir . '/interpolated_string.php ' );
161+ $ result = $ parser ->parse ($ content );
162+
163+ $ this ->assertInstanceOf (ParseResult::class, $ result );
164+ $ functions = $ result ->functions ;
165+ $ this ->assertCount (1 , $ functions );
166+ $ this ->assertSame ('test ' , $ functions [0 ]->name );
167+ $ this ->assertSame (null , $ functions [0 ]->namespace );
168+ $ this ->assertCount (3 , $ functions [0 ]->getVariables ());
169+
170+ $ vars = $ functions [0 ]->getVariables ();
171+ $ this ->assertSame ('name ' , $ vars [0 ]->name );
172+ $ this ->assertSame (3 , $ vars [0 ]->lineNumber , 'first $name ' );
173+ $ this ->assertSame (false , $ vars [0 ]->assigned , 'first $name ' );
174+ $ this ->assertSame ('${"Hello, {$name}!"} ' , $ vars [1 ]->name , '${"Hello, {$name}! ' );
175+ $ this ->assertSame (5 , $ vars [1 ]->lineNumber , 'interpolated_string ' );
176+ $ this ->assertSame (false , $ vars [1 ]->assigned , 'interpolated_string not reference ' );
177+ $ this ->assertSame ('name ' , $ vars [2 ]->name );
178+ $ this ->assertSame (5 , $ vars [2 ]->lineNumber , 'second $name (10) ' );
179+ $ this ->assertSame (false , $ vars [2 ]->assigned , 'second $name (10) not reference ' );
180+ }
156181}
0 commit comments