Skip to content

Commit

Permalink
Don't call ReflectionProperty::isInitialized for php < 7.4 / fix Obje…
Browse files Browse the repository at this point in the history
…ctTest::testInterface()
  • Loading branch information
bkdotcom committed Sep 9, 2024
1 parent fb48067 commit b9117f7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Debug/Abstraction/Object/PropertiesInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ private function valueFromReflection(array $propInfo, Abstraction $abs, Reflecti
}
return Abstracter::NOT_INSPECTED;
}
if ($refProperty->isInitialized($obj) === false) {
$isInitialized = PHP_VERSION_ID < 70400 || $refProperty->isInitialized($obj);
if ($isInitialized === false) {
return $propInfo['value']; // undefined
}
if (PHP_VERSION_ID >= 80400 && $propInfo['isStatic'] === false) {
Expand Down
5 changes: 3 additions & 2 deletions tests/Debug/DebugTestFramework.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DebugTestFramework extends DOMTestCase
protected $file;
protected $line;

private static $errorHandlerPrev;
protected static $errorHandlerPrev;

/**
* Constructor
Expand Down Expand Up @@ -344,9 +344,10 @@ public function testMethod($method = null, $args = array(), array $tests = array
$trace = $e->getTrace();
$file = $e->getFile();
$line = $e->getLine();
// \bdk\Debug::varDump('exception', $e->getMessage(), $file, $line);
for ($i = 0, $count = \count($trace); $i < $count; $i++) {
$frame = $trace[$i];
if (isset($frame['class']) && \strpos($frame['class'], __NAMESPACE__) === 0) {
if (isset($frame['class']) && \strpos($frame['class'], __NAMESPACE__) === 0 && isset($trace[$i - 1])) {
$file = $trace[$i - 1]['file'];
$line = $trace[$i - 1]['line'];
break;
Expand Down
3 changes: 2 additions & 1 deletion tests/Debug/Type/ObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,8 @@ public function testInterface()
</li>
</ul>
</dd>';
self::assertStringContainsString(preg_replace('/^\s+/m', $expect, ''), $html);
$expect = \preg_replace('/^\s+/m', '', $expect);
self::assertStringContainsString($expect, $html);
self::assertStringNotContainsString('<dt>implements</dt>', $html);
},
)
Expand Down

0 comments on commit b9117f7

Please sign in to comment.