mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-11 18:16:13 +03:00
Add return types
This commit is contained in:
parent
1b7eb1c69c
commit
12247cb56e
@ -135,7 +135,7 @@ final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelReg
|
||||
return $analysis;
|
||||
}
|
||||
|
||||
private function getMethodsToParse()
|
||||
private function getMethodsToParse(): \Generator
|
||||
{
|
||||
foreach ($this->routeCollection->all() as $route) {
|
||||
if (!$route->hasDefault('_controller')) {
|
||||
@ -154,7 +154,7 @@ final class SwaggerPhpDescriber extends ExternalDocDescriber implements ModelReg
|
||||
}
|
||||
}
|
||||
|
||||
private function normalizePath(string $path)
|
||||
private function normalizePath(string $path): string
|
||||
{
|
||||
if (substr($path, -10) === '.{_format}') {
|
||||
$path = substr($path, 0, -10);
|
||||
|
@ -30,7 +30,7 @@ final class Model
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function getHash()
|
||||
public function getHash(): string
|
||||
{
|
||||
return md5(serialize($this->type));
|
||||
}
|
||||
|
@ -101,11 +101,12 @@ final class ModelRegistry
|
||||
return $name;
|
||||
}
|
||||
|
||||
private function getTypeShortName(Type $type)
|
||||
private function getTypeShortName(Type $type): string
|
||||
{
|
||||
if (null !== $type->getCollectionValueType()) {
|
||||
return $this->getTypeShortName($type->getCollectionValueType()).'[]';
|
||||
}
|
||||
|
||||
if (Type::BUILTIN_TYPE_OBJECT === $type->getBuiltinType()) {
|
||||
$parts = explode('\\', $type->getClassName());
|
||||
|
||||
|
@ -28,7 +28,7 @@ class CollectionModelDescriber implements ModelDescriberInterface, ModelRegistry
|
||||
);
|
||||
}
|
||||
|
||||
public function supports(Model $model)
|
||||
public function supports(Model $model): bool
|
||||
{
|
||||
return $model->getType()->isCollection() && null !== $model->getType()->getCollectionValueType();
|
||||
}
|
||||
|
@ -18,5 +18,5 @@ interface ModelDescriberInterface
|
||||
{
|
||||
public function describe(Model $model, Schema $schema);
|
||||
|
||||
public function supports(Model $model);
|
||||
public function supports(Model $model): bool;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
|
||||
}
|
||||
}
|
||||
|
||||
public function supports(Model $model)
|
||||
public function supports(Model $model): bool
|
||||
{
|
||||
return Type::BUILTIN_TYPE_OBJECT === $model->getType()->getBuiltinType();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class ScalarModelDescriber implements ModelDescriberInterface
|
||||
$schema->setType($type);
|
||||
}
|
||||
|
||||
public function supports(Model $model)
|
||||
public function supports(Model $model): bool
|
||||
{
|
||||
return isset(self::$supportedTypes[$model->getType()->getBuiltinType()]);
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ trait RouteDescriberTrait
|
||||
*
|
||||
* @return Operation[]
|
||||
*/
|
||||
private function getOperations(Swagger $api, Route $route)
|
||||
private function getOperations(Swagger $api, Route $route): array
|
||||
{
|
||||
$path = $api->getPaths()->get($this->normalizePath($route->getPath()));
|
||||
$methods = $route->getMethods() ?: Swagger::$METHODS;
|
||||
@ -41,7 +41,7 @@ trait RouteDescriberTrait
|
||||
return $operations;
|
||||
}
|
||||
|
||||
private function normalizePath(string $path)
|
||||
private function normalizePath(string $path): string
|
||||
{
|
||||
if (substr($path, -10) === '.{_format}') {
|
||||
$path = substr($path, 0, -10);
|
||||
|
Loading…
x
Reference in New Issue
Block a user