diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php index 6e999a2..f4fe075 100644 --- a/Annotation/ApiDoc.php +++ b/Annotation/ApiDoc.php @@ -526,7 +526,7 @@ class ApiDoc //replace route placeholders foreach ($route->getDefaults() as $key => $value) { - if (is_string($value)) { + if (null !== $this->host && is_string($value)) { $this->host = str_replace('{' . $key . '}', $value, $this->host); } } diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index d347db6..222701c 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -149,7 +149,7 @@ class ApiDocExtractor $resources[] = $resource; } else { // remove format from routes used for resource grouping - $resources[] = str_replace('.{_format}', '', $route->getPath()); + $resources[] = str_replace('.{_format}', '', $route->getPath() ?: ''); } } @@ -168,7 +168,7 @@ class ApiDocExtractor rsort($resources); foreach ($array as $index => $element) { $hasResource = false; - $path = $element['annotation']->getRoute()->getPath(); + $path = $element['annotation']->getRoute()->getPath() ?: ''; foreach ($resources as $resource) { if (0 === strpos($path, $resource) || $resource === $element['annotation']->getResource()) { diff --git a/Formatter/AbstractFormatter.php b/Formatter/AbstractFormatter.php index 981e294..7676e73 100644 --- a/Formatter/AbstractFormatter.php +++ b/Formatter/AbstractFormatter.php @@ -173,7 +173,7 @@ abstract class AbstractFormatter implements FormatterInterface } } - $annotation['id'] = strtolower($annotation['method']).'-'.str_replace('/', '-', $annotation['uri']); + $annotation['id'] = strtolower($annotation['method'] ?? '').'-'.str_replace('/', '-', $annotation['uri'] ?? ''); return $annotation; } diff --git a/Formatter/SwaggerFormatter.php b/Formatter/SwaggerFormatter.php index 2de44ed..46082e5 100644 --- a/Formatter/SwaggerFormatter.php +++ b/Formatter/SwaggerFormatter.php @@ -594,6 +594,6 @@ class SwaggerFormatter implements FormatterInterface $resource = preg_replace('#/^#', '', $resource); $resource = $this->normalizeResourcePath($resource); - return sprintf('%s_%s', strtolower($method), $resource); + return sprintf('%s_%s', strtolower($method ?: ''), $resource); } } diff --git a/Util/DocCommentExtractor.php b/Util/DocCommentExtractor.php index a06a587..1ea3862 100644 --- a/Util/DocCommentExtractor.php +++ b/Util/DocCommentExtractor.php @@ -10,7 +10,7 @@ class DocCommentExtractor */ public function getDocComment(\Reflector $reflected) { - $comment = $reflected->getDocComment(); + $comment = $reflected->getDocComment() ?? ''; // let's clean the doc block $comment = str_replace('/**', '', $comment);