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

bump minimum version to php 7.4 #2171

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 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
5 changes: 1 addition & 4 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,9 @@ jobs:
fail-fast: false
matrix:
include:
- php-version: 7.2
- php-version: 7.4
composer-flags: "--prefer-lowest"
doctrine-annotations: true
- php-version: 7.3
symfony-require: "5.4.*"
doctrine-annotations: true
- php-version: 7.4
symfony-require: "5.4.*"
doctrine-annotations: true
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/composer.phar
/composer.lock
/.php_cs.cache
/.php-cs-fixer.cache
/.php_cs
/phpunit.xml
/.phpunit
Expand Down
7 changes: 3 additions & 4 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

$finder = PhpCsFixer\Finder::create()
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude('var')
->exclude('Tests/Functional/cache')
;

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'nullable_type_declaration_for_default_null_value' => true,
'header_comment' => [
'header' => <<<HEADER
This file is part of the NelmioApiDocBundle package.
Expand Down
2 changes: 1 addition & 1 deletion Annotation/Areas.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
final class Areas
{
/** @var string[] */
private $areas;
private array $areas;

public function __construct(array $properties)
{
Expand Down
20 changes: 8 additions & 12 deletions Annotation/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#[\Attribute(\Attribute::TARGET_METHOD)]
final class Model extends Attachable
{
/** {@inheritdoc} */
public static $_types = [
'type' => 'string',
'groups' => '[string]',
Expand All @@ -34,25 +33,22 @@ final class Model extends Attachable
Parameter::class,
];

/**
* @var string
*/
public $type;
public string $type;

/**
* @var string[]
* @var string[]|null
*/
public $groups;
public ?array $groups;

/**
* @var mixed[]
* @var mixed[]|null
*/
public $options;
public ?array $options;

/**
* @var array<string, mixed>
*/
public $serializationContext;
public array $serializationContext;

/**
* @param mixed[] $properties
Expand All @@ -63,8 +59,8 @@ final class Model extends Attachable
public function __construct(
array $properties = [],
string $type = Generator::UNDEFINED,
array $groups = null,
array $options = null,
?array $groups = null,
?array $options = null,
array $serializationContext = []
) {
parent::__construct($properties + [
Expand Down
10 changes: 3 additions & 7 deletions Annotation/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,23 @@
#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Security extends AbstractAnnotation
{
/** {@inheritdoc} */
public static $_types = [
'name' => 'string',
'scopes' => '[string]',
];

public static $_required = ['name'];

/**
* @var string
*/
public $name;
public ?string $name;

/**
* @var string[]
*/
public $scopes = [];
public array $scopes = [];

public function __construct(
array $properties = [],
string $name = null,
?string $name = null,
array $scopes = []
) {
parent::__construct($properties + [
Expand Down
4 changes: 2 additions & 2 deletions ApiDocGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class ApiDocGenerator
/**
* @var ?string
*/
private $openApiVersion = null;
private $openApiVersion;

/** @var Generator */
private $generator;
Expand All @@ -60,7 +60,7 @@ final class ApiDocGenerator
* @param DescriberInterface[]|iterable $describers
* @param ModelDescriberInterface[]|iterable $modelDescribers
*/
public function __construct($describers, $modelDescribers, CacheItemPoolInterface $cacheItemPool = null, string $cacheItemId = null, Generator $generator = null)
public function __construct($describers, $modelDescribers, ?CacheItemPoolInterface $cacheItemPool = null, ?string $cacheItemId = null, ?Generator $generator = null)
{
$this->describers = $describers;
$this->modelDescribers = $modelDescribers;
Expand Down
7 changes: 2 additions & 5 deletions Command/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@

class DumpCommand extends Command
{
/**
* @var RenderOpenApi
*/
private $renderOpenApi;
private RenderOpenApi $renderOpenApi;

/**
* @var mixed[]
*/
private $defaultHtmlConfig = [
private array $defaultHtmlConfig = [
'assets_mode' => AssetsMode::CDN,
'swagger_ui_config' => [],
];
Expand Down
7 changes: 2 additions & 5 deletions Controller/DocumentationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@

final class DocumentationController
{
/**
* @var RenderOpenApi
*/
private $renderOpenApi;
private RenderOpenApi $renderOpenApi;

public function __construct(RenderOpenApi $renderOpenApi)
{
$this->renderOpenApi = $renderOpenApi;
}

public function __invoke(Request $request, $area = 'default')
public function __invoke(Request $request, string $area = 'default')
{
try {
return JsonResponse::fromJsonString(
Expand Down
7 changes: 2 additions & 5 deletions Controller/SwaggerUiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,14 @@

final class SwaggerUiController
{
/**
* @var RenderOpenApi
*/
private $renderOpenApi;
private RenderOpenApi $renderOpenApi;

public function __construct(RenderOpenApi $renderOpenApi)
{
$this->renderOpenApi = $renderOpenApi;
}

public function __invoke(Request $request, $area = 'default')
public function __invoke(Request $request, string $area = 'default')
{
try {
$response = new Response(
Expand Down
10 changes: 3 additions & 7 deletions Controller/YamlDocumentationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,21 @@

namespace Nelmio\ApiDocBundle\Controller;

use InvalidArgumentException;
use Nelmio\ApiDocBundle\Render\RenderOpenApi;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;

final class YamlDocumentationController
{
/**
* @var RenderOpenApi
*/
private $renderOpenApi;
private RenderOpenApi $renderOpenApi;

public function __construct(RenderOpenApi $renderOpenApi)
{
$this->renderOpenApi = $renderOpenApi;
}

public function __invoke(Request $request, $area = 'default')
public function __invoke(Request $request, string $area = 'default')
{
try {
$response = new Response(
Expand All @@ -39,7 +35,7 @@ public function __invoke(Request $request, $area = 'default')
);

return $response->setCharset('UTF-8');
} catch (InvalidArgumentException $e) {
} catch (\InvalidArgumentException $e) {
throw new BadRequestHttpException(sprintf('Area "%s" is not supported as it isn\'t defined in config.', $area));
}
}
Expand Down
6 changes: 0 additions & 6 deletions DependencyInjection/NelmioApiDocExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@

final class NelmioApiDocExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container): void
{
$container->prependExtensionConfig('framework', ['property_info' => ['enabled' => true]]);
Expand All @@ -62,9 +59,6 @@ public function prepend(ContainerBuilder $container): void
}
}

/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration(new Configuration(), $configs);
Expand Down
5 changes: 4 additions & 1 deletion Describer/ExternalDocDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

class ExternalDocDescriber implements DescriberInterface
{
/**
* @var array|callable
*/
private $externalDoc;

private $overwrite;
private bool $overwrite;

/**
* @param array|callable $externalDoc
Expand Down
5 changes: 1 addition & 4 deletions Describer/ModelRegistryAwareTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

trait ModelRegistryAwareTrait
{
/**
* @var ModelRegistry
*/
private $modelRegistry;
private ModelRegistry $modelRegistry;
DjordyKoert marked this conversation as resolved.
Show resolved Hide resolved

public function setModelRegistry(ModelRegistry $modelRegistry)
{
Expand Down
21 changes: 9 additions & 12 deletions Describer/OpenApiPhpDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@ final class OpenApiPhpDescriber
{
use SetsContextTrait;

private $routeCollection;
private $controllerReflector;
private RouteCollection $routeCollection;
private ControllerReflector $controllerReflector;

/**
* @var Reader|null
*/
private $annotationReader;
private $logger;
private $overwrite;
private ?Reader $annotationReader;
private LoggerInterface $logger;
private bool $overwrite;

public function __construct(RouteCollection $routeCollection, ControllerReflector $controllerReflector, ?Reader $annotationReader, LoggerInterface $logger, bool $overwrite = false)
{
Expand Down Expand Up @@ -144,10 +141,10 @@ public function describe(OA\OpenApi $api)
}

if (
!$annotation instanceof OA\Response &&
!$annotation instanceof OA\RequestBody &&
!$annotation instanceof OA\Parameter &&
!$annotation instanceof OA\ExternalDocumentation
!$annotation instanceof OA\Response
&& !$annotation instanceof OA\RequestBody
&& !$annotation instanceof OA\Parameter
&& !$annotation instanceof OA\ExternalDocumentation
) {
throw new \LogicException(sprintf('Using the annotation "%s" as a root annotation in "%s::%s()" is not allowed.', get_class($annotation), $method->getDeclaringClass()->name, $method->name));
}
Expand Down
11 changes: 7 additions & 4 deletions Describer/RouteDescriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ final class RouteDescriber implements DescriberInterface, ModelRegistryAwareInte
{
use ModelRegistryAwareTrait;

private $routeCollection;
private RouteCollection $routeCollection;

private $controllerReflector;
private ControllerReflector $controllerReflector;

private $routeDescribers;
/**
* @var iterable|RouteDescriberInterface[]
*/
private iterable $routeDescribers;

/**
* @param RouteDescriberInterface[]|iterable $routeDescribers
*/
public function __construct(RouteCollection $routeCollection, ControllerReflector $controllerReflector, $routeDescribers)
public function __construct(RouteCollection $routeCollection, ControllerReflector $controllerReflector, iterable $routeDescribers)
{
$this->routeCollection = $routeCollection;
$this->controllerReflector = $controllerReflector;
Expand Down
10 changes: 5 additions & 5 deletions Exception/UndocumentedArrayItemsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
*/
class UndocumentedArrayItemsException extends \LogicException
{
private $class;
private $path;
private ?string $class;
private string $path;

public function __construct(string $class = null, string $path = '')
public function __construct(?string $class = null, string $path = '')
{
$this->class = $class;
$this->path = $path;
Expand All @@ -33,12 +33,12 @@ public function __construct(string $class = null, string $path = '')
parent::__construct(sprintf('Property "%s" is an array, but its items type isn\'t specified. You can specify that by using the type `string[]` for instance or `@OA\Property(type="array", @OA\Items(type="string"))`.', $propertyName));
}

public function getClass()
public function getClass(): ?string
{
return $this->class;
}

public function getPath()
public function getPath(): string
{
return $this->path;
}
Expand Down
Loading
Loading