Beispiel #1
0
 /**
  * @param $value           string
  * @param $class_property  Reflection
  * @param $annotation_name string
  */
 public function __construct($value, Reflection $class_property, $annotation_name)
 {
     if (!empty($value)) {
         $class = $class_property instanceof Reflection_Property ? $class_property->getFinalClass() : $class_property;
         if ($pos = strpos($value, '::')) {
             $type_annotation = new Type_Annotation(substr($value, 0, $pos), $class);
             if ($type_annotation->value == 'composite') {
                 /** @var $composite_property Reflection_Property */
                 $composite_property = call_user_func([$class->getName(), 'getCompositeProperty']);
                 $type_annotation->value = $composite_property->getType()->asString();
             }
             // if the property is declared into the final class : try using the class namespace name
             if (!$class_property instanceof Reflection_Property || $class_property->getDeclaringTraitName() === $class_property->getFinalClassName()) {
                 $type_annotation->applyNamespace($class->getNamespaceName());
             }
             if (!@class_exists($type_annotation->value)) {
                 $this->searchIntoDeclaringTrait($class_property, $type_annotation, $value, $pos);
             }
             if (!@class_exists($type_annotation->value)) {
                 $this->searchIntoFinalClass($class_property, $type_annotation, $value, $pos);
             }
             if (!@class_exists($type_annotation->value)) {
                 trigger_error(sprintf('Not found full class name for Method_Annotation %1 value %2 class %3 property %4', $annotation_name, $value, $class->getName(), $class_property->getName()), E_USER_ERROR);
             }
             $value = $type_annotation->value . substr($value, $pos);
             $this->static = true;
         } else {
             if ($value === true) {
                 $value = Names::propertyToMethod($annotation_name);
             }
             $value = $class->getName() . '::' . $value;
         }
     }
     parent::__construct($value);
 }
Beispiel #2
0
 /**
  * Parse a special data / function and returns its return value
  *
  * @param $func_name string
  * @return mixed
  */
 protected function parseFunc($func_name)
 {
     $func_name = ($p = strpos($func_name, '(')) ? Names::propertyToMethod(substr($func_name, 0, $p), 'get') . substr($func_name, $p) : Names::propertyToMethod($func_name, 'get');
     return $this->htmlEntities($this->callFunc($this->functions, $func_name));
 }
Beispiel #3
0
 /**
  * @param $properties array
  * @param $class      Reflection_Class
  */
 private function scanForSetters(&$properties, Reflection_Class $class)
 {
     foreach ($class->getProperties() as $property) {
         $expr = '%' . '\\n\\s+\\*\\s+' . '@setter' . '(?:\\s+(?:([\\\\\\w]+)::)?' . '(\\w+)?)?' . '%';
         preg_match($expr, $property->getDocComment(), $match);
         if ($match) {
             $advice = [empty($match[1]) ? '$this' : $class->source->fullClassName($match[1]), empty($match[2]) ? Names::propertyToMethod($property->name, 'set') : $match[2]];
             $properties[$property->name][] = ['write', $advice];
         }
     }
     foreach ($this->scanForOverrides($class->getDocComment(), ['setter']) as $match) {
         $advice = [empty($match['class_name']) ? '$this' : $match['class_name'], empty($match['method_name']) ? Names::propertyToMethod($match['property_name'], 'set') : $match['method_name']];
         $properties[$match['property_name']][] = ['write', $advice];
     }
 }