Prechádzať zdrojové kódy

Check if reflectionclass has a doc block

Marcel Pociot 9 rokov pred
rodič
commit
62690bfc25

+ 6 - 4
src/Mpociot/ApiDoc/Generators/AbstractGenerator.php

@@ -112,10 +112,12 @@ abstract class AbstractGenerator
         list($class, $method) = explode('@', $route);
         $reflection = new ReflectionClass($class);
         $comment = $reflection->getDocComment();
-        $phpdoc = new DocBlock($comment);
-        foreach ($phpdoc->getTags() as $tag) {
-            if ($tag->getName() === 'resource') {
-                return $tag->getContent();
+        if ($comment) {
+            $phpdoc = new DocBlock($comment);
+            foreach ($phpdoc->getTags() as $tag) {
+                if ($tag->getName() === 'resource') {
+                    return $tag->getContent();
+                }
             }
         }