当前位置: 首页>>代码示例>>PHP>>正文


PHP Annotation::parse方法代码示例

本文整理汇总了PHP中Annotation::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Annotation::parse方法的具体用法?PHP Annotation::parse怎么用?PHP Annotation::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Annotation的用法示例。


在下文中一共展示了Annotation::parse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: calculate_type

 public static function calculate_type($reflection)
 {
     $annotations = Annotation::parse($reflection);
     if (isset($annotations['type'])) {
         return $annotations['type'];
     } else {
         $defaults = $reflection->getDeclaringClass()->getDefaultProperties();
         $default_value = $defaults[$reflection->getName()];
         if (is_null($default_value)) {
             return 'null';
         }
         if (is_string($default_value)) {
             return 'string';
         } else {
             if (is_integer($default_value)) {
                 return 'integer';
             } else {
                 if (is_float($default_value)) {
                     return 'float';
                 } else {
                     if (is_bool($default_value)) {
                         return 'boolean';
                     } else {
                         if (is_array($default_value)) {
                             return 'array';
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:jaz303,项目名称:spitfire,代码行数:32,代码来源:Utilities.php

示例2: execute

 public function execute($include_inherited_members = false)
 {
     if (!isset($this->_classes[0])) {
         throw new \Wave\Exception('No files to reflect on');
     }
     $classes = array();
     foreach ($this->_classes as $class) {
         $reflector = new \ReflectionClass($class);
         $class_annotations = Annotation::parse($reflector->getDocComment(), $class);
         $parent_class = $reflector->getParentClass();
         $c = array('name' => $class, 'subclasses' => $parent_class instanceof \ReflectionClass ? $parent_class->getName() : '', 'implements' => $reflector->getInterfaceNames(), 'annotations' => $class_annotations);
         $methods = array();
         foreach ($reflector->getMethods() as $method) {
             $declaring_class = $method->getDeclaringClass()->getName();
             // don't put inherited methods on here plz
             if ($declaring_class != $class && !$include_inherited_members) {
                 continue;
             }
             $annotations = Annotation::parse($method->getDocComment(), $class);
             $method_annotations = array();
             foreach ($annotations as $annotation) {
                 $method_annotations[] = $annotation;
             }
             $method_name = $method->getName();
             $visibility = $method->isPublic() ? self::VISIBILITY_PUBLIC : ($method->isPrivate() ? self::VISIBILITY_PRIVATE : self::VISIBILITY_PROTECTED);
             $methods[$method_name] = array('name' => $method_name, 'visibility' => $visibility, 'static' => $method->isStatic(), 'parameters' => $method->getParameters(), 'annotations' => $method_annotations, 'declaring_class' => $method->getDeclaringClass()->getName());
         }
         $properties = array();
         foreach ($reflector->getProperties() as $property) {
             $declaring_class = $property->getDeclaringClass()->getName();
             // don't put inherited methods on here plz
             if ($declaring_class != $class && !$include_inherited_members) {
                 continue;
             }
             $annotations = Annotation::parse($property->getDocComment(), $class);
             $property_annotations = array();
             foreach ($annotations as $annotation) {
                 $property_annotations[] = $annotation;
             }
             $property_name = $property->getName();
             $visibility = $property->isPublic() ? self::VISIBILITY_PUBLIC : ($property->isPrivate() ? self::VISIBILITY_PRIVATE : self::VISIBILITY_PROTECTED);
             $properties[$property_name] = array('name' => $property_name, 'visibility' => $visibility, 'static' => $property->isStatic(), 'annotations' => $property_annotations, 'declaring_class' => $property->getDeclaringClass()->getName());
         }
         $classes[$class] = array('class' => $c, 'methods' => $methods, 'properties' => $properties);
     }
     return $classes;
 }
开发者ID:wave-framework,项目名称:wave,代码行数:47,代码来源:Reflector.php

示例3: getAnnotations

 function getAnnotations()
 {
     $docstring = $this->getDocComment();
     if ($docstring == '') {
         return array();
     } else {
         $returns = array();
         try {
             $returns = Annotation::parse($docstring);
         } catch (InvalidAnnotationValueException $e) {
             throw new InvalidAnnotationValueException('In class "' . $this->getDeclaringClass()->name . '" on property "' . $this->name . '".' . $e->getMessage(), 0, 0, $this->getDeclaringClass()->getFileName(), $this->getDeclaringClass()->getStartLine(), array());
         } catch (UnknownAnnotationException $e) {
             throw new UnknownAnnotationException('In class "' . $this->getDeclaringClass()->name . '" on property "' . $this->name . '".' . $e->getMessage(), 0, 0, $this->getDeclaringClass()->getFileName(), $this->getDeclaringClass()->getStartLine(), array());
         }
     }
     return $returns;
 }
开发者ID:amitshukla30,项目名称:recess,代码行数:17,代码来源:RecessReflectionProperty.class.php

示例4: getAnnotations

 function getAnnotations()
 {
     Library::import('recess.lang.Annotation');
     $docstring = $this->getDocComment();
     if ($docstring == '') {
         return array();
     } else {
         $returns = array();
         try {
             $returns = Annotation::parse($docstring);
         } catch (InvalidAnnotationValueException $e) {
             throw new InvalidAnnotationValueException('In class "' . $this->name . '".' . $e->getMessage(), 0, 0, $this->getFileName(), $this->getStartLine(), array());
         } catch (UnknownAnnotationException $e) {
             throw new UnknownAnnotationException('In class "' . $this->name . '".' . $e->getMessage(), 0, 0, $this->getFileName(), $this->getStartLine(), array());
         }
     }
     return $returns;
 }
开发者ID:amitshukla30,项目名称:recess,代码行数:18,代码来源:RecessReflectionClass.class.php

示例5: handle_class

 private function handle_class($class)
 {
     $reflection = new \ReflectionClass($class);
     $annotations = Annotation::parse($reflection);
     if (isset($annotations['model'])) {
         echo "creating model {$reflection->getName()}\n";
         $model = new Model($this->universe, $reflection);
         $this->universe->register_model($model);
     }
 }
开发者ID:jaz303,项目名称:spitfire,代码行数:10,代码来源:Builder.php

示例6: processProperty

 /**
  * Process a property
  * @param \ReflectionProperty $p
  */
 private function processProperty(\ReflectionProperty $p)
 {
     $registered = false;
     foreach (Annotation::parse($p->getDocComment()) as $a) {
         if ($a->getName() != "element" && $a->getName() != "attribute") {
             continue;
         }
         if ($p->isStatic()) {
             $this->fail("Static property '{$p->name}' cannot be serialized");
         }
         if (!$registered) {
             $p->setAccessible(true);
             $this->reflectors[$p->name] = $p;
             $registered = true;
         }
         $type = "";
         if ($a->getParamCount() > 0) {
             $type = $a->getParam(0);
         }
         $type = $this->resolveType($type);
         $xmlName = $p->name;
         if ($a->getParamCount() > 1) {
             $xmlName = $a->getParam(1);
         }
         $isElement = $a->getName() == "element";
         if ($this->hasXmlNameForProperty($p->name, $type)) {
             $this->fail("Duplicate xml name for property name '{$p->name}' and value type '{$type}'");
         }
         if (!array_key_exists($p->name, $this->props)) {
             $this->props[$p->name] = array();
         }
         $this->props[$p->name][$type] = array($xmlName, $isElement);
         if ($isElement) {
             if ($this->hasPropertyForElement($xmlName)) {
                 $this->fail("Duplicate element '{$xmlName}'");
             }
             $this->els[$xmlName] = array($p->name, $type);
         } else {
             if ($this->hasPropertyForAttribute($xmlName)) {
                 $this->fail("Duplicate attribute '{$xmlName}'");
             }
             $this->attrs[$xmlName] = array($p->name, $type);
         }
     }
 }
开发者ID:pdiveris,项目名称:mimas,代码行数:49,代码来源:ClassMeta.php

示例7: testParseNamespaced

    public function testParseNamespaced()
    {
        $comment = <<<'DOC'
/**
 * foobar
 *
 * @ORM\Column(type="string")
 */
DOC;
        $doc = Annotation::parse($comment);
        $this->assertEquals('(type="string")', $doc->getFirstAnnotation('Column'));
    }
开发者ID:seytar,项目名称:psx,代码行数:12,代码来源:AnnotationTest.php

示例8: scan_serial

 private function scan_serial()
 {
     foreach ($this->klass->getProperties() as $ref) {
         $annotations = Annotation::parse($ref);
         if (isset($annotations['serial'])) {
             if ($this->serial === null) {
                 $this->serial = $ref->getName();
             } else {
                 throw new Exception("only one serial field per model is supported");
             }
         }
     }
 }
开发者ID:jaz303,项目名称:spitfire,代码行数:13,代码来源:Model.php


注:本文中的Annotation::parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。