Compability with PHP 8.1 (string functions calling)

This commit is contained in:
Ilyas Salikhov 2024-01-30 18:39:44 +03:00
parent c764717de4
commit 0765d2b453
5 changed files with 6 additions and 6 deletions

View File

@ -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);
}
}

View File

@ -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()) {

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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);