Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: [5.x] add void return types #2395

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,22 @@ Future proofing for potential future changes and keeping it consistent with `des
## BC BREAK: `Nelmio\ApiDocBundle\Command` has been made final

## BC BREAK: Made classes implementing `Nelmio\ApiDocBundle\PropertyDescriber\PropertyDescriberInterface` final
`Nelmio\ApiDocBundle\PropertyDescriber\ArrayPropertyDescriber`
`Nelmio\ApiDocBundle\PropertyDescriber\BooleanPropertyDescriber`
`Nelmio\ApiDocBundle\PropertyDescriber\DateTimePropertyDescriber`
`Nelmio\ApiDocBundle\PropertyDescriber\CompoundPropertyDescriber`
`Nelmio\ApiDocBundle\PropertyDescriber\FloatPropertyDescriber`
`Nelmio\ApiDocBundle\PropertyDescriber\IntegerPropertyDescriber`
`Nelmio\ApiDocBundle\PropertyDescriber\ObjectPropertyDescriber`
`Nelmio\ApiDocBundle\PropertyDescriber\StringPropertyDescriber`
- `Nelmio\ApiDocBundle\PropertyDescriber\ArrayPropertyDescriber`
- `Nelmio\ApiDocBundle\PropertyDescriber\BooleanPropertyDescriber`
- `Nelmio\ApiDocBundle\PropertyDescriber\DateTimePropertyDescriber`
- `Nelmio\ApiDocBundle\PropertyDescriber\CompoundPropertyDescriber`
- `Nelmio\ApiDocBundle\PropertyDescriber\FloatPropertyDescriber`
- `Nelmio\ApiDocBundle\PropertyDescriber\IntegerPropertyDescriber`
- `Nelmio\ApiDocBundle\PropertyDescriber\ObjectPropertyDescriber`
- `Nelmio\ApiDocBundle\PropertyDescriber\StringPropertyDescriber`

## BC BREAK: Added `void` return type to:
- `Nelmio\ApiDocBundle\Describer\DescriberInterface::describe()`
- `Nelmio\ApiDocBundle\Describer\ExternalDocDescriber::describe()`
- `Nelmio\ApiDocBundle\ModelDescriber\ModelDescriberInterface::describe()`
- `Nelmio\ApiDocBundle\ModelDescriber\FallbackObjectModelDescriber::describe()`
- `Nelmio\ApiDocBundle\ModelDescriber\JMSModelDescriber::describe()`
- `Nelmio\ApiDocBundle\Describer\ModelRegistryAwareInterface::setModelRegistry()`
- `Nelmio\ApiDocBundle\Describer\ModelRegistryAwareTrait::setModelRegistry()`
- `Nelmio\ApiDocBundle\PropertyDescriber\PropertyDescriberInterface::describe()`
- `Nelmio\ApiDocBundle\RouteDescriber\RouteDescriberInterface::describe()`
5 changes: 1 addition & 4 deletions src/Describer/DescriberInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,5 @@

interface DescriberInterface
{
/**
* @return void
*/
public function describe(OpenApi $api);
public function describe(OpenApi $api): void;
}
7 changes: 2 additions & 5 deletions src/Describer/ExternalDocDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public function __construct($externalDoc, bool $overwrite = false)
$this->overwrite = $overwrite;
}

/**
* @return void
*/
public function describe(OA\OpenApi $api)
public function describe(OA\OpenApi $api): void
{
$externalDoc = $this->getExternalDoc();

Expand All @@ -47,7 +44,7 @@ public function describe(OA\OpenApi $api)
/**
* @return mixed The external doc
*/
private function getExternalDoc()
private function getExternalDoc(): mixed
{
if (is_callable($this->externalDoc)) {
return call_user_func($this->externalDoc);
Expand Down
5 changes: 1 addition & 4 deletions src/Describer/ModelRegistryAwareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,5 @@

interface ModelRegistryAwareInterface
{
/**
* @return void
*/
public function setModelRegistry(ModelRegistry $modelRegistry);
public function setModelRegistry(ModelRegistry $modelRegistry): void;
}
5 changes: 1 addition & 4 deletions src/Describer/ModelRegistryAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ trait ModelRegistryAwareTrait
{
private ModelRegistry $modelRegistry;

/**
* @return void
*/
public function setModelRegistry(ModelRegistry $modelRegistry)
public function setModelRegistry(ModelRegistry $modelRegistry): void
{
$this->modelRegistry = $modelRegistry;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ModelDescriber/BazingaHateoasModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(MetadataFactoryInterface $factory, JMSModelDescriber
$this->JMSModelDescriber = $JMSModelDescriber;
}

public function setModelRegistry(ModelRegistry $modelRegistry)
public function setModelRegistry(ModelRegistry $modelRegistry): void
{
$this->modelRegistry = $modelRegistry;
$this->JMSModelDescriber->setModelRegistry($modelRegistry);
Expand Down
2 changes: 1 addition & 1 deletion src/ModelDescriber/EnumModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class EnumModelDescriber implements ModelDescriberInterface
{
public const FORCE_NAMES = '_nelmio_enum_force_names';

public function describe(Model $model, Schema $schema)
public function describe(Model $model, Schema $schema): void
{
$enumClass = $model->getType()->getClassName();
$forceName = isset($model->getSerializationContext()[self::FORCE_NAMES]) && true === $model->getSerializationContext()[self::FORCE_NAMES];
Expand Down
5 changes: 1 addition & 4 deletions src/ModelDescriber/FallbackObjectModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@

class FallbackObjectModelDescriber implements ModelDescriberInterface
{
/**
* @return void
*/
public function describe(Model $model, OA\Schema $schema)
public function describe(Model $model, OA\Schema $schema): void
{
}

Expand Down
5 changes: 1 addition & 4 deletions src/ModelDescriber/JMSModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ public function __construct(
$this->contextFactory = $contextFactory;
}

/**
* @return void
*/
public function describe(Model $model, OA\Schema $schema)
public function describe(Model $model, OA\Schema $schema): void
{
$className = $model->getType()->getClassName();
$metadata = $this->factory->getMetadataForClass($className);
Expand Down
5 changes: 1 addition & 4 deletions src/ModelDescriber/ModelDescriberInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

interface ModelDescriberInterface
{
/**
* @return void
*/
public function describe(Model $model, Schema $schema);
public function describe(Model $model, Schema $schema): void;

public function supports(Model $model): bool;
}
2 changes: 1 addition & 1 deletion src/ModelDescriber/ObjectModelDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(
$this->classMetadataFactory = $classMetadataFactory;
}

public function describe(Model $model, OA\Schema $schema)
public function describe(Model $model, OA\Schema $schema): void
{
$class = $model->getType()->getClassName();
$schema->_context->class = $class;
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/ArrayPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class ArrayPropertyDescriber implements PropertyDescriberInterface, ModelR
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$property->type = 'array';
/** @var OA\Items $property */
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/BooleanPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class BooleanPropertyDescriber implements PropertyDescriberInterface
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$property->type = 'boolean';
}
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/CompoundPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class CompoundPropertyDescriber implements PropertyDescriberInterface, Mod
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$property->oneOf = Generator::UNDEFINED !== $property->oneOf ? $property->oneOf : [];

Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/DateTimePropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class DateTimePropertyDescriber implements PropertyDescriberInterface
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$property->type = 'string';
$property->format = 'date-time';
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/DictionaryPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class DictionaryPropertyDescriber implements PropertyDescriberInterface, M
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$property->type = 'object';
/** @var OA\AdditionalProperties $additionalProperties */
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/FloatPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class FloatPropertyDescriber implements PropertyDescriberInterface
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$property->type = 'number';
$property->format = 'float';
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/IntegerPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class IntegerPropertyDescriber implements PropertyDescriberInterface
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$property->type = 'integer';
}
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/NullablePropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class NullablePropertyDescriber implements PropertyDescriberInterface, Pro
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
if (Generator::UNDEFINED === $property->nullable) {
$property->nullable = true;
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/ObjectPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class ObjectPropertyDescriber implements PropertyDescriberInterface, Model
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$type = new Type(
$types[0]->getBuiltinType(),
Expand Down
4 changes: 1 addition & 3 deletions src/PropertyDescriber/PropertyDescriberInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ interface PropertyDescriberInterface
/**
* @param Type[] $types
* @param array<string, mixed> $context Context options for describing the property
*
* @return void
*/
public function describe(array $types, Schema $property, array $context = []);
public function describe(array $types, Schema $property, array $context = []): void;

/**
* @param Type[] $types
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/StringPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class StringPropertyDescriber implements PropertyDescriberInterface
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$property->type = 'string';
}
Expand Down
2 changes: 1 addition & 1 deletion src/PropertyDescriber/UuidPropertyDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class UuidPropertyDescriber implements PropertyDescriberInterface
/**
* @param array<string, mixed> $context Context options for describing the property
*/
public function describe(array $types, OA\Schema $property, array $context = [])
public function describe(array $types, OA\Schema $property, array $context = []): void
{
$property->type = 'string';
$property->format = 'uuid';
Expand Down
5 changes: 1 addition & 4 deletions src/RouteDescriber/RouteDescriberInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@

interface RouteDescriberInterface
{
/**
* @return void
*/
public function describe(OpenApi $api, Route $route, \ReflectionMethod $reflectionMethod);
public function describe(OpenApi $api, Route $route, \ReflectionMethod $reflectionMethod): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class VirtualTypeClassDoesNotExistsHandlerDefinedDescriber implements ModelDescriberInterface
{
public function describe(Model $model, OA\Schema $schema)
public function describe(Model $model, OA\Schema $schema): void
{
$schema->type = 'object';
$property = Util::getProperty($schema, 'custom_prop');
Expand Down
Loading