Skip to content

Commit

Permalink
Merge 8a60e00 into 25c71b2
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Oct 11, 2021
2 parents 25c71b2 + 8a60e00 commit 016dfb3
Show file tree
Hide file tree
Showing 166 changed files with 614 additions and 991 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -15,10 +15,8 @@ jobs:
strategy:
matrix:
php:
- '7.4'
- '8.0'
fail-fast: false
env:
PHP_CS_FIXER_FUTURE_MODE: '1'
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -40,7 +38,7 @@ jobs:
strategy:
matrix:
php:
- '7.4'
- '8.0'
fail-fast: false
env:
APP_DEBUG: '1' # https://github.com/phpstan/phpstan-symfony/issues/37
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -72,6 +72,7 @@
"symfony/form": "^3.4 || ^4.4 || ^5.1",
"symfony/framework-bundle": "^4.4 || ^5.1",
"symfony/http-client": "^4.4 || ^5.1",
"symfony/intl": "^4.4 || ^5.3",
"symfony/mercure-bundle": "*",
"symfony/messenger": "^4.4 || ^5.1",
"symfony/phpunit-bridge": "^5.1.7",
Expand Down
1 change: 1 addition & 0 deletions features/doctrine/date_filter.feature
Expand Up @@ -7,6 +7,7 @@ Feature: Date filter on collections
Scenario: Get collection filtered by date
Given there are 30 dummy objects with dummyDate
When I send a "GET" request to "/dummies?dummyDate[after]=2015-04-28"
Then print last JSON response
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
Expand Down
3 changes: 2 additions & 1 deletion features/main/custom_normalized.feature
Expand Up @@ -53,7 +53,7 @@ Feature: Using custom normalized entity
}
"""

Scenario: Create a resource with a custom normalized dummy and an id
Scenario: Update a resource with a custom normalized dummy and an id
When I add "Content-Type" header equal to "application/json"
When I add "Accept" header equal to "application/json"
And I send a "PUT" request to "/related_normalized_dummies/1" with body:
Expand All @@ -69,6 +69,7 @@ Feature: Using custom normalized entity
}]
}
"""
Then print last JSON response
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/json; charset=utf-8"
Expand Down
3 changes: 0 additions & 3 deletions phpstan.neon.dist
Expand Up @@ -86,9 +86,6 @@ parameters:
path: tests/GraphQl/Type/TypesContainerTest.php

