[BUGFIX] Add support for float values to arrayExport 03/20703/2
authorJigal van Hemert <jigal@xs4all.nl>
Sat, 11 May 2013 19:13:49 +0000 (21:13 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 11 May 2013 19:57:56 +0000 (21:57 +0200)
ArrayUtility::arrayExport() must support float values too.

Change-Id: Ibfb0dfa3b7d8f584d41ff01f49a40dbbd991a66e
Releases: 6.2, 6.1, 6.0
Fixes: #48114
Reviewed-on: https://review.typo3.org/20703
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/core/Classes/Utility/ArrayUtility.php
typo3/sysext/core/Tests/Unit/Utility/ArrayUtilityTest.php

index e9bd600..22a0ec6 100644 (file)
@@ -269,7 +269,7 @@ class ArrayUtility {
                                } else {
                                        $lines .= 'array(),' . LF;
                                }
-                       } elseif (is_int($value)) {
+                       } elseif (is_int($value) || is_float($value)) {
                                $lines .= $value . ',' . LF;
                        } elseif (is_null($value)) {
                                $lines .= 'NULL' . ',' . LF;
index cdfcb53..b5bdfae 100644 (file)
@@ -681,7 +681,9 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                )
                        ),
                        'baz' => 23,
-                       'foobar' => NULL
+                       'foobar' => NULL,
+                       'qux' => 0.1,
+                       'qux2' => 0.000000001,
                );
                $expected =
                        'array(' . LF .
@@ -696,6 +698,8 @@ class ArrayUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                                TAB . '),' . LF .
                                TAB . '\'baz\' => 23,' . LF .
                                TAB . '\'foobar\' => NULL,' . LF .
+                               TAB . '\'qux\' => 0.1,' . LF .
+                               TAB . '\'qux2\' => 1.0E-9,' . LF .
                        ')';
                $this->assertSame($expected, \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($array));
        }