Skip to content

Commit

Permalink
Bugfix #390 reference checks on typed properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jnvsor committed Jul 12, 2022
1 parent 757b32d commit 055630e
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.
7 changes: 6 additions & 1 deletion src/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use Kint\Zval\Value;
use ReflectionObject;
use stdClass;
use TypeError;

class Parser
{
Expand Down Expand Up @@ -524,7 +525,11 @@ private function parseObject(&$var, Value $o)
}

$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
12 changes: 12 additions & 0 deletions tests/Parser/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,18 @@ public function testParseReferences()
$this->assertTrue($o->value->contents[0]->reference);
$this->assertFalse($o->value->contents[1]->reference);
$this->assertFalse($o->value->contents[2]->reference);

if (KINT_PHP74) {
$propval = 'test';
$v = new Php74TestClass();
$v->b = &$propval;

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

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

/**
Expand Down

0 comments on commit 055630e

Please sign in to comment.