# Expected, due to PHP 8 attributes
- '#ReflectionProperty::getAttributes\(\)#'
- '#ReflectionMethod::getAttributes\(\)#'
- '#ReflectionClass<object>::getAttributes\(\)#'
- '#Constructor of class ApiPlatform\\Core\\Annotation\\ApiResource has an unused parameter#'
- '#Constructor of class ApiPlatform\\Core\\Annotation\\ApiProperty has an unused parameter#'

Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Doctrine/MongoDbOdm/CollectionDataProvider.php
Expand Up @@ -56,7 +56,7 @@ public function supports(string $resourceClass, string $operationName = null, ar
*
* @throws RuntimeException
*/
public function getCollection(string $resourceClass, string $operationName = null, array $context = [])
public function getCollection(string $resourceClass, string $operationName = null, array $context = []): iterable
{
/** @var DocumentManager $manager */
$manager = $this->managerRegistry->getManagerForClass($resourceClass);
Expand Down
Expand Up @@ -43,8 +43,10 @@ public function __construct(ObjectManager $objectManager)

/**
* {@inheritdoc}
*
* @return string[]|null
*/
public function getProperties($class, array $context = [])
public function getProperties($class, array $context = []): ?array
{
if (null === $metadata = $this->getMetadata($class)) {
return null;
Expand All @@ -55,8 +57,10 @@ public function getProperties($class, array $context = [])

/**
* {@inheritdoc}
*
* @return Type[]|null
*/
public function getTypes($class, $property, array $context = [])
public function getTypes($class, $property, array $context = []): ?array
{
if (null === $metadata = $this->getMetadata($class)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Doctrine/Orm/CollectionDataProvider.php
Expand Up @@ -53,7 +53,7 @@ public function supports(string $resourceClass, string $operationName = null, ar
*
* @throws RuntimeException
*/
public function getCollection(string $resourceClass, string $operationName = null, array $context = [])
public function getCollection(string $resourceClass, string $operationName = null, array $context = []): iterable
{
/** @var EntityManagerInterface $manager */
$manager = $this->managerRegistry->getManagerForClass($resourceClass);
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Doctrine/Orm/Extension/PaginationExtension.php
Expand Up @@ -155,7 +155,7 @@ public function supportsResult(string $resourceClass, string $operationName = nu
/**
* {@inheritdoc}
*/
public function getResult(QueryBuilder $queryBuilder, string $resourceClass = null, string $operationName = null, array $context = [])
public function getResult(QueryBuilder $queryBuilder, string $resourceClass = null, string $operationName = null, array $context = []): iterable
{
$query = $queryBuilder->getQuery();

Expand Down
Expand Up @@ -89,7 +89,7 @@ public function supports(string $resourceClass, ?string $operationName = null, a
/**
* {@inheritdoc}
*/
public function getCollection(string $resourceClass, ?string $operationName = null, array $context = [])
public function getCollection(string $resourceClass, ?string $operationName = null, array $context = []): iterable
{
$documentMetadata = $this->documentMetadataFactory->create($resourceClass);
$body = [];
Expand Down
1 change: 1 addition & 0 deletions src/Bridge/Elasticsearch/Serializer/ItemNormalizer.php
Expand Up @@ -52,6 +52,7 @@ public function supportsDenormalization($data, $type, $format = null): bool

/**
* {@inheritdoc}
* @return mixed
*/
public function denormalize($data, $class, $format = null, array $context = [])
{
Expand Down
Expand Up @@ -36,15 +36,15 @@ public function __construct(?NameConverterInterface $decorated = null)
/**
* {@inheritdoc}
*/
public function normalize($propertyName, string $class = null, string $format = null, array $context = [])
public function normalize($propertyName, string $class = null, string $format = null, array $context = []): string
{
return $this->convertInnerFields($propertyName, true, $class, $format, $context);
}

/**
* {@inheritdoc}
*/
public function denormalize($propertyName, string $class = null, string $format = null, array $context = [])
public function denormalize($propertyName, string $class = null, string $format = null, array $context = []): string
{
return $this->convertInnerFields($propertyName, false, $class, $format, $context);
}
Expand Down
Expand Up @@ -36,8 +36,10 @@ public function __construct(Psr6CacheClearer $poolClearer, array $pools = [])

/**
* {@inheritdoc}
*
* @return string[]
*/
public function warmUp($cacheDirectory)
public function warmUp($cacheDirectory): array
{
foreach ($this->pools as $pool) {
if ($this->poolClearer->hasPool($pool)) {
Expand Down
2 changes: 2 additions & 0 deletions src/Bridge/Symfony/Bundle/Command/GraphQlExportCommand.php
Expand Up @@ -54,6 +54,8 @@ protected function configure(): void

/**
* {@inheritdoc}
*
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/Bundle/Command/OpenApiCommand.php
Expand Up @@ -57,7 +57,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
// Backwards compatibility
if (2 === $specVersion = (int) $input->getOption('spec-version')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/Bundle/Command/SwaggerCommand.php
Expand Up @@ -79,7 +79,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

Expand Down
Expand Up @@ -45,7 +45,7 @@ public function getContext(): array
return $this->context;
}

public function getCollection(string $resourceClass, string $operationName = null, array $context = [])
public function getCollection(string $resourceClass, string $operationName = null, array $context = []): iterable
{
$this->context = $context;
$results = null;
Expand Down
Expand Up @@ -47,8 +47,9 @@ final class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
* @return TreeBuilder
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$treeBuilder = new TreeBuilder('api_platform');
Expand Down
1 change: 1 addition & 0 deletions src/Bridge/Symfony/Bundle/Test/Response.php
Expand Up @@ -65,6 +65,7 @@ public function __construct(HttpFoundationResponse $httpFoundationResponse, Brow

/**
* {@inheritdoc}
* @return mixed
*/
public function getInfo(string $type = null)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Bridge/Symfony/Identifier/Normalizer/UlidNormalizer.php
Expand Up @@ -24,6 +24,7 @@ final class UlidNormalizer implements DenormalizerInterface
{
/**
* {@inheritdoc}
* @return mixed
*/
public function denormalize($data, $class, $format = null, array $context = [])
{
Expand All @@ -37,7 +38,7 @@ public function denormalize($data, $class, $format = null, array $context = [])
/**
* {@inheritdoc}
*/
public function supportsDenormalization($data, $type, $format = null)
public function supportsDenormalization($data, $type, $format = null): bool
{
return \is_string($data) && is_a($type, Ulid::class, true);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Bridge/Symfony/Messenger/DataTransformer.php
Expand Up @@ -33,6 +33,8 @@ public function __construct(ResourceMetadataFactoryInterface $resourceMetadataFa

/**
* {@inheritdoc}
*
* @return object
*/
public function transform($object, string $to, array $context = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Symfony/Routing/ApiLoader.php
Expand Up @@ -157,7 +157,7 @@ public function load($data, $type = null): RouteCollection
/**
* {@inheritdoc}
*/
public function supports($resource, $type = null)
public function supports($resource, $type = null): bool
{
return 'api_platform' === $type;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Bridge/Symfony/Routing/IriConverter.php
Expand Up @@ -66,6 +66,8 @@ public function __construct(PropertyNameCollectionFactoryInterface $propertyName

/**
* {@inheritdoc}
*
* @return object
*/
public function getItemFromIri(string $iri, array $context = [])
{
Expand Down
9 changes: 5 additions & 4 deletions src/Bridge/Symfony/Routing/Router.php
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RouterInterface;

/**
Expand Down Expand Up @@ -54,23 +55,23 @@ public function setContext(RequestContext $context)
/**
* {@inheritdoc}
*/
public function getContext()
public function getContext(): RequestContext
{
return $this->router->getContext();
}

/**
* {@inheritdoc}
*/
public function getRouteCollection()
public function getRouteCollection(): RouteCollection
{
return $this->router->getRouteCollection();
}

/**
* {@inheritdoc}
*/
public function match($pathInfo)
public function match($pathInfo): array
{
$baseContext = $this->router->getContext();
$baseUrl = $baseContext->getBaseUrl();
Expand Down Expand Up @@ -101,7 +102,7 @@ public function match($pathInfo)
/**
* {@inheritdoc}
*/
public function generate($name, $parameters = [], $referenceType = null)
public function generate($name, $parameters = [], $referenceType = null): string
{
return $this->router->generate($name, $parameters, self::CONST_MAP[$referenceType ?? $this->urlGenerationStrategy]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/DataProvider/ChainCollectionDataProvider.php
Expand Up @@ -40,7 +40,7 @@ public function __construct(iterable $dataProviders)
/**
* {@inheritdoc}
*/
public function getCollection(string $resourceClass, string $operationName = null, array $context = [])
public function getCollection(string $resourceClass, string $operationName = null, array $context = []): iterable
{
foreach ($this->dataProviders as $dataProvider) {
try {
Expand Down
4 changes: 1 addition & 3 deletions src/DataProvider/OperationDataProviderTrait.php
Expand Up @@ -46,10 +46,8 @@ trait OperationDataProviderTrait

/**
* Retrieves data for a collection operation.
*
* @return iterable
*/
private function getCollectionData(array $attributes, array $context)
private function getCollectionData(array $attributes, array $context): iterable
{
return $this->collectionDataProvider->getCollection($attributes['resource_class'], $attributes['collection_operation_name'], $context);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Filter/Validator/ArrayItems.php
Expand Up @@ -62,9 +62,12 @@ private function getValue(string $name, array $filterDescription, array $queryPa

$collectionFormat = $filterDescription['swagger']['collectionFormat'] ?? 'csv';

return explode(self::getSeparator($collectionFormat), $value) ?: [];
return explode(self::getSeparator($collectionFormat), $value) ?: []; // @phpstan-ignore-line
}

/**
* @return non-empty-string
*/
private static function getSeparator(string $collectionFormat): string
{
switch ($collectionFormat) {
Expand Down
2 changes: 0 additions & 2 deletions src/Filter/Validator/Required.php
Expand Up @@ -72,8 +72,6 @@ private function requestHasQueryParameter(array $queryParameters, string $name):

/**
* Test if required filter is valid. It validates array notation too like "required[bar]".
*
* @return ?mixed
*/
private function requestGetQueryParameter(array $queryParameters, string $name)
{
Expand Down
3 changes: 3 additions & 0 deletions src/GraphQl/Type/Definition/IterableType.php
Expand Up @@ -33,6 +33,7 @@ trait IterableTypeParseLiteralTrait
* {@inheritdoc}
*
* @param ObjectValueNode|ListValueNode|IntValueNode|FloatValueNode|StringValueNode|BooleanValueNode|NullValueNode $valueNode
* @return mixed
*/
public function parseLiteral(/*Node */ $valueNode, ?array $variables = null)
{
Expand Down Expand Up @@ -90,6 +91,7 @@ public function getName(): string

/**
* {@inheritdoc}
* @return mixed
*/
public function serialize($value)
{
Expand All @@ -102,6 +104,7 @@ public function serialize($value)

/**
* {@inheritdoc}
* @return mixed
*/
public function parseValue($value)
{
Expand Down
3 changes: 3 additions & 0 deletions src/GraphQl/Type/Definition/UploadType.php
Expand Up @@ -24,6 +24,8 @@ trait UploadTypeParseLiteralTrait
{
/**
* {@inheritdoc}
*
* @return mixed
*/
public function parseLiteral(/*Node */ $valueNode, array $variables = null)
{
Expand Down Expand Up @@ -67,6 +69,7 @@ public function getName(): string

/**
* {@inheritdoc}
* @return mixed
*/
public function serialize($value)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Hal/Serializer/EntrypointNormalizer.php
Expand Up @@ -67,7 +67,7 @@ public function normalize($object, $format = null, array $context = [])
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null)
public function supportsNormalization($data, $format = null): bool
{
return self::FORMAT === $format && $data instanceof Entrypoint;
}
Expand Down

0 comments on commit 016dfb3

Please sign in to comment.