[BUGFIX] Do not rewind Generator in DebuggerUtility::var_dump() 32/59132/4
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 15:35:15 +0000 (16:35 +0100)
Resolves: #87149
Releases: master, 8.7
Change-Id: I8cf2cfab94634276a67fd3d0dd36215c12ae5490
Reviewed-on: https://review.typo3.org/59132
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Riny van Tiggelen <info@online-gamer.nl>
Reviewed-by: Ralf Merz <mail@merzilla.de>
Tested-by: Ralf Merz <mail@merzilla.de>
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 5f7952c..58626ce 100644 (file)
@@ -463,7 +463,7 @@ class DebuggerUtility
             $dump .= ' => ';
             $dump .= self::renderDump($value, $level, $plainText, $ansiColors);
         }
-        if ($collection instanceof \Iterator) {
+        if ($collection instanceof \Iterator && !$collection instanceof \Generator) {
             $collection->rewind();
         }
         return $dump;
index ffb27a0..133f217 100644 (file)
@@ -42,6 +42,20 @@ class DebuggerUtilityTest extends 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();