From 71490e0f59f968b91d5c5c1ce576abfe9120fd74 Mon Sep 17 00:00:00 2001 From: Denny Septian Panggabean <97607754+ddevsr@users.noreply.github.com> Date: Fri, 15 Aug 2025 10:31:44 +0700 Subject: [PATCH 1/2] refactor: setAccessible no longer effect since PHP 8.1 Update ClassStaticsPlugin.php Update ClassStringsPluginTest.php Update DomPluginTest.php Update SimpleXMLElementPluginTest.php refactor: using constant KINT_PHP81 instead run composer format run composer build --- build/kint.phar | Bin 576372 -> 576489 bytes src/Parser/ClassStaticsPlugin.php | 4 +++- src/Parser/Parser.php | 5 ++++- tests/Parser/ClassStringsPluginTest.php | 17 ++++++++++++++--- tests/Parser/DomPluginTest.php | 17 ++++++++++++++--- tests/Parser/SimpleXMLElementPluginTest.php | 11 +++++++++-- 6 files changed, 44 insertions(+), 10 deletions(-) diff --git a/build/kint.phar b/build/kint.phar index dd651f7cd3a767d15b616bbbe1df2a7c5b0fe3bc..cb747409a752f1af1c018d470a5e97ebe0a3ae69 100644 GIT binary patch delta 350 zcmew|P5I??6@C^!6skl<6HsY_i(} zni)MSr#s}Zu}{8W!aDu*A4cWrs?1CRAjM)3CER}*Iaf?yV9m-hz4sI|r?8=dt*xy> zT4GLds-{9UmjVz>=UK|6G`)5YGskqEoy^?R^CH>BrvLxO%-J5clxcg|Qf4mk=?NAc4JU)*P z*VP}zc}QH~3Y)m(X5P=u6Ho78ElkmRlRInIS&;{AJo653Ok>PiBG~cD^qb9u%*?An bGHom~T6m_u3AvSCczret0|SG*ldls158Qx2 delta 276 zcmaDkUHQv2mL2k&%+%^a-LUo|m$PCxO7QEd9$CPt&_ zT{D?^w>va5MpjOr(8S0){oWr&f$2M@F^f)L`iD_@`u%t|+3nna897%>w^_<0HNAK{ zn?`%bQl{-4OPRUEryttGtUKMIfQ_S_YcDepvj8zG5VHX>`*yCq9MkzcVyf40FFY2Q ztW(b|HzAoTlxy14?+ihV7qixwwYBYZxfOCbu+C_@Or@E>Ut~ve)BmO|T&rVB1>7T- T7(QM%?W-LN0|SG*ldls1{^@6| diff --git a/src/Parser/ClassStaticsPlugin.php b/src/Parser/ClassStaticsPlugin.php index 8a18a00ae..0b5e616fc 100644 --- a/src/Parser/ClassStaticsPlugin.php +++ b/src/Parser/ClassStaticsPlugin.php @@ -136,7 +136,9 @@ private function buildStaticValue(ReflectionProperty $pr, int $depth): AbstractV $context->access_path = '\\'.$context->owner_class.'::$'.$context->name; } - $pr->setAccessible(true); + if (KINT_PHP81 === false) { + $pr->setAccessible(true); + } /** * @psalm-suppress TooFewArguments diff --git a/src/Parser/Parser.php b/src/Parser/Parser.php index 8548e4682..771e50e16 100644 --- a/src/Parser/Parser.php +++ b/src/Parser/Parser.php @@ -401,7 +401,10 @@ private function parseObject(object &$var, ContextInterface $c): AbstractValue $properties = []; foreach ($props as $rprop) { - $rprop->setAccessible(true); + if (KINT_PHP81 === false) { + $rprop->setAccessible(true); + } + $name = $rprop->getName(); // Casting object to array: diff --git a/tests/Parser/ClassStringsPluginTest.php b/tests/Parser/ClassStringsPluginTest.php index 53420684c..5ca992351 100644 --- a/tests/Parser/ClassStringsPluginTest.php +++ b/tests/Parser/ClassStringsPluginTest.php @@ -54,17 +54,28 @@ public function testConstruct() $reflector = new ReflectionClass($d); $mprop = $reflector->getProperty('methods_plugin'); - $mprop->setAccessible(true); + + if (KINT_PHP81 === false) { + $mprop->setAccessible(true); + } + $m = $mprop->getValue($d); $this->assertInstanceOf(ClassMethodsPlugin::class, $m); $sprop = $reflector->getProperty('statics_plugin'); - $sprop->setAccessible(true); + + if (KINT_PHP81 === false) { + $sprop->setAccessible(true); + } + $s = $sprop->getValue($d); $this->assertInstanceOf(ClassStaticsPlugin::class, $s); $reflector = new ReflectionClass(AbstractPlugin::class); $aparser = $reflector->getProperty('parser'); - $aparser->setAccessible(true); + + if (KINT_PHP81 === false) { + $aparser->setAccessible(true); + } $p = new Parser(); $this->assertNotSame($p, $aparser->getValue($m)); diff --git a/tests/Parser/DomPluginTest.php b/tests/Parser/DomPluginTest.php index 72b705a7c..5bd3d8c4a 100644 --- a/tests/Parser/DomPluginTest.php +++ b/tests/Parser/DomPluginTest.php @@ -115,17 +115,28 @@ public function testConstruct() $reflector = new ReflectionClass($d); $mprop = $reflector->getProperty('methods_plugin'); - $mprop->setAccessible(true); + + if (KINT_PHP81 === false) { + $mprop->setAccessible(true); + } + $m = $mprop->getValue($d); $this->assertInstanceOf(ClassMethodsPlugin::class, $m); $sprop = $reflector->getProperty('statics_plugin'); - $sprop->setAccessible(true); + + if (KINT_PHP81 === false) { + $sprop->setAccessible(true); + } + $s = $sprop->getValue($d); $this->assertInstanceOf(ClassStaticsPlugin::class, $s); $reflector = new ReflectionClass(AbstractPlugin::class); $aparser = $reflector->getProperty('parser'); - $aparser->setAccessible(true); + + if (KINT_PHP81 === false) { + $aparser->setAccessible(true); + } $p = new Parser(); $this->assertNotSame($p, $aparser->getValue($m)); diff --git a/tests/Parser/SimpleXMLElementPluginTest.php b/tests/Parser/SimpleXMLElementPluginTest.php index c0a15ed6e..8551ba51c 100644 --- a/tests/Parser/SimpleXMLElementPluginTest.php +++ b/tests/Parser/SimpleXMLElementPluginTest.php @@ -87,13 +87,20 @@ public function testConstruct() $reflector = new ReflectionClass($s); $mprop = $reflector->getProperty('methods_plugin'); - $mprop->setAccessible(true); + + if (KINT_PHP81 === false) { + $mprop->setAccessible(true); + } + $m = $mprop->getValue($s); $this->assertInstanceOf(ClassMethodsPlugin::class, $m); $reflector = new ReflectionClass(AbstractPlugin::class); $mparser = $reflector->getProperty('parser'); - $mparser->setAccessible(true); + + if (KINT_PHP81 === false) { + $mparser->setAccessible(true); + } $p = new Parser(); $this->assertNotSame($p, $mparser->getValue($m)); From ad382b5ecb1d1399cfb1a16d95f1cb5e220ec6e0 Mon Sep 17 00:00:00 2001 From: Jonathan Vollebregt Date: Sun, 17 Aug 2025 11:13:33 +0200 Subject: [PATCH 2/2] Build --- build/kint.phar | Bin 576489 -> 576489 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/build/kint.phar b/build/kint.phar index cb747409a752f1af1c018d470a5e97ebe0a3ae69..4ee8a7d0fb3455c8a4b47e61e5f00c54092bf07b 100644 GIT binary patch delta 196 zcmaDkUHRp7y=#iq|~Vlj2vQInbaXxAP(cs$6nU%A2b$_S?w5wI!7piQk+ZEqcx1#$d wo2};EDW>&7G1CqI?0)l@%X(&(n@AUv)XU?!)#q)mPdl&8!oa}b?&RwP0EG`y$^ZZW delta 214 zcmaDkUHRp7LO+WpIQF(gDe|CZC z3;r;QA=I^V|78SXCLm@8Viq7~1!A`C+<)1po%8r`UHws