[BUGFIX] Do not rewind Generator in DebuggerUtility::var_dump() 34/59134/2
authorMathias Brodala <mbrodala@pagemachine.de>
Thu, 13 Dec 2018 14:21:15 +0000 (15:21 +0100)
committerMathias Brodala <mbrodala@pagemachine.de>
Thu, 13 Dec 2018 16:16:10 +0000 (17:16 +0100)
Resolves: #87149
Releases: master, 8.7
Change-Id: I8cf2cfab94634276a67fd3d0dd36215c12ae5490
Reviewed-on: https://review.typo3.org/59134
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
typo3/sysext/extbase/Classes/Utility/DebuggerUtility.php
typo3/sysext/extbase/Tests/Unit/Utility/DebuggerUtilityTest.php

index 71ed74d..0cd2419 100644 (file)
@@ -467,7 +467,7 @@ class DebuggerUtility
             $dump .= PHP_EOL . str_repeat(self::PLAINTEXT_INDENT, $level) . ($plainText ? '' : '<span class="extbase-debug-property">') . self::ansiEscapeWrap($key, '37', $ansiColors) . ($plainText ? '' : '</span>') . ' => ';
             $dump .= self::renderDump($value, $level, $plainText, $ansiColors);
         }
-        if ($collection instanceof \Iterator) {
+        if ($collection instanceof \Iterator && !$collection instanceof \Generator) {
             $collection->rewind();
         }
         return $dump;
index 60d0116..3632ae9 100644 (file)
@@ -41,6 +41,20 @@ class DebuggerUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
+    public function debuggerDoesNotRewindInstancesOfGenerator()
+    {
+        $generator = (function () {
+            yield 1;
+            yield 2;
+            yield 3;
+        })();
+        $result = DebuggerUtility::var_dump($generator, null, 8, true, false, true);
+        $this->assertContains('Generator', $result);
+    }
+
+    /**
+     * @test
+     */
     public function varDumpShowsPropertiesOfStdClassObjects()
     {
         $testObject = new \stdClass();