diff --git a/src/Stash/Utilities.php b/src/Stash/Utilities.php index 077356b4..96e8dc66 100644 --- a/src/Stash/Utilities.php +++ b/src/Stash/Utilities.php @@ -34,6 +34,10 @@ public static function encoding($data) return 'bool'; } + if (is_string($data)) { + return 'string'; + } + if (is_numeric($data)) { if (is_numeric($data) && ($data >= 2147483648 || $data < -2147483648)) { return 'serialize'; @@ -41,8 +45,6 @@ public static function encoding($data) return 'numeric'; } } - - return 'string'; } return 'serialize'; diff --git a/tests/Stash/Test/UtilitiesTest.php b/tests/Stash/Test/UtilitiesTest.php index 1bafdbdb..d380ad17 100644 --- a/tests/Stash/Test/UtilitiesTest.php +++ b/tests/Stash/Test/UtilitiesTest.php @@ -25,6 +25,8 @@ public function testEncoding() $this->assertEquals(Utilities::encoding(true), 'bool', 'encoding recognized \'true\' boolean.'); $this->assertEquals(Utilities::encoding(false), 'bool', 'encoding recognized \'false\' boolean'); + $this->assertEquals(Utilities::encoding('1'), 'string', 'encoding recognized \'1\' string.'); + $this->assertEquals(Utilities::encoding('1.2'), 'string', 'encoding recognized \'1.2\' string.'); $this->assertEquals(Utilities::encoding('String of doom!'), 'string', 'encoding recognized string scalar'); $this->assertEquals(Utilities::encoding(234), 'numeric', 'encoding recognized integer scalar');