Skip to content
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
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
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
9 changes: 4 additions & 5 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
'@PHPUnit60Migration:risky' => true,
'@Symfony' => true,
'@Symfony:risky' => true,
'single_line_comment_style' => false, // Temporary fix for compatibility with PHP 8 attributes, see https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/5284
'comment_to_phpdoc' => true, // Temporary fix for compatibility with PHP 8 attributes, see https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/5284
'align_multiline_comment' => [
'comment_type' => 'phpdocs_like',
],
Expand Down Expand Up @@ -75,9 +73,10 @@
],
],
'no_superfluous_elseif' => true,
'no_superfluous_phpdoc_tags' => [
'allow_mixed' => false,
],
// To re-enable in API Platform 3: https://github.com/symfony/symfony/issues/43021
//'no_superfluous_phpdoc_tags' => [
// 'allow_mixed' => false,
//],
'no_unset_cast' => true,
'no_unset_on_property' => true,
'no_useless_else' => true,
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion features/main/custom_normalized.feature
Original file line number Diff line number Diff line change
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 Down
3 changes: 0 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
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
1 change: 1 addition & 0 deletions src/Api/ResourceClassResolverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface ResourceClassResolverInterface
*
* @param string $resourceClass The expected resource class
* @param bool $strict If true, value must match the expected resource class
* @param mixed $value
*
* @throws InvalidArgumentException
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Bridge/Doctrine/Common/DataPersister.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ public function remove($data, array $context = [])

/**
* Gets the Doctrine object manager associated with given data.
*
* @param mixed $data
*/
private function getManager($data): ?DoctrineObjectManager
{
Expand All @@ -86,6 +88,8 @@ private function getManager($data): ?DoctrineObjectManager

/**
* Checks if doctrine does not manage data automatically.
*
* @param mixed $data
*/
private function isDeferredExplicit(DoctrineObjectManager $manager, $data): bool
{
Expand Down
2 changes: 2 additions & 0 deletions src/Bridge/Doctrine/EventListener/WriteListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public function onKernelView(ViewEvent $event): void

/**
* Gets the manager if applicable.
*
* @param mixed $data
*/
private function getManager(string $resourceClass, $data): ?ObjectManager
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Doctrine/MongoDbOdm/CollectionDataProvider.php
Original file line number Diff line number Diff line change
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
2 changes: 2 additions & 0 deletions src/Bridge/Doctrine/MongoDbOdm/Filter/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public function apply(Builder $aggregationBuilder, string $resourceClass, string

/**
* Passes a property through the filter.
*
* @param mixed $value
*/
abstract protected function filterProperty(string $property, $value, Builder $aggregationBuilder, string $resourceClass, string $operationName = null, array &$context = []);

Expand Down
4 changes: 4 additions & 0 deletions src/Bridge/Doctrine/MongoDbOdm/Filter/SearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ protected function filterProperty(string $property, $value, Builder $aggregation

/**
* Add equality match stage according to the strategy.
*
* @param mixed $values
*/
private function addEqualityMatchStrategy(string $strategy, Builder $aggregationBuilder, string $field, string $matchField, $values, bool $caseSensitive, ClassMetadata $metadata): void
{
Expand All @@ -161,6 +163,8 @@ private function addEqualityMatchStrategy(string $strategy, Builder $aggregation
/**
* Get equality match value according to the strategy.
*
* @param mixed $value
*
* @throws InvalidArgumentException If strategy does not exist
*
* @return Regex|string
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
2 changes: 2 additions & 0 deletions src/Bridge/Doctrine/Orm/Filter/AbstractFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $q

/**
* Passes a property through the filter.
*
* @param mixed $value
*/
abstract protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $operationName = null/*, array $context = []*/);

Expand Down
2 changes: 2 additions & 0 deletions src/Bridge/Doctrine/Orm/Filter/SearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ protected function filterProperty(string $property, $value, QueryBuilder $queryB
/**
* Adds where clause according to the strategy.
*
* @param mixed $values
*
* @throws InvalidArgumentException If strategy does not exist
*/
protected function addWhereByStrategy(string $strategy, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, $values, bool $caseSensitive)
Expand Down
Original file line number Diff line number Diff line change
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
2 changes: 2 additions & 0 deletions src/Bridge/Elasticsearch/Serializer/ItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function supportsDenormalization($data, $type, $format = null): bool

/**
* {@inheritdoc}
*
* @return mixed
*/
public function denormalize($data, $class, $format = null, array $context = [])
{
Expand Down
Original file line number Diff line number Diff line change
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
9 changes: 9 additions & 0 deletions src/Bridge/Symfony/Bundle/Action/SwaggerUiAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ final class SwaggerUiAction
/**
* @param int[] $swaggerVersions
* @param mixed|null $assetPackage
* @param mixed $formats
* @param mixed $oauthEnabled
* @param mixed $oauthClientId
* @param mixed $oauthClientSecret
* @param mixed $oauthType
* @param mixed $oauthFlow
* @param mixed $oauthTokenUrl
* @param mixed $oauthAuthorizationUrl
* @param mixed $oauthScopes
*/
public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, ResourceMetadataFactoryInterface $resourceMetadataFactory, NormalizerInterface $normalizer, ?TwigEnvironment $twig, UrlGeneratorInterface $urlGenerator, string $title = '', string $description = '', string $version = '', $formats = [], $oauthEnabled = false, $oauthClientId = '', $oauthClientSecret = '', $oauthType = '', $oauthFlow = '', $oauthTokenUrl = '', $oauthAuthorizationUrl = '', $oauthScopes = [], bool $showWebby = true, bool $swaggerUiEnabled = false, bool $reDocEnabled = false, bool $graphqlEnabled = false, bool $graphiQlEnabled = false, bool $graphQlPlaygroundEnabled = false, array $swaggerVersions = [2, 3], OpenApiSwaggerUiAction $swaggerUiAction = null, $assetPackage = null)
{
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ protected function additionalFailureDescription($other): string
*
* Specifically, we should ensure that:
* 1. a JSON object is represented as a PHP object, not as an associative array.
*
* @param mixed $document
*/
private function normalizeJson($document)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Bridge/Symfony/Bundle/Test/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public function __construct(HttpFoundationResponse $httpFoundationResponse, Brow

/**
* {@inheritdoc}
*
* @return mixed
*/
public function getInfo(string $type = null)
{
Expand Down
4 changes: 3 additions & 1 deletion src/Bridge/Symfony/Identifier/Normalizer/UlidNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ final class UlidNormalizer implements DenormalizerInterface
{
/**
* {@inheritdoc}
*
* @return mixed
*/
public function denormalize($data, $class, $format = null, array $context = [])
{
Expand All @@ -37,7 +39,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public function __construct(PropertyNameCollectionFactoryInterface $propertyName

/**
* {@inheritdoc}
*
* @return object
*/
public function getItemFromIri(string $iri, array $context = [])
{
Expand Down
Loading