File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -175,12 +175,15 @@ private function transform_and_set(array $action): string
175
175
176
176
private function set (array $ action ): string
177
177
{
178
- $ key = key ($ action );
179
- $ this ->variables [] = $ action [$ key ];
180
- return YamlTests::render (self ::TEMPLATE_SET_VARIABLE , [
181
- ':var ' => $ action [$ key ],
182
- ':value ' => $ this ->convertResponseField ($ key )
183
- ]);
178
+ $ output = '' ;
179
+ foreach ($ action as $ key => $ var ) {
180
+ $ this ->variables [] = $ var ;
181
+ $ output .= YamlTests::render (self ::TEMPLATE_SET_VARIABLE , [
182
+ ':var ' => $ var ,
183
+ ':value ' => $ this ->convertResponseField ($ key )
184
+ ]);
185
+ }
186
+ return $ output ;
184
187
}
185
188
186
189
private function warnings (array $ action , array &$ vars )
Original file line number Diff line number Diff line change @@ -291,6 +291,9 @@ public function build(): array
291
291
]
292
292
);
293
293
}
294
+ // Fix ${var} string interpolation deprecated for PHP 8.2
295
+ // @see https://php.watch/versions/8.2/$%7Bvar%7D-string-interpolation-deprecated
296
+ $ test = $ this ->fixStringInterpolationInCurlyBracket ($ test );
294
297
file_put_contents ($ testDirName . '/ ' . $ testName . '.php ' , $ test );
295
298
try {
296
299
eval (substr ($ test , 5 )); // remove <?php header
@@ -309,6 +312,16 @@ public function build(): array
309
312
];
310
313
}
311
314
315
+ /**
316
+ * Convert ${var} in {$var} for PHP 8.2 deprecation notice
317
+ *
318
+ * @see https://php.watch/versions/8.2/$%7Bvar%7D-string-interpolation-deprecated
319
+ */
320
+ private function fixStringInterpolationInCurlyBracket (string $ code ): string
321
+ {
322
+ return preg_replace ('/\${([^}]+)}/ ' , '{\$$1} ' , $ code );
323
+ }
324
+
312
325
private function extractTestNamespace (string $ path )
313
326
{
314
327
$ file = substr ($ path , strlen ($ this ->testDir ) + 1 );
You can’t perform that action at this time.
0 commit comments