Browse Source

Add array cast to result of debugInfo to fix iteration issues.

Mark Story 3 years ago
parent
commit
a91a54a72a
2 changed files with 2 additions and 3 deletions
  1. 1 1
      src/Error/Debugger.php
  2. 1 2
      tests/TestCase/Error/DebuggerTest.php

+ 1 - 1
src/Error/Debugger.php

@@ -782,7 +782,7 @@ class Debugger
         if ($remaining > 0) {
             if (method_exists($var, '__debugInfo')) {
                 try {
-                    foreach ($var->__debugInfo() as $key => $val) {
+                    foreach ((array)$var->__debugInfo() as $key => $val) {
                         $node->addProperty(new PropertyNode("'{$key}'", null, static::export($val, $context)));
                     }
 

+ 1 - 2
tests/TestCase/Error/DebuggerTest.php

@@ -651,8 +651,7 @@ TEXT;
     public function testExportVarMockObject(): void
     {
         $result = Debugger::exportVar($this->getMockBuilder(Table::class)->getMock());
-        $expected = '(unable to export object: foreach() argument must be of type array|object, null given)';
-        $this->assertTextEquals($expected, $result);
+        $this->assertStringContainsString('object(Mock_Table', $result);
     }
 
     /**