mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-03-12 10:36:09 +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;
|
return $analysis;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMethodsToParse()
|
private function getMethodsToParse(): \Generator
|
||||||
{
|
{
|
||||||
foreach ($this->routeCollection->all() as $route) {
|
foreach ($this->routeCollection->all() as $route) {
|
||||||
if (!$route->hasDefault('_controller')) {
|
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}') {
|
if (substr($path, -10) === '.{_format}') {
|
||||||
$path = substr($path, 0, -10);
|
$path = substr($path, 0, -10);
|
||||||
|
@ -30,7 +30,7 @@ final class Model
|
|||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHash()
|
public function getHash(): string
|
||||||
{
|
{
|
||||||
return md5(serialize($this->type));
|
return md5(serialize($this->type));
|
||||||
}
|
}
|
||||||
|
@ -101,11 +101,12 @@ final class ModelRegistry
|
|||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getTypeShortName(Type $type)
|
private function getTypeShortName(Type $type): string
|
||||||
{
|
{
|
||||||
if (null !== $type->getCollectionValueType()) {
|
if (null !== $type->getCollectionValueType()) {
|
||||||
return $this->getTypeShortName($type->getCollectionValueType()).'[]';
|
return $this->getTypeShortName($type->getCollectionValueType()).'[]';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Type::BUILTIN_TYPE_OBJECT === $type->getBuiltinType()) {
|
if (Type::BUILTIN_TYPE_OBJECT === $type->getBuiltinType()) {
|
||||||
$parts = explode('\\', $type->getClassName());
|
$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();
|
return $model->getType()->isCollection() && null !== $model->getType()->getCollectionValueType();
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,5 @@ interface ModelDescriberInterface
|
|||||||
{
|
{
|
||||||
public function describe(Model $model, Schema $schema);
|
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();
|
return Type::BUILTIN_TYPE_OBJECT === $model->getType()->getBuiltinType();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class ScalarModelDescriber implements ModelDescriberInterface
|
|||||||
$schema->setType($type);
|
$schema->setType($type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(Model $model)
|
public function supports(Model $model): bool
|
||||||
{
|
{
|
||||||
return isset(self::$supportedTypes[$model->getType()->getBuiltinType()]);
|
return isset(self::$supportedTypes[$model->getType()->getBuiltinType()]);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ trait RouteDescriberTrait
|
|||||||
*
|
*
|
||||||
* @return Operation[]
|
* @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()));
|
$path = $api->getPaths()->get($this->normalizePath($route->getPath()));
|
||||||
$methods = $route->getMethods() ?: Swagger::$METHODS;
|
$methods = $route->getMethods() ?: Swagger::$METHODS;
|
||||||
@ -41,7 +41,7 @@ trait RouteDescriberTrait
|
|||||||
return $operations;
|
return $operations;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function normalizePath(string $path)
|
private function normalizePath(string $path): string
|
||||||
{
|
{
|
||||||
if (substr($path, -10) === '.{_format}') {
|
if (substr($path, -10) === '.{_format}') {
|
||||||
$path = substr($path, 0, -10);
|
$path = substr($path, 0, -10);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user