mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 07:41:43 +03:00
Compability with PHP 8.1 (string functions calling)
This commit is contained in:
parent
c764717de4
commit
0765d2b453
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user