@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | } |
| 46 | 46 | class AnnotationReader implements \ArrayAccess |
| 47 | 47 | { |
| 48 | - static public function createDocBlockFactory(){ |
|
| 48 | + static public function createDocBlockFactory() { |
|
| 49 | 49 | $fqsenResolver = new FqsenResolver(); |
| 50 | - $tagFactory = new StandardTagFactory($fqsenResolver,[]); |
|
| 50 | + $tagFactory = new StandardTagFactory($fqsenResolver, []); |
|
| 51 | 51 | $descriptionFactory = new DescriptionFactory($tagFactory); |
| 52 | 52 | $tagFactory->addService($descriptionFactory); |
| 53 | 53 | $tagFactory->addService(new TypeResolver($fqsenResolver)); |
@@ -72,22 +72,22 @@ discard block |
||
| 72 | 72 | self::assertAnnotationEnabled(); |
| 73 | 73 | $rfl = new \ReflectionClass($className) or \PhpBoot\abort("load class $className failed"); |
| 74 | 74 | $fileName = $rfl->getFileName(); |
| 75 | - $key = str_replace('\\','.',self::class).md5($fileName.$className); |
|
| 75 | + $key = str_replace('\\', '.', self::class).md5($fileName.$className); |
|
| 76 | 76 | $oldData = null; |
| 77 | - $cache = new CheckableCache($localCache?:new ApcCache()); |
|
| 77 | + $cache = new CheckableCache($localCache ?: new ApcCache()); |
|
| 78 | 78 | $res = $cache->get('ann:'.$key, null, $oldData, false); |
| 79 | - if($res === null){ |
|
| 80 | - try{ |
|
| 79 | + if ($res === null) { |
|
| 80 | + try { |
|
| 81 | 81 | $meta = self::readWithoutCache($className); |
| 82 | - $cache->set($key, $meta, 0, $fileName?new ClassModifiedChecker($className):null); |
|
| 82 | + $cache->set($key, $meta, 0, $fileName ? new ClassModifiedChecker($className) : null); |
|
| 83 | 83 | return $meta; |
| 84 | - }catch (\Exception $e){ |
|
| 85 | - $cache->set($key, $e->getMessage(), 0, $fileName?new ClassModifiedChecker($className):null); |
|
| 84 | + }catch (\Exception $e) { |
|
| 85 | + $cache->set($key, $e->getMessage(), 0, $fileName ? new ClassModifiedChecker($className) : null); |
|
| 86 | 86 | throw $e; |
| 87 | 87 | } |
| 88 | - }elseif(is_string($res)){ |
|
| 88 | + }elseif (is_string($res)) { |
|
| 89 | 89 | \PhpBoot\abort($res); |
| 90 | - }else{ |
|
| 90 | + }else { |
|
| 91 | 91 | return $res; |
| 92 | 92 | } |
| 93 | 93 | } |
@@ -104,19 +104,19 @@ discard block |
||
| 104 | 104 | $reader->class->name = $className; |
| 105 | 105 | |
| 106 | 106 | //method annotations |
| 107 | - foreach ($rfl->getMethods() as $i){ |
|
| 107 | + foreach ($rfl->getMethods() as $i) { |
|
| 108 | 108 | $block = self::readAnnotationBlock($i->getDocComment()); |
| 109 | 109 | $block->name = $i->getName(); |
| 110 | - $reader->methods[$i->getName()]=$block; |
|
| 110 | + $reader->methods[$i->getName()] = $block; |
|
| 111 | 111 | } |
| 112 | 112 | //property annotations |
| 113 | - foreach ($rfl->getProperties() as $i){ |
|
| 113 | + foreach ($rfl->getProperties() as $i) { |
|
| 114 | 114 | if ($i->isStatic()) { |
| 115 | 115 | continue; |
| 116 | 116 | } |
| 117 | 117 | $block = self::readAnnotationBlock($i->getDocComment()); |
| 118 | 118 | $block->name = $i->getName(); |
| 119 | - $reader->properties[$i->getName()]=$block; |
|
| 119 | + $reader->properties[$i->getName()] = $block; |
|
| 120 | 120 | } |
| 121 | 121 | while ($rfl = $rfl->getParentClass()) { |
| 122 | 122 | foreach ($rfl->getProperties(\ReflectionProperty::IS_PRIVATE) as $i) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | } |
| 126 | 126 | $block = self::readAnnotationBlock($i->getDocComment()); |
| 127 | 127 | $block->name = $i->getName(); |
| 128 | - $reader->properties[$i->getName()]=$block; |
|
| 128 | + $reader->properties[$i->getName()] = $block; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | return $reader; |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | static private function readAnnotationBlock($doc) |
| 135 | 135 | { |
| 136 | 136 | $annBlock = new AnnotationBlock(); |
| 137 | - if(empty($doc)){ |
|
| 137 | + if (empty($doc)) { |
|
| 138 | 138 | return $annBlock; |
| 139 | 139 | } |
| 140 | 140 | $docFactory = AnnotationReader::createDocBlockFactory(); |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | $annTag->parent = $annBlock; |
| 150 | 150 | $annTag->description = strval($desc); |
| 151 | 151 | $annTag->name = $tag->getName(); |
| 152 | - $annTag->children=[]; |
|
| 153 | - if($desc){ |
|
| 152 | + $annTag->children = []; |
|
| 153 | + if ($desc) { |
|
| 154 | 154 | $output = new AnnotationTagsOutput(); |
| 155 | 155 | $desc->render($output); |
| 156 | 156 | foreach ($output->tags as $child) { |
@@ -174,11 +174,11 @@ discard block |
||
| 174 | 174 | * @var AnnotationBlock[] |
| 175 | 175 | */ |
| 176 | 176 | |
| 177 | - public $methods=[]; |
|
| 177 | + public $methods = []; |
|
| 178 | 178 | /** |
| 179 | 179 | * @var AnnotationBlock[] |
| 180 | 180 | */ |
| 181 | - public $properties=[]; |
|
| 181 | + public $properties = []; |
|
| 182 | 182 | |
| 183 | 183 | public function offsetExists($offset) |
| 184 | 184 | { |