Kaynağa Gözat

ZF-11172: fixed discovery of "0" in values

- Added check for strlen() when checking for values in matched key:value
  patterns; allows discovery of 0 as a value


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23807 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 15 yıl önce
ebeveyn
işleme
4f597463cc

+ 2 - 2
library/Zend/Config/Yaml.php

@@ -284,7 +284,7 @@ class Zend_Config_Yaml extends Zend_Config
         $config   = array();
         $inIndent = false;
         while (list($n, $line) = each($lines)) {
-            $lineno = $n+1;
+            $lineno = $n + 1;
             if (strlen($line) == 0) {
                 continue;
             }
@@ -313,7 +313,7 @@ class Zend_Config_Yaml extends Zend_Config
 
             if (preg_match("/(\w+):\s*(.*)/", $line, $m)) {
                 // key: value
-                if ($m[2]) {
+                if (strlen($m[2])) {
                     // simple key: value
                     $value = $m[2];
                     // Check for booleans and constants

+ 2 - 0
tests/Zend/Config/YamlTest.php

@@ -89,6 +89,8 @@ class Zend_Config_YamlTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('', $config->special->null);
         $this->assertType('string', $config->special->false);
         $this->assertEquals('', $config->special->false);
+        $this->assertInternalType('string', $config->special->zero);
+        $this->assertEquals('0', $config->special->zero);
     }
 
     public function testMultiDepthExtends()

+ 1 - 0
tests/Zend/Config/_files/config.yaml

@@ -26,6 +26,7 @@ debug:
     no: 
     null: 
     false: 
+    zero: 0
   _extends: all
 other_staging: 
   only_in: otherStaging