/** * fromReflection() * * @param \Zend\Reflection\ReflectionProperty $reflectionProperty * @return \Zend\CodeGenerator\Php\PhpProperty */ public static function fromReflection(\Zend\Reflection\ReflectionProperty $reflectionProperty) { $property = new self(); $property->setName($reflectionProperty->getName()); $allDefaultProperties = $reflectionProperty->getDeclaringClass()->getDefaultProperties(); $property->setDefaultValue($allDefaultProperties[$reflectionProperty->getName()]); if ($reflectionProperty->getDocComment() != '') { $property->setDocblock(Php\PhpDocblock::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; }
/** * Extract type of the property from DocBlock * * @param \Zend\Reflection\ReflectionProperty $prop reflection property object * @return string Property type */ protected function _getPropertyType(\Zend\Reflection\ReflectionProperty $prop) { $docBlock = $prop->getDocComment(); if (!$docBlock) { return 'Unknown'; } if (!$docBlock->hasTag('var')) { return 'Unknown'; } $tag = $docBlock->getTag('var'); return trim($tag->getDescription()); }