Skip to content

Commit fd8c3f2

Browse files
committed
Merge branch '2.4' into merge-2.4
2 parents df92b77 + 5207379 commit fd8c3f2

File tree

50 files changed

+203
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+203
-106
lines changed

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ jobs:
224224
working_directory: ~/api-platform/core
225225
steps:
226226
- checkout
227-
- install-mongodb-php-extension
228227
- disable-xdebug-php-extension
229228
- disable-php-memory-limit
230229
- update-composer

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ indent_size = 2
5050
[.gitmodules]
5151
indent_style = tab
5252

53-
[.php_cs]
53+
[.php_cs{,.dist}]
5454
indent_style = space
5555
indent_size = 4
5656

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"phpdocumentor/type-resolver": "^0.3 || ^0.4",
5050
"phpspec/prophecy": "^1.8",
5151
"phpstan/extension-installer": "^1.0",
52-
"phpstan/phpstan": "^0.11",
52+
"phpstan/phpstan": "^0.11.10",
5353
"phpstan/phpstan-doctrine": "^0.11",
5454
"phpstan/phpstan-phpunit": "^0.11",
5555
"phpstan/phpstan-symfony": "^0.11",
@@ -83,7 +83,7 @@
8383
"symfony/validator": "^3.4 || ^4.0",
8484
"symfony/web-profiler-bundle": "^4.2",
8585
"symfony/yaml": "^3.4 || ^4.0",
86-
"webonyx/graphql-php": ">=0.13 <1.0"
86+
"webonyx/graphql-php": ">=0.13.1 <1.0"
8787
},
8888
"conflict": {
8989
"doctrine/common": "<2.7",

phpstan.neon.dist

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ parameters:
77
- src
88
- tests
99
- tests/Fixtures/app/console
10+
inferPrivatePropertyTypeFromConstructor: true
1011
symfony:
1112
container_xml_path: %rootDir%/../../../tests/Fixtures/app/var/cache/test/appAppKernelTestDebugContainer.xml
1213
constant_hassers: false
@@ -35,6 +36,14 @@ parameters:
3536
path: %currentWorkingDirectory%/src/GraphQl/Resolver/FieldsToAttributesTrait.php
3637
- '#Access to an undefined property Prophecy\\Prophecy\\ObjectProphecy<(\\?[a-zA-Z0-9_]+)+>::\$[a-zA-Z0-9_]+#'
3738
- '#Call to an undefined method Doctrine\\Common\\Persistence\\ObjectManager::getConnection\(\)#'
39+
# https://github.com/willdurand/Negotiation/issues/89#issuecomment-513283286
40+
-
41+
message: '#Call to an undefined method Negotiation\\AcceptHeader::getType\(\)\.#'
42+
path: %currentWorkingDirectory%/src/EventListener/AddFormatListener.php
43+
# https://github.com/symfony/symfony/issues/31814#issuecomment-498749590
44+
-
45+
message: '#Call to an undefined method Symfony\\Component\\Security\\Core\\Role\\RoleHierarchyInterface::getReachableRoles\(\)\.#'
46+
path: %currentWorkingDirectory%/src/Security/ResourceAccessChecker.php
3847
- '#Parameter \#1 \$function of function call_user_func expects callable\(\): mixed, .+ given\.#'
3948
- '#Parameter \#1 \$exception of static method Symfony\\Component\\Debug\\Exception\\FlattenException::create\(\) expects Exception, Symfony\\Component\\Serializer\\Exception\\ExceptionInterface given\.#'
4049
- '#Parameter \#1 \$classes of class ApiPlatform\\Core\\Metadata\\Resource\\ResourceNameCollection constructor expects array<string>, array<int, int\|string> given\.#'
@@ -52,14 +61,8 @@ parameters:
5261
message: '#Parameter \#1 \$collection of method ApiPlatform\\Core\\Tests\\GraphQl\\Resolver\\Factory\\CollectionResolverFactoryTest::createCollectionResolverFactory\(\) expects array\|Iterator, object given\.#'
5362
path: %currentWorkingDirectory%/tests/GraphQl/Resolver/Factory/CollectionResolverFactoryTest.php
5463
-
55-
message: '#Parameter \#1 \$resourceClass of method ApiPlatform\\Core\\Metadata\\Property\\Factory\\InheritedPropertyMetadataFactory::create\(\) expects string, object\|string given\.#'
56-
path: %currentWorkingDirectory%/src/Metadata/Property/Factory/InheritedPropertyMetadataFactory.php
57-
-
58-
message: '#Parameter \#1 \$childInherited of method ApiPlatform\\Core\\Metadata\\Property\\PropertyMetadata::withChildInherited\(\) expects string, object\|string given\.#'
59-
path: %currentWorkingDirectory%/src/Metadata/Property/Factory/InheritedPropertyMetadataFactory.php
60-
-
61-
message: '#Parameter \#1 \$resourceClass of method ApiPlatform\\Core\\Metadata\\Property\\Factory\\InheritedPropertyNameCollectionFactory::create\(\) expects string, object\|string given\.#'
62-
path: %currentWorkingDirectory%/src/Metadata/Property/Factory/InheritedPropertyNameCollectionFactory.php
64+
message: '#Parameter \#1 \$docblock of method phpDocumentor\\Reflection\\DocBlockFactoryInterface::create\(\) expects string, ReflectionClass given\.#'
65+
path: %currentWorkingDirectory%/src/Metadata/Resource/Factory/PhpDocResourceMetadataFactory.php
6366
-
6467
message: '#Property ApiPlatform\\Core\\Test\\DoctrineMongoDbOdmFilterTestCase::\$repository \(Doctrine\\ODM\\MongoDB\\Repository\\DocumentRepository\) does not accept Doctrine\\ORM\\EntityRepository<ApiPlatform\\Core\\Tests\\Fixtures\\TestBundle\\Document\\Dummy>\.#'
6568
path: %currentWorkingDirectory%/src/Test/DoctrineMongoDbOdmFilterTestCase.php
@@ -86,13 +89,20 @@ parameters:
8689
path: %currentWorkingDirectory%/src/Bridge/Doctrine/Common/Filter/RangeFilterTrait.php
8790
- '#Parameter \#1 \$objectValue of method GraphQL\\Type\\Definition\\InterfaceType::resolveType\(\) expects object, array(<string, string>)? given.#'
8891

89-
# Expected, due to deprecations
92+
# Expected, due to optional interfaces
93+
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Extension\\QueryCollectionExtensionInterface::applyToCollection\(\) invoked with 5 parameters, 3-4 required\.#'
9094
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Extension\\QueryResult(Item|Collection)ExtensionInterface::getResult\(\) invoked with 4 parameters, 1 required\.#'
9195
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Extension\\QueryResult(Item|Collection)ExtensionInterface::supportsResult\(\) invoked with 3 parameters, 1-2 required\.#'
92-
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\AbstractFilter::apply\(\) invoked with 5 parameters, 3-4 required\.#'
93-
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\AbstractFilter::filterProperty\(\) invoked with 7 parameters, 5-6 required\.#'
94-
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\FilterInterface::apply\(\) invoked with 5 parameters, 3-4 required\.#'
95-
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\(Exists|Order)Filter::filterProperty\(\) invoked with 7 parameters, 5-6 required\.#'
96+
- '#Method ApiPlatform\\Core\\Bridge\\Symfony\\Routing\\RouteNameResolverInterface::getRouteName\(\) invoked with 3 parameters, 2 required\.#'
97+
- '#Method ApiPlatform\\Core\\DataPersister\\DataPersisterInterface::persist\(\) invoked with 2 parameters, 1 required\.#'
98+
- '#Method ApiPlatform\\Core\\DataPersister\\DataPersisterInterface::remove\(\) invoked with 2 parameters, 1 required\.#'
99+
- '#Method ApiPlatform\\Core\\DataPersister\\DataPersisterInterface::supports\(\) invoked with 2 parameters, 1 required\.#'
96100
- '#Method ApiPlatform\\Core\\DataProvider\\CollectionDataProviderInterface::getCollection\(\) invoked with 3 parameters, 1-2 required\.#'
97-
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::normalize\(\) invoked with 3 parameters, 1 required\.#'
98-
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::normalize\(\) invoked with 4 parameters, 1 required\.#'
101+
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::denormalize\(\) invoked with (2|3|4) parameters, 1 required\.#'
102+
- '#Method Symfony\\Component\\Serializer\\NameConverter\\NameConverterInterface::normalize\(\) invoked with (2|3|4) parameters, 1 required\.#'
103+
- '#Method Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface::supportsNormalization\(\) invoked with 3 parameters, 1-2 required\.#'
104+
105+
# Expected, due to deprecations
106+
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\(Abstract|Exists|Order)Filter::filterProperty\(\) invoked with 7 parameters, 5-6 required\.#'
107+
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\(AbstractFilter|FilterInterface)::apply\(\) invoked with 5 parameters, 3-4 required\.#'
108+
- '#Method ApiPlatform\\Core\\PathResolver\\OperationPathResolverInterface::resolveOperationPath\(\) invoked with 4 parameters, 3 required\.#'

src/Api/FormatMatcher.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@
2020
*/
2121
final class FormatMatcher
2222
{
23+
/**
24+
* @var array<string, string[]>
25+
*/
2326
private $formats;
2427

28+
/**
29+
* @param array<string, string[]|string> $formats
30+
*/
2531
public function __construct(array $formats)
2632
{
2733
$normalizedFormats = [];

src/Bridge/Doctrine/EventListener/PublishMercureUpdatesListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ final class PublishMercureUpdatesListener
4848
private $deletedEntities;
4949
private $formats;
5050

51+
/**
52+
* @param array<string, string[]|string> $formats
53+
*/
5154
public function __construct(ResourceClassResolverInterface $resourceClassResolver, IriConverterInterface $iriConverter, ResourceMetadataFactoryInterface $resourceMetadataFactory, SerializerInterface $serializer, array $formats, MessageBusInterface $messageBus = null, callable $publisher = null, ExpressionLanguage $expressionLanguage = null)
5255
{
5356
if (null === $messageBus && null === $publisher) {
@@ -166,6 +169,7 @@ private function publishUpdate($entity, array $targets): void
166169
// This may change in the feature, because it's not JSON Merge Patch compliant,
167170
// and I'm not a fond of this approach
168171
$iri = $entity->iri;
172+
/** @var string $data */
169173
$data = json_encode(['@id' => $entity->id]);
170174
} else {
171175
$resourceClass = $this->getObjectClass($entity);

src/Bridge/Doctrine/MongoDbOdm/PropertyInfo/DoctrineExtractor.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
namespace ApiPlatform\Core\Bridge\Doctrine\MongoDbOdm\PropertyInfo;
1515

1616
use Doctrine\Common\Collections\Collection;
17+
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
1718
use Doctrine\Common\Persistence\Mapping\MappingException;
1819
use Doctrine\Common\Persistence\ObjectManager;
19-
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
20+
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata as MongoDbClassMetadata;
2021
use Doctrine\ODM\MongoDB\Types\Type as MongoDbType;
2122
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
2223
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
@@ -61,17 +62,11 @@ public function getTypes($class, $property, array $context = [])
6162
return null;
6263
}
6364

64-
$reflectionMetadata = new \ReflectionClass($metadata);
65-
6665
if ($metadata->hasAssociation($property)) {
6766
$class = $metadata->getAssociationTargetClass($property);
6867

6968
if ($metadata->isSingleValuedAssociation($property)) {
70-
if ($reflectionMetadata->hasMethod('isNullable')) {
71-
$nullable = $metadata->isNullable($property);
72-
} else {
73-
$nullable = false;
74-
}
69+
$nullable = $metadata instanceof MongoDbClassMetadata && $metadata->isNullable($property);
7570

7671
return [new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $class)];
7772
}
@@ -92,7 +87,7 @@ public function getTypes($class, $property, array $context = [])
9287

9388
if ($metadata->hasField($property)) {
9489
$typeOfField = $metadata->getTypeOfField($property);
95-
$nullable = $reflectionMetadata->hasMethod('isNullable') && $metadata->isNullable($property);
90+
$nullable = $metadata instanceof MongoDbClassMetadata && $metadata->isNullable($property);
9691

9792
switch ($typeOfField) {
9893
case MongoDbType::DATE:
@@ -124,7 +119,7 @@ public function isWritable($class, $property, array $context = []): ?bool
124119
{
125120
if (
126121
null === ($metadata = $this->getMetadata($class))
127-
|| ClassMetadata::GENERATOR_TYPE_NONE === $metadata->generatorType
122+
|| $metadata instanceof MongoDbClassMetadata && MongoDbClassMetadata::GENERATOR_TYPE_NONE === $metadata->generatorType
128123
|| !\in_array($property, $metadata->getIdentifierFieldNames(), true)
129124
) {
130125
return null;

src/Bridge/Doctrine/Orm/CollectionDataProvider.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
namespace ApiPlatform\Core\Bridge\Doctrine\Orm;
1515

16-
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\ContextAwareQueryCollectionExtensionInterface;
1716
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryCollectionExtensionInterface;
1817
use ApiPlatform\Core\Bridge\Doctrine\Orm\Extension\QueryResultCollectionExtensionInterface;
1918
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGenerator;
@@ -36,9 +35,9 @@ class CollectionDataProvider implements ContextAwareCollectionDataProviderInterf
3635
private $collectionExtensions;
3736

3837
/**
39-
* @param QueryCollectionExtensionInterface[]|ContextAwareQueryCollectionExtensionInterface[] $collectionExtensions
38+
* @param QueryCollectionExtensionInterface[] $collectionExtensions
4039
*/
41-
public function __construct(ManagerRegistry $managerRegistry, /* iterable */ $collectionExtensions = [])
40+
public function __construct(ManagerRegistry $managerRegistry, iterable $collectionExtensions = [])
4241
{
4342
$this->managerRegistry = $managerRegistry;
4443
$this->collectionExtensions = $collectionExtensions;

src/Bridge/Doctrine/Orm/Extension/PaginationExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ final class PaginationExtension implements ContextAwareQueryResultCollectionExte
3838
{
3939
private $managerRegistry;
4040
private $requestStack;
41+
/**
42+
* @var ResourceMetadataFactoryInterface
43+
*/
4144
private $resourceMetadataFactory;
4245
private $enabled;
4346
private $clientEnabled;
@@ -50,6 +53,9 @@ final class PaginationExtension implements ContextAwareQueryResultCollectionExte
5053
private $partial;
5154
private $clientPartial;
5255
private $partialParameterName;
56+
/**
57+
* @var Pagination|null
58+
*/
5359
private $pagination;
5460

5561
/**

src/Bridge/Doctrine/Orm/Extension/QueryResultCollectionExtensionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface QueryResultCollectionExtensionInterface extends QueryCollectionExtensi
2727
public function supportsResult(string $resourceClass, string $operationName = null): bool;
2828

2929
/**
30-
* @return array|\Traversable
30+
* @return iterable
3131
*/
3232
public function getResult(QueryBuilder $queryBuilder);
3333
}

0 commit comments

Comments
 (0)