浏览代码

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);