Example #1
0
    /**
     * fromReflection()
     *
     * @param Zend_Reflection_Property $reflectionProperty
     * @return Zend_CodeGenerator_Php_Property
     */
    public static function fromReflection(Zend_Reflection_Property $reflectionProperty)
    {
        $property = new self();

        $property->setName($reflectionProperty->getName());

        $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties();

        $property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]);

        if ($reflectionProperty->getDocComment() != '') {
            $property->setDocblock(Zend_CodeGenerator_Php_Docblock::fromReflection($reflectionProperty->getDocComment()));
        }

        if ($reflectionProperty->isStatic()) {
            $property->setStatic(true);
        }

        if ($reflectionProperty->isPrivate()) {
            $property->setVisibility(self::VISIBILITY_PRIVATE);
        } elseif ($reflectionProperty->isProtected()) {
            $property->setVisibility(self::VISIBILITY_PROTECTED);
        } else {
            $property->setVisibility(self::VISIBILITY_PUBLIC);
        }

        $property->setSourceDirty(false);

        return $property;
    }
Example #2
0
 /**
  * Extract type of the property from DocBlock
  * 
  * @param  Zend_Reflection_Property $prop reflection property object
  * @return string Property type
  */
 protected function _getPropertyType(Zend_Reflection_Property $prop)
 {
     $docBlock = $prop->getDocComment();
     if (!$docBlock) {
         return 'Unknown';
     }
     if (!$docBlock->hasTag('var')) {
         return 'Unknown';
     }
     $tag = $docBlock->getTag('var');
     return trim($tag->getDescription());
 }
Example #3
0
 public function testDeclaringClassReturn()
 {
     $property = new Zend_Reflection_Property('Zend_Reflection_TestSampleClass2', '_prop1');
     $this->assertEquals(get_class($property->getDeclaringClass()), 'Zend_Reflection_Class');
 }