Пример #1
0
 public function getPropertyDesc($propertyName)
 {
     if ($this->reflection->hasProperty($propertyName)) {
         $docComment = $this->reflection->getProperty($propertyName)->getDocComment();
         if ($docComment) {
             $docBlock = new DocBlock($docComment);
             $tags = $docBlock->getTagsByName('var');
             foreach ($tags as $tag) {
                 $parts = preg_split('/(\\s+)/Su', $tag->getContent());
                 if (isset($parts[0]) && strlen($parts[0]) > 0 && $parts[0][0] !== '$' && isset($parts[2]) && strlen($parts[2]) > 0) {
                     return join('', array_slice($parts, 2));
                 }
                 if (isset($parts[0]) && strlen($parts[0]) > 0 && $parts[0][0] === '$' && isset($parts[1]) && strlen($parts[1]) > 0) {
                     return join('', array_slice($parts, 1));
                 }
             }
         }
     }
     $docComment = $this->reflection->getDocComment();
     if ($docComment) {
         $docBlock = new DocBlock($docComment);
         $propertyTags = $docBlock->getTagsByName('property');
         foreach ($propertyTags as $propertyTag) {
             $parts = preg_split('/(\\s+)/Su', $propertyTag->getContent());
             if (isset($parts[0]) && strlen($parts[0]) > 0 && $parts[0][0] !== '$') {
                 if (isset($parts[1]) && strlen($parts[1]) > 0 && isset($parts[2]) && strlen($parts[2]) > 0) {
                     if ($parts[1][0] === '$') {
                         if (substr($parts[1], 1) == $propertyName) {
                             return join('', array_slice($parts, 2));
                         }
                     } else {
                         if ($parts[1] == $propertyName) {
                             return join('', array_slice($parts, 2));
                         }
                     }
                 }
             }
             if (isset($parts[0]) && strlen($parts[0]) > 0 && $parts[0][0] === '$') {
                 if (substr($parts[0], 1) == $propertyName && isset($parts[1]) && strlen($parts[1]) > 0) {
                     return join('', array_slice($parts, 1));
                 }
             }
         }
     }
     if ($parent = $this->reflection->getParentClass()) {
         $annotationParser = new AnnotationParser($parent->getName());
         return $annotationParser->getPropertyDesc($propertyName);
     }
     return null;
 }