Add return types

This commit is contained in:
Guilhem Niot 2017-03-17 19:37:41 +01:00
parent 1b7eb1c69c
commit 12247cb56e
No known key found for this signature in database
GPG Key ID: 7A655BEB5BDC1CA6
8 changed files with 11 additions and 10 deletions

View File

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

View File

@ -30,7 +30,7 @@ final class Model
return $this->type;
}
public function getHash()
public function getHash(): string
{
return md5(serialize($this->type));
}

View File

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

View File

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

View File

@ -18,5 +18,5 @@ interface ModelDescriberInterface
{
public function describe(Model $model, Schema $schema);
public function supports(Model $model);
public function supports(Model $model): bool;
}

View File

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

View File

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

View File

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