ソースを参照

Fixing issue where ints are casted to strings

Chris Hallgren 6 年 前
コミット
1ae1cdcc47
2 ファイル変更8 行追加2 行削除
  1. 2 0
      src/Utility/Utility.php
  2. 6 2
      tests/TestCase/Utility/UtilityTest.php

+ 2 - 0
src/Utility/Utility.php

@@ -449,6 +449,8 @@ class Utility {
 				$value[$k] = static::trimDeep($v, $transformNullToString);
 			}
 			return $value;
+		} elseif (is_int($value)) {
+			return $value;
 		}
 
 		return ($value === null && !$transformNullToString) ? $value : trim($value);

+ 6 - 2
tests/TestCase/Utility/UtilityTest.php

@@ -337,12 +337,16 @@ class UtilityTest extends TestCase {
 		$is = [
 			'f some',
 			'e 49r ' => 'rf r ',
-			'er' => [['ee' => ['rr ' => ' tt ', 'empty' => null]]]
+			'er' => [['ee' => ['rr ' => ' tt ', 'empty' => null]]],
+			'bsh' => 1,
+			'bkd' => '1'
 		];
 		$expected = [
 			'f some',
 			'e 49r ' => 'rf r',
-			'er' => [['ee' => ['rr ' => 'tt', 'empty' => null]]]
+			'er' => [['ee' => ['rr ' => 'tt', 'empty' => null]]],
+			'bsh' => 1,
+			'bkd' => '1'
 		];
 
 		$res = Utility::trimDeep($is);