Skip to content

Commit 72ac53a

Browse files
committed
Merge branch '2.1'
2 parents 084be5b + cdaeec5 commit 72ac53a

19 files changed

+68
-76
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
* Add support for API key authentication in Swagger UI
3232
* Allow to specify a whitelist of serialization groups
3333
* Allow to use the new immutable date and time types of Doctrine in filters
34+
* Update swagger definition keys to more verbose ones (ie `Resource-md5($groups)` => `Resource-groupa_groupb`) - see https://github.com/api-platform/core/pull/1207
3435

3536
## 2.0.11
3637

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"symfony/finder": "^3.3 || ^4.0",
5757
"symfony/form": "^3.3 || ^4.0",
5858
"symfony/framework-bundle": "^3.3 || ^4.0",
59-
"symfony/phpunit-bridge": "^2.7 || ^3.0 || ^4.0",
59+
"symfony/phpunit-bridge": "^3.3 || ^4.0",
6060
"symfony/routing": "^3.3 || ^4.0",
6161
"symfony/security": "^3.0 || ^4.0",
6262
"symfony/security-bundle": "^3.0 || ^4.0",

phpunit.xml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
colors="true"
99
>
1010
<php>
11+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors" />
1112
<ini name="error_reporting" value="-1" />
1213
<ini name="memory_limit" value="-1" />
1314
<server name="KERNEL_DIR" value="tests/Fixtures/app/" />
@@ -29,4 +30,8 @@
2930
</exclude>
3031
</whitelist>
3132
</filter>
33+
34+
<listeners>
35+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
36+
</listeners>
3237
</phpunit>

