Skip to content

Commit 30d8213

Browse files
committed
Merge branch '2.2'
2 parents c40320a + a2bb3bf commit 30d8213

Some content is hidden

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

43 files changed

+406
-194
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
- *update-project-dependencies
111111
- run:
112112
name: Install PHPStan
113-
command: composer global require phpstan/phpstan:^0.8
113+
command: composer global require phpstan/phpstan:^0.10
114114
- *save-composer-cache-by-revision
115115
- *save-composer-cache-by-branch
116116
- run:

appveyor.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ clone_folder: c:\projects\api-platform\core
55
cache:
66
- '%LOCALAPPDATA%\Composer\files'
77

8-
init:
9-
- SET PATH=c:\tools\php72;%PATH%
10-
118
environment:
129
APP_ENV: 'test'
1310

1411
install:
1512
- ps: Set-Service wuauserv -StartupType Manual
16-
- cinst -y php
13+
- cinst -y php composer
14+
- refreshenv
1715
- cd c:\tools\php72
1816
- copy php.ini-production php.ini /Y
1917
- echo date.timezone="UTC" >> php.ini
@@ -24,8 +22,7 @@ install:
2422
- echo extension=php_pdo_sqlite.dll >> php.ini
2523
- echo memory_limit=3G >> php.ini
2624
- cd %APPVEYOR_BUILD_FOLDER%
27-
- php -r "readfile('http://getcomposer.org/installer');" | php
28-
- php composer.phar install --no-interaction --no-progress
25+
- composer install --no-interaction --no-progress
2926

3027
test_script:
3128
- cd %APPVEYOR_BUILD_FOLDER%

features/main/content_negotiation.feature

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Feature: Content Negotiation support
1818
And the response should be equal to
1919
"""
2020
<?xml version="1.0"?>
21-
<response><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><id>1</id><name>XML!</name><alias/><foo/></response>
21+
<response><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></response>
2222
"""
2323

2424
Scenario: Retrieve a collection in XML
@@ -29,7 +29,7 @@ Feature: Content Negotiation support
2929
And the response should be equal to
3030
"""
3131
<?xml version="1.0"?>
32-
<response><item key="0"><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><id>1</id><name>XML!</name><alias/><foo/></item></response>
32+
<response><item key="0"><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></item></response>
3333
"""
3434

3535
Scenario: Retrieve a collection in XML using the .xml URL
@@ -39,7 +39,7 @@ Feature: Content Negotiation support
3939
And the response should be equal to
4040
"""
4141
<?xml version="1.0"?>
42-
<response><item key="0"><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><id>1</id><name>XML!</name><alias/><foo/></item></response>
42+
<response><item key="0"><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>1</id><name>XML!</name><alias/><foo/></item></response>
4343
"""
4444

4545
Scenario: Retrieve a collection in JSON
@@ -63,6 +63,8 @@ Feature: Content Negotiation support
6363
"jsonData": [],
6464
"arrayData": [],
6565
"name_converted": null,
66+
"relatedOwnedDummy": null,
67+
"relatedOwningDummy": null,
6668
"id": 1,
6769
"name": "XML!",
6870
"alias": null,
@@ -83,7 +85,7 @@ Feature: Content Negotiation support
8385
And the response should be equal to
8486
"""
8587
<?xml version="1.0"?>
86-
<response><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><id>2</id><name>Sent in JSON</name><alias/><foo/></response>
88+
<response><description/><dummy/><dummyBoolean/><dummyDate/><dummyFloat/><dummyPrice/><relatedDummy/><relatedDummies/><jsonData/><arrayData/><name_converted/><relatedOwnedDummy/><relatedOwningDummy/><id>2</id><name>Sent in JSON</name><alias/><foo/></response>
8789
"""
8890

8991
Scenario: Requesting the same format in the Accept header and in the URL should work

