Skip to content

Commit

Permalink
Fix #390 edge case when typed properties are referenced in arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
jnvsor committed Jun 26, 2023
1 parent efdcb51 commit a700653
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Binary file modified build/kint.phar
Binary file not shown.
6 changes: 5 additions & 1 deletion src/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,11 @@ private function parseArray(array &$var, Value $o): Value
}

$stash = $val;
$copy[$i] = $refmarker;
try {
$copy[$i] = $refmarker;
} catch (TypeError $e) {
$child->reference = true;
}
if ($val === $refmarker) {
$child->reference = true;
$val = $stash;
Expand Down
13 changes: 13 additions & 0 deletions tests/Parser/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,19 @@ public function testParseReferences()
foreach ($o->value->contents as $val) {
$this->assertSame('b' === $val->name, $val->reference);
}

$v = new Php74TestClass();
$v->b = 'test';
$a = [
'testval' => $v->b,
'testref' => &$v->b,
];

$o = $p->parse($a, clone $b);

foreach ($o->value->contents as $val) {
$this->assertSame('testref' === $val->name, $val->reference);
}
}
}

Expand Down

0 comments on commit a700653

Please sign in to comment.