Browse Source

Fixing issue where ints are casted to strings

Chris Hallgren 6 years ago
parent
commit
1ae1cdcc47
2 changed files with 8 additions and 2 deletions
  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);
 				$value[$k] = static::trimDeep($v, $transformNullToString);
 			}
 			}
 			return $value;
 			return $value;
+		} elseif (is_int($value)) {
+			return $value;
 		}
 		}
 
 
 		return ($value === null && !$transformNullToString) ? $value : trim($value);
 		return ($value === null && !$transformNullToString) ? $value : trim($value);

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

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