src/Api/OperationTypeDeprecationHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ final class OperationTypeDeprecationHelper
3636
public static function getOperationType($operationType): string
3737
{
3838
if (is_bool($operationType)) {
39-
@trigger_error('Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3', E_USER_DEPRECATED);
39+
@trigger_error('Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3', E_USER_DEPRECATED);
4040

4141
$operationType = $operationType === true ? OperationType::COLLECTION : OperationType::ITEM;
4242
}

src/Bridge/Symfony/Bundle/Resources/config/api.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@
102102
</service>
103103

104104
<service id="api_platform.operation_path_resolver.underscore" class="ApiPlatform\Core\PathResolver\UnderscoreOperationPathResolver" public="false">
105-
<deprecated>The "%service_id%" service is deprecated since ApiPlatform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.underscore" instead.</deprecated>
105+
<deprecated>The "%service_id%" service is deprecated since API Platform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.underscore" instead.</deprecated>
106106
</service>
107107

108108
<service id="api_platform.operation_path_resolver.dash" class="ApiPlatform\Core\PathResolver\DashOperationPathResolver" public="false">
109-
<deprecated>The "%service_id%" service is deprecated since ApiPlatform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.dash" instead.</deprecated>
109+
<deprecated>The "%service_id%" service is deprecated since API Platform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.dash" instead.</deprecated>
110110
</service>
111111

112112
<!-- Path name generator -->

src/Metadata/Extractor/XmlExtractor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private function getOperations(\SimpleXMLElement $resource, string $operationTyp
6565
{
6666
if ($legacyOperations = $this->getAttributes($resource, $operationType)) {
6767
@trigger_error(
68-
sprintf('Configuring "%1$s" tags without using a parent "%1$ss" tag is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3', $operationType),
68+
sprintf('Configuring "%1$s" tags without using a parent "%1$ss" tag is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3', $operationType),
6969
E_USER_DEPRECATED
7070
);
7171

src/PathResolver/DashOperationPathResolver.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,21 @@
1919
* Generates a path with words separated by underscores.
2020
*
2121
* @author Paul Le Corre <[email protected]>
22+
*
23+
* @deprecated since version 2.1, to be removed in 3.0. Use {@see \ApiPlatform\Core\Operation\DashPathSegmentNameGenerator} instead.
2224
*/
2325
final class DashOperationPathResolver implements OperationPathResolverInterface
2426
{
27+
public function __construct()
28+
{
29+
@trigger_error(sprintf('The use of %s is deprecated since 2.1. Please use %s instead.', __CLASS__, DashPathSegmentNameGenerator::class), E_USER_DEPRECATED);
30+
}
31+
2532
/**
2633
* {@inheritdoc}
2734
*/
2835
public function resolveOperationPath(string $resourceShortName, array $operation, $operationType/*, string $operationName = null*/): string
2936
{
30-
@trigger_error(sprintf('The use of %s is deprecated since 2.1. Please use PathSegmentNameGenerator instead.', __CLASS__), E_USER_DEPRECATED);
31-
3237
if (func_num_args() >= 4) {
3338
$operationName = func_get_arg(3);
3439
} else {

src/PathResolver/UnderscoreOperationPathResolver.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,21 @@
1919
* Generates a path with words separated by underscores.
2020
*
2121
* @author Paul Le Corre <[email protected]>
22+
*
23+
* @deprecated since version 2.1, to be removed in 3.0. Use {@see \ApiPlatform\Core\Operation\UnderscorePathSegmentNameGenerator} instead.
2224
*/
2325
final class UnderscoreOperationPathResolver implements OperationPathResolverInterface
2426
{
27+
public function __construct()
28+
{
29+
@trigger_error(sprintf('The use of %s is deprecated since 2.1. Please use %s instead.', __CLASS__, UnderscorePathSegmentNameGenerator::class), E_USER_DEPRECATED);
30+
}
31+
2532
/**
2633
* {@inheritdoc}
2734
*/
2835
public function resolveOperationPath(string $resourceShortName, array $operation, $operationType/*, string $operationName = null*/): string
2936
{
30-
@trigger_error(sprintf('The use of %s is deprecated since 2.1. Please use PathSegmentNameGenerator instead.', __CLASS__), E_USER_DEPRECATED);
31-
3237
if (func_num_args() >= 4) {
3338
$operationName = func_get_arg(3);
3439
} else {

src/Serializer/AbstractItemNormalizer.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ protected function getFactoryOptions(array $context): array
357357
* @param array $context
358358
*
359359
* @return array
360+
*
361+
* @deprecated since version 2.1, to be removed in 3.0.
360362
*/
361363
protected function createRelationSerializationContext(string $resourceClass, array $context): array
362364
{

tests/Bridge/Symfony/Bundle/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function testDefaultConfig()
123123

124124
/**
125125
* @group legacy
126-
* @expectedDeprecation Using a string "HTTP_INTERNAL_SERVER_ERROR" as a constant of the "Symfony\Component\HttpFoundation\Response" class is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3. Use the Symfony's custom YAML extension for PHP constants instead (i.e. "!php/const:Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST").
126+
* @expectedDeprecation Using a string "HTTP_INTERNAL_SERVER_ERROR" as a constant of the "Symfony\Component\HttpFoundation\Response" class is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3. Use the Symfony's custom YAML extension for PHP constants instead (i.e. "!php/const:Symfony\Component\HttpFoundation\Response::HTTP_INTERNAL_SERVER_ERROR").
127127
*/
128128
public function testLegacyExceptionToStatusConfig()
129129
{

tests/Bridge/Symfony/Routing/CachedRouteNameResolverTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ public function testGetRouteNameForItemRouteWithNoMatchingRoute()
5959
$cachedRouteNameResolver->getRouteName('AppBundle\Entity\User', OperationType::ITEM);
6060
}
6161

62-
/**
63-
* @group legacy
64-
* @expectedDeprecation Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
65-
*/
6662
public function testGetRouteNameForItemRouteOnCacheMiss()
6763
{
6864
$cacheItemProphecy = $this->prophesize(CacheItemInterface::class);
@@ -123,10 +119,6 @@ public function testGetRouteNameForCollectionRouteWithNoMatchingRoute()
123119
$cachedRouteNameResolver->getRouteName('AppBundle\Entity\User', OperationType::COLLECTION);
124120
}
125121

126-
/**
127-
* @group legacy
128-
* @expectedDeprecation Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
129-
*/
130122
public function testGetRouteNameForCollectionRouteOnCacheMiss()
131123
{
132124
$cacheItemProphecy = $this->prophesize(CacheItemInterface::class);

tests/Bridge/Symfony/Routing/RouteNameGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testGenerate()
2929

3030
/**
3131
* @group legacy
32-
* @expectedDeprecation Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
32+
* @expectedDeprecation Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3
3333
*/
3434
public function testLegacyGenerate()
3535
{

tests/Bridge/Symfony/Routing/RouteNameResolverTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testGetRouteNameForItemRouteWithNoMatchingRoute()
5555

5656
/**
5757
* @group legacy
58-
* @expectedDeprecation Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
58+
* @expectedDeprecation Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3
5959
*/
6060
public function testGetRouteNameForItemRouteLegacy()
6161
{
@@ -120,7 +120,7 @@ public function testGetRouteNameForCollectionRouteWithNoMatchingRoute()
120120

121121
/**
122122
* @group legacy
123-
* @expectedDeprecation Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
123+
* @expectedDeprecation Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3
124124
*/
125125
public function testGetRouteNameForCollectionRouteLegacy()
126126
{

tests/Bridge/Symfony/Routing/RouterOperationPathResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function testResolveOperationPathWithRouteNotFound()
8282
/**
8383
* @group legacy
8484
* @expectedDeprecation Method ApiPlatform\Core\Bridge\Symfony\Routing\RouterOperationPathResolver::resolveOperationPath() will have a 4th `string $operationName` argument in version 3.0. Not defining it is deprecated since 2.1.
85-
* @expectedDeprecation Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
85+
* @expectedDeprecation Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3
8686
*/
8787
public function testLegacyResolveOperationPath()
8888
{

tests/Metadata/Resource/Factory/ExtractorResourceMetadataFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testXmlOptionalResourceMetadata($expectedResourceMetadata)
7373
}
7474

7575
/**
76-
* @expectedDeprecation Configuring "%s" tags without using a parent "%ss" tag is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
76+
* @expectedDeprecation Configuring "%s" tags without using a parent "%ss" tag is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3
7777
* @group legacy
7878
* @dataProvider legacyOperationsResourceMetadataProvider
7979
*/

tests/PathResolver/CustomOperationPathResolverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testResolveOperationPathWithDeferred()
4141

4242
/**
4343
* @group legacy
44-
* @expectedDeprecation Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
44+
* @expectedDeprecation Method ApiPlatform\Core\PathResolver\CustomOperationPathResolver::resolveOperationPath() will have a 4th `string $operationName` argument in version 3.0. Not defining it is deprecated since 2.1.
4545
*/
4646
public function testLegacyResolveOperationPath()
4747
{

tests/PathResolver/DashOperationPathResolverTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@
1818

1919
/**
2020
* @author Guilhem N. <[email protected]>
21+
*
2122
* @group legacy
2223
*/
2324
class DashOperationPathResolverTest extends \PHPUnit_Framework_TestCase
2425
{
26+
/**
27+
* @expectedDeprecation The use of ApiPlatform\Core\PathResolver\DashOperationPathResolver is deprecated since 2.1. Please use ApiPlatform\Core\Operation\DashPathSegmentNameGenerator instead.
28+
*/
2529
public function testResolveCollectionOperationPath()
2630
{
2731
$dashOperationPathResolver = new DashOperationPathResolver();
2832

2933
$this->assertSame('/short-names.{_format}', $dashOperationPathResolver->resolveOperationPath('ShortName', [], OperationType::COLLECTION, 'get'));
3034
}
3135

36+
/**
37+
* @expectedDeprecation The use of ApiPlatform\Core\PathResolver\DashOperationPathResolver is deprecated since 2.1. Please use ApiPlatform\Core\Operation\DashPathSegmentNameGenerator instead.
38+
*/
3239
public function testResolveItemOperationPath()
3340
{
3441
$dashOperationPathResolver = new DashOperationPathResolver();
@@ -37,6 +44,8 @@ public function testResolveItemOperationPath()
3744
}
3845

3946
/**
47+
* @expectedDeprecation The use of ApiPlatform\Core\PathResolver\DashOperationPathResolver is deprecated since 2.1. Please use ApiPlatform\Core\Operation\DashPathSegmentNameGenerator instead.
48+
*
4049
* @expectedException \ApiPlatform\Core\Exception\InvalidArgumentException
4150
* @expectedMessage Subresource operations are not supported by the OperationPathResolver.
4251
*/
@@ -48,7 +57,8 @@ public function testResolveSubresourceOperationPath()
4857
}
4958

5059
/**
51-
* @expectedDeprecation Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
60+
* @expectedDeprecation The use of ApiPlatform\Core\PathResolver\DashOperationPathResolver is deprecated since 2.1. Please use ApiPlatform\Core\Operation\DashPathSegmentNameGenerator instead.
61+
* @expectedDeprecation Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3
5262
*/
5363
public function testLegacyResolveOperationPath()
5464
{

tests/PathResolver/UnderscoreOperationPathResolverTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@
1818

1919
/**
2020
* @author Guilhem N. <[email protected]>
21+
*
2122
* @group legacy
2223
*/
2324
class UnderscoreOperationPathResolverTest extends \PHPUnit_Framework_TestCase
2425
{
26+
/**
27+
* @expectedDeprecation The use of ApiPlatform\Core\PathResolver\UnderscoreOperationPathResolver is deprecated since 2.1. Please use ApiPlatform\Core\Operation\UnderscorePathSegmentNameGenerator instead.
28+
*/
2529
public function testResolveCollectionOperationPath()
2630
{
2731
$underscoreOperationPathResolver = new UnderscoreOperationPathResolver();
2832

2933
$this->assertSame('/short_names.{_format}', $underscoreOperationPathResolver->resolveOperationPath('ShortName', [], OperationType::COLLECTION, 'get'));
3034
}
3135

36+
/**
37+
* @expectedDeprecation The use of ApiPlatform\Core\PathResolver\UnderscoreOperationPathResolver is deprecated since 2.1. Please use ApiPlatform\Core\Operation\UnderscorePathSegmentNameGenerator instead.
38+
*/
3239
public function testResolveItemOperationPath()
3340
{
3441
$underscoreOperationPathResolver = new UnderscoreOperationPathResolver();
@@ -37,6 +44,8 @@ public function testResolveItemOperationPath()
3744
}
3845

3946
/**
47+
* @expectedDeprecation The use of ApiPlatform\Core\PathResolver\UnderscoreOperationPathResolver is deprecated since 2.1. Please use ApiPlatform\Core\Operation\UnderscorePathSegmentNameGenerator instead.
48+
*
4049
* @expectedException \ApiPlatform\Core\Exception\InvalidArgumentException
4150
* @expectedMessage Subresource operations are not supported by the OperationPathResolver.
4251
*/
@@ -48,7 +57,8 @@ public function testResolveSubresourceOperationPath()
4857
}
4958

5059
/**
51-
* @expectedDeprecation Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3
60+
* @expectedDeprecation The use of ApiPlatform\Core\PathResolver\UnderscoreOperationPathResolver is deprecated since 2.1. Please use ApiPlatform\Core\Operation\UnderscorePathSegmentNameGenerator instead.
61+
* @expectedDeprecation Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3
5262
*/
5363
public function testLegacyResolveOperationPath()
5464
{

0 commit comments

Comments
 (0)