Explorar o código

Check if reflectionclass has a doc block

Marcel Pociot %!s(int64=9) %!d(string=hai) anos
pai
achega
62690bfc25
Modificáronse 1 ficheiros con 6 adicións e 4 borrados
  1. 6 4
      src/Mpociot/ApiDoc/Generators/AbstractGenerator.php

+ 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();
+                }
             }
         }