Forráskód Böngészése

[ZF-8849] PHP Notice: Undefined variable: type in Zend/CodeGenerator/Php/Property/DefaultValue.php on line 113

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21979 44c647ce-9c0f-0410-b52a-842ac1e357ba
jan 15 éve
szülő
commit
836a0b7422

+ 2 - 0
library/Zend/CodeGenerator/Php/Property/DefaultValue.php

@@ -94,6 +94,8 @@ class Zend_CodeGenerator_Php_Property_DefaultValue extends Zend_CodeGenerator_Ph
     {
         if ($this->_type == self::TYPE_AUTO) {
             $type = $this->_getAutoDeterminedType($this->_value);
+        } else {
+            $type = $this->_type;
         }
 
         // valid types for constants

+ 17 - 0
tests/Zend/CodeGenerator/Php/PropertyTest.php

@@ -233,4 +233,21 @@ EOS;
 
         $this->assertEquals($code, $defaultValue->generate());
     }
+    
+    /**
+     * @group ZF-8849
+     */
+    public function testZF8849()
+    {
+        $property = new Zend_CodeGenerator_Php_Property(array(
+            'defaultValue' => array('value' => 1.337, 'type' => 'string'),
+            'name'         => 'ZF8849',
+            'const'        => true
+        ));
+        
+        $this->assertEquals(
+            $property->generate(),
+            "    const ZF8849 = '1.337';"
+        );
+    }
 }