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;
    }
 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['name' => null, 'number' => null, 'label' => null, 'type' => null, 'type_name' => null, 'extendee' => null, 'default_value' => null, 'oneof_index' => null, 'json_name' => null, 'options' => null], $values);
     $message->setName($values['name']);
     $message->setNumber($values['number']);
     $message->setLabel($values['label']);
     $message->setType($values['type']);
     $message->setTypeName($values['type_name']);
     $message->setExtendee($values['extendee']);
     $message->setDefaultValue($values['default_value']);
     $message->setOneofIndex($values['oneof_index']);
     $message->setJsonName($values['json_name']);
     $message->setOptions($values['options']);
     return $message;
 }