1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Handle resources used as array keys consistently

Resources used as array keys are generally handled by throwing a
notice and converting the resource to the resource handle. The only
exception is the [$resource => null] syntax, where this was treated
as an illegal offset type instead. However, this also only happened
for VM evaluations, the AST evaluator did handle resources correctly.
This commit is contained in:
Nikita Popov
2019-09-27 10:39:21 +02:00
parent d71f859a56
commit a6c9c7c2b8
10 changed files with 147 additions and 41 deletions

View File

@@ -54,6 +54,10 @@ function normalizeOutput(string $out): string {
$out = preg_replace('/^#(\d+) \/.+\(\d+\):/m', '#$1 %s(%d):', $out);
$out = preg_replace('/Resource id #\d+/', 'Resource id #%d', $out);
$out = preg_replace('/resource\(\d+\) of type/', 'resource(%d) of type', $out);
$out = preg_replace(
'/Resource ID#\d+ used as offset, casting to integer \(\d+\)/',
'Resource ID#%d used as offset, casting to integer (%d)',
$out);
$out = preg_replace('/string\(\d+\) "([^"]*%d)/', 'string(%d) "$1', $out);
return $out;
}