features/main/crud.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Feature: Create-Retrieve-Update-Delete
4444
},
4545
"arrayData": [],
4646
"name_converted": null,
47+
"relatedOwnedDummy": null,
48+
"relatedOwningDummy": null,
4749
"id": 1,
4850
"name": "My Dummy",
4951
"alias": null,
@@ -78,6 +80,8 @@ Feature: Create-Retrieve-Update-Delete
7880
},
7981
"arrayData": [],
8082
"name_converted": null,
83+
"relatedOwnedDummy": null,
84+
"relatedOwningDummy": null,
8185
"id": 1,
8286
"name": "My Dummy",
8387
"alias": null,
@@ -120,6 +124,8 @@ Feature: Create-Retrieve-Update-Delete
120124
},
121125
"arrayData": [],
122126
"name_converted": null,
127+
"relatedOwnedDummy": null,
128+
"relatedOwningDummy": null,
123129
"id": 1,
124130
"name": "My Dummy",
125131
"alias": null,
@@ -444,6 +450,8 @@ Feature: Create-Retrieve-Update-Delete
444450
],
445451
"arrayData": [],
446452
"name_converted": null,
453+
"relatedOwnedDummy": null,
454+
"relatedOwningDummy": null,
447455
"id": 1,
448456
"name": "A nice dummy",
449457
"alias": null,
@@ -481,6 +489,8 @@ Feature: Create-Retrieve-Update-Delete
481489
],
482490
"arrayData": [],
483491
"name_converted": null,
492+
"relatedOwnedDummy": null,
493+
"relatedOwningDummy": null,
484494
"id": 1,
485495
"name": "A nice dummy",
486496
"alias": null,

features/main/relation.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ Feature: Relations support
162162
"jsonData": [],
163163
"arrayData": [],
164164
"name_converted": null,
165+
"relatedOwnedDummy": null,
166+
"relatedOwningDummy": null,
165167
"id": 1,
166168
"name": "Dummy with relations",
167169
"alias": null,
@@ -544,6 +546,8 @@ Feature: Relations support
544546
"jsonData":[],
545547
"arrayData":[],
546548
"name_converted":null,
549+
"relatedOwnedDummy": null,
550+
"relatedOwningDummy": null,
547551
"id":2,
548552
"name":"Dummy with plain relations",
549553
"alias":null,

features/security/strong_typing.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Feature: Handle properly invalid data submitted to the API
3333
"jsonData": [],
3434
"arrayData": [],
3535
"name_converted": null,
36+
"relatedOwnedDummy": null,
37+
"relatedOwningDummy": null,
3638
"id": 1,
3739
"name": "Not existing",
3840
"alias": null,

features/security/unknown_attributes.feature

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Feature: Ignore unknown attributes
3333
"jsonData": [],
3434
"arrayData": [],
3535
"name_converted": null,
36+
"relatedOwnedDummy": null,
37+
"relatedOwningDummy": null,
3638
"id": 1,
3739
"name": "Not existing",
3840
"alias": null,

phpstan.neon

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,35 @@ parameters:
33
- tests/Fixtures/app/AppKernel.php
44
excludes_analyse:
55
- tests/Fixtures/app/cache
6+
# The Symfony Configuration API isn't good enough to be analysed
7+
- src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php
68
ignoreErrors:
7-
- '#Call to an undefined method Symfony\\Component\\Routing\\Exception\\ExceptionInterface::getCode\(\)#'
8-
- '#Call to an undefined method Prophecy\\Prophecy\\ObjectProphecy::[a-zA-Z0-9_]+\(\)#'
9-
- '#Access to an undefined property Prophecy\\Prophecy\\ObjectProphecy::\$[a-zA-Z0-9_]+#'
10-
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::[a-zA-Z0-9_]+\(\)#'
11-
- '#Call to an undefined method Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata::getAssociationMappings\(\)#'
9+
# Real problems, hard to fix
10+
- '#Parameter \#2 \$dqlPart of method Doctrine\\ORM\\QueryBuilder::add\(\) expects array\|object, string given\.#'
1211

