From 055630e77a9ae625968ade09addb0bd57ce1f4b3 Mon Sep 17 00:00:00 2001 From: Jonathan Vollebregt Date: Tue, 12 Jul 2022 17:40:11 +0200 Subject: [PATCH] Bugfix #390 reference checks on typed properties --- build/kint.phar | Bin 408125 -> 408255 bytes src/Parser/Parser.php | 7 ++++++- tests/Parser/ParserTest.php | 12 ++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/build/kint.phar b/build/kint.phar index ba7792035729fe8671aac5863b56fbfdceac1cdc..f2d8265cbcce5cc725efaf1b40b7f46db5b238e1 100644 GIT binary patch delta 205 zcmdn{MPmO~i4B_E0$;rt7#jBJ$bjhDgBmxQExFq*xf!=xax>LB@Rk;*Duh%Pq`DRr z}cSHGPdctJrk)HYSznzI{xboN(#s@qJ9<(?3))aZImkW0ITxzlD`+x|mbGFTTleA!h%#2%8K1$XJ y9#Sc@ij}cC+H%Q;vrCz?%iyMO$eM-C>Qh$8J?vYzwy)g5ZYB!@1B1JhuM+?Wuuq); delta 151 zcmdo0RbuZKi4B_E0>xeo3=R8qWI(jknrmm9ExFq*xf!=xax>LBY(MJFRA@Ebr;SNv z`uR^RtkZc4na;N_Y-a*uW*}zSzObG3+9nSr4*d@=g)}CtczJ~{z(vt!(&axlnchEl zyxE>L{m;}@Q?~bC=RZ?^>qAp>qsofzQ?K4zM84J05B_FvzTJ(pMfNBQ0|SG*ldls1 DXr@6A diff --git a/src/Parser/Parser.php b/src/Parser/Parser.php index d658b0924..75781206b 100644 --- a/src/Parser/Parser.php +++ b/src/Parser/Parser.php @@ -34,6 +34,7 @@ use Kint\Zval\Value; use ReflectionObject; use stdClass; +use TypeError; class Parser { @@ -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; diff --git a/tests/Parser/ParserTest.php b/tests/Parser/ParserTest.php index 9d6f2994b..916662eb7 100644 --- a/tests/Parser/ParserTest.php +++ b/tests/Parser/ParserTest.php @@ -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); + } + } } /**