Ejemplo n.º 1
0
 /**
  * @param $value    string
  * @param $property Reflection_Property
  */
 public function __construct($value, Reflection_Property $property)
 {
     if (!$value) {
         $value = $property->getName();
     }
     parent::__construct($value);
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
0
 /**
  * Default annotation constructor receive the full doc text content
  *
  * Annotation class will have to parse it ie for several parameters or specific syntax, or if they
  * want to store specific typed or calculated value
  *
  * @param $value string any value from SAF\Framework\Tools\Encryption constants
  */
 public function __construct($value)
 {
     if (isset($value) && !$value) {
         $value = Encryption::SHA1;
     }
     parent::__construct($value);
 }
Ejemplo n.º 4
0
 /**
  * @param $value string
  * @param $class Reflection_Class
  */
 public function __construct($value, Reflection_Class $class)
 {
     parent::__construct($value);
     if (!$this->value) {
         $class_name = $class->getName();
         $this->value = Set::defaultSetClassNameOf($class_name);
     }
 }
Ejemplo n.º 5
0
 /**
  * @param $value    string
  * @param $property Reflection_Property
  */
 public function __construct($value, Reflection_Property $property)
 {
     $possibles = [self::ALL, self::COLLECTION, self::DATETIME, self::MAP, self::OBJECT];
     if (empty($value) && $property->getType()->isClass() && ($stored = $property->getFinalClass()->getAnnotation('stored')->value)) {
         $value = $this->guessValue($property);
     }
     if (!empty($value) && !in_array($value, $possibles)) {
         trigger_error('@link ' . $value . ' is a bad value : only ' . join(', ', $possibles) . ' can be used', E_USER_ERROR);
         $value = '';
     }
     parent::__construct($value);
 }
Ejemplo n.º 6
0
 /**
  * @param $value    string
  * @param $property Reflection_Property ie the contextual Reflection_Property object
  */
 public function __construct($value, Reflection_Property $property)
 {
     parent::__construct($value);
     if (empty($this->value)) {
         foreach ($property->getFinalClass()->getAnnotations('group') as $group) {
             /** @var $group Class_\Group_Annotation */
             if ($group->has($property->getName())) {
                 $this->value = $property->getName();
                 break;
             }
         }
     }
 }
Ejemplo n.º 7
0
 /**
  * Annotation string value is a value type separated from a a documentation with a single space
  *
  * @example '@var Class_Name A documentation text can come after that'
  * @example '@var An_Array[]|Another[]|array Documentation will begin at "Another[]"'
  * @param $value string
  */
 public function __construct($value)
 {
     $i = strpos($value, SP);
     $j = strpos($value, '|');
     if ($i === false || $j !== false && $j < $i) {
         $i = $j;
     }
     if ($i === false) {
         parent::__construct($value);
         $this->documentation = '';
     } else {
         parent::__construct(substr($value, 0, $i));
         $this->documentation = trim(substr($value, $i + 1));
     }
 }
Ejemplo n.º 8
0
 /**
  * List string value is a values list, each one separated by a comma.
  * Spaces before and after commas are ignored.
  *
  * @example '@values First value, Second one, etc'
  * @param $value string
  */
 public function __construct($value)
 {
     $values = [];
     $value = trim($value);
     $length = strlen($value);
     $in_quote = $length && ($value[0] === Q || $value[0] === DQ) ? $value[0] : false;
     $start = $in_quote ? 1 : 0;
     $stop = null;
     $i = $start;
     while ($i < $length) {
         if ($value[$i] === BS && $i < $length - 1) {
             $i++;
         }
         if ($value[$i] === $in_quote) {
             $j = $i + 1;
             while ($j < $length && $value[$j] === SP) {
                 $j++;
             }
             $stop = $i;
             $in_quote = false;
             $i = $j;
         }
         if ($i == $length || $value[$i] === ',' && !$in_quote) {
             if (!isset($stop)) {
                 $stop = $i;
             }
             $values[] = substr($value, $start, $stop - $start);
             $i++;
             if ($i == $length) {
                 $start = $i;
                 break;
             }
             while ($i < $length && $value[$i] === SP) {
                 $i++;
             }
             $in_quote = $i < $length && ($value[$i] === Q || $value[$i] === DQ) ? $value[$i] : false;
             $start = $in_quote ? $i + 1 : $i;
             $stop = null;
         }
         $i++;
     }
     if ($i == $length && ($values || $i > $start)) {
         $values[] = substr($value, $start, $i - $start);
     }
     parent::__construct($values);
 }
Ejemplo n.º 9
0
 /**
  * Annotation string value is a class name followed by the two property names that do the link
  *
  * @example '@var Class_Name property_1 property_2'
  * @param $value string
  * @param $class Reflection_Class The contextual Reflection_Class object
  */
 public function __construct($value, Reflection_Class $class)
 {
     if ($value && substr($value, 0, 4) !== 'http') {
         $this->class = $class;
         $this->link_properties = [];
         if (trim($value)) {
             $i = strpos($value, SP);
             if ($i === false) {
                 parent::__construct($value);
                 $this->link_properties = null;
             } else {
                 parent::__construct(substr($value, 0, $i));
                 $this->link_properties = substr($value, $i + 1);
             }
         } else {
             parent::__construct(null);
         }
     } else {
         parent::__construct(null);
     }
 }
Ejemplo n.º 10
0
 /**
  * @param $value    string
  * @param $property Interfaces\Reflection_Property
  */
 public function __construct($value, Interfaces\Reflection_Property $property)
 {
     /** @noinspection PhpUndefinedMethodInspection @extends Annotation */
     parent::__construct($value);
     $this->property = $property;
 }