1312
# False positives
13+
- '#Access to an undefined property Prophecy\\Prophecy\\ObjectProphecy::\$[a-zA-Z0-9_]+#'
14+
- '#Access to an undefined property object::\$isIdentifierComposite.#'
1415
- '#Call to an undefined method Doctrine\\Common\\Persistence\\ObjectManager::getConnection\(\)#'
15-
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Extension\\QueryResult(Item|Collection)ExtensionInterface::supportsResult\(\) invoked with 3 parameters, 1-2 required\.#'
16+
- '#Call to an undefined method PHPUnit\\Framework\\MockObject\\MockObject::[a-zA-Z0-9_]+\(\)#'
17+
- '#Call to an undefined method Prophecy\\Prophecy\\ObjectProphecy::[a-zA-Z0-9_]+\(\)#'
18+
- '#Method ApiPlatform\\Core\\Tests\\Bridge\\Doctrine\\Orm\\ItemDataProviderTest::getManagerRegistry\(\) should return Doctrine\\Common\\Persistence\\ManagerRegistry but returns object\.#'
19+
- '#Method ApiPlatform\\Core\\Tests\\Bridge\\Doctrine\\Util\\IdentifierManagerTraitTest::getObjectManager\(\) should return Doctrine\\Common\\Persistence\\ObjectManager but returns object\.#'
20+
# Temporary fix while the PHPStan extension for Prophecy isn't compatible with 0.10
21+
- '#Parameter .* expects .*, .*object.* given\.#'
22+
- '#Parameter \#[0-9] \$filterLocator of class ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Extension\\FilterExtension constructor expects ApiPlatform\\Core\\Api\\FilterCollection|Psr\\Container\\ContainerInterface(\|null)?, ArrayObject given\.#'
23+
- '#Property ApiPlatform\\Core\\Test\\DoctrineOrmFilterTestCase::\$managerRegistry \(Doctrine\\Common\\Persistence\\ManagerRegistry\) does not accept object\.#'
24+
- '#Property ApiPlatform\\Core\\Test\\DoctrineOrmFilterTestCase::\$repository \(Doctrine\\ORM\\EntityRepository\) does not accept Doctrine\\Common\\Persistence\\ObjectRepository\.#'
25+
# https://github.com/doctrine/doctrine2/pull/7298/files
26+
- '#Strict comparison using === between null and int will always evaluate to false\.#'
27+
- '#Strict comparison using !== between null and null will always evaluate to false\.#'
28+
29+
# Expected, due to deprecations
1630
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Extension\\QueryResult(Item|Collection)ExtensionInterface::getResult\(\) invoked with 4 parameters, 1 required\.#'
31+
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Extension\\QueryResult(Item|Collection)ExtensionInterface::supportsResult\(\) invoked with 3 parameters, 1-2 required\.#'
32+
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\AbstractFilter::apply\(\) invoked with 5 parameters, 3-4 required\.#'
1733
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\AbstractFilter::filterProperty\(\) invoked with 7 parameters, 5-6 required\.#'
34+
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\FilterInterface::apply\(\) invoked with 5 parameters, 3-4 required\.#'
1835
- '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Filter\\OrderFilter::filterProperty\(\) invoked with 7 parameters, 5-6 required\.#'
36+
- '#Method ApiPlatform\\Core\\DataProvider\\CollectionDataProviderInterface::getCollection\(\) invoked with 3 parameters, 1-2 required.#'
37+
- '#PHPDoc tag @param references unknown parameter \$operationName#'

src/Annotation/ApiFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ final class ApiFilter
5353

5454
public function __construct($options = [])
5555
{
56-
if (!isset($options['value'])) {
56+
if (!\is_string($options['value'] ?? null)) {
5757
throw new InvalidArgumentException('This annotation needs a value representing the filter class.');
5858
}
5959

60-
if (!is_subclass_of($options['value'], FilterInterface::class)) {
60+
if (!is_a($options['value'], FilterInterface::class, true)) {
6161
throw new InvalidArgumentException(sprintf('The filter class "%s" does not implement "%s".', $options['value'], FilterInterface::class));
6262
}
6363

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ public function applyToCollection(QueryBuilder $queryBuilder, QueryNameGenerator
6161
}
6262

6363
foreach ($resourceFilters as $filterId) {
64-
if (!($filter = $this->getFilter($filterId)) instanceof FilterInterface) {
65-
continue;
64+
$filter = $this->getFilter($filterId);
65+
if ($filter instanceof FilterInterface) {
66+
$context['filters'] = $context['filters'] ?? [];
67+
$filter->apply($queryBuilder, $queryNameGenerator, $resourceClass, $operationName, $context);
6668
}
67-
68-
$context['filters'] = $context['filters'] ?? [];
69-
70-
$filter->apply($queryBuilder, $queryNameGenerator, $resourceClass, $operationName, $context);
7169
}
7270
}
7371
}

0 commit comments

Comments
 (0)