[BUGFIX] Handle variadic arguments in Extbase DebuggerUtility 37/54637/2
authorMathias Brodala <mbrodala@pagemachine.de>
Thu, 9 Nov 2017 08:42:04 +0000 (09:42 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Tue, 14 Nov 2017 14:09:41 +0000 (15:09 +0100)
Variadic arguments are optional but do not have a default value, thus
properly check this.

Also render the variadic operator ("...") in the output.

Resolves: #82956
Releases: master, 8.7
Change-Id: I10e3528d9cffcdd03ae4711b139898f569ac3775
Reviewed-on: https://review.typo3.org/54637
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/extbase/Classes/Utility/DebuggerUtility.php
typo3/sysext/extbase/Tests/Unit/Utility/DebuggerUtilityTest.php

index c524e71..71ed74d 100644 (file)
@@ -376,13 +376,16 @@ class DebuggerUtility
                     if ($parameter->isPassedByReference()) {
                         $parameterDump .= '&';
                     }
+                    if ($parameter->isVariadic()) {
+                        $parameterDump .= '...';
+                    }
                     if ($plainText) {
                         $parameterDump .= self::ansiEscapeWrap('$' . $parameter->name, '37', $ansiColors);
                     } else {
                         $parameterDump .= '<span class="extbase-debug-property">'
                             . htmlspecialchars('$' . $parameter->name) . '</span>';
                     }
-                    if ($parameter->isOptional()) {
+                    if ($parameter->isDefaultValueAvailable()) {
                         $parameterDump .= ' = ';
                         if ($plainText) {
                             $parameterDump .= self::ansiEscapeWrap(var_export($parameter->getDefaultValue(), true), '33', $ansiColors);
index bfbef64..60d0116 100644 (file)
@@ -52,6 +52,16 @@ class DebuggerUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
     /**
      * @test
      */
+    public function varDumpHandlesVariadicArguments()
+    {
+        $result = DebuggerUtility::var_dump(function (...$args) {
+        }, null, 8, true, false, true);
+        $this->assertContains('function (...$args)', $result);
+    }
+
+    /**
+     * @test
+     */
     public function varDumpRespectsBlacklistedProperties()
     {
         $testClass = new \stdClass();