Skip to content

Commit a700653

Browse files
committed
Fix #390 edge case when typed properties are referenced in arrays
1 parent efdcb51 commit a700653

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

build/kint.phar

115 Bytes
Binary file not shown.

src/Parser/Parser.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,11 @@ private function parseArray(array &$var, Value $o): Value
374374
}
375375

376376
$stash = $val;
377-
$copy[$i] = $refmarker;
377+
try {
378+
$copy[$i] = $refmarker;
379+
} catch (TypeError $e) {
380+
$child->reference = true;
381+
}
378382
if ($val === $refmarker) {
379383
$child->reference = true;
380384
$val = $stash;

tests/Parser/ParserTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,19 @@ public function testParseReferences()
583583
foreach ($o->value->contents as $val) {
584584
$this->assertSame('b' === $val->name, $val->reference);
585585
}
586+
587+
$v = new Php74TestClass();
588+
$v->b = 'test';
589+
$a = [
590+
'testval' => $v->b,
591+
'testref' => &$v->b,
592+
];
593+
594+
$o = $p->parse($a, clone $b);
595+
596+
foreach ($o->value->contents as $val) {
597+
$this->assertSame('testref' === $val->name, $val->reference);
598+
}
586599
}
587600
}
588601

0 commit comments

Comments
 (0)