Skip to content

Commit 3be32c1

Browse files
bendaviesdunglas
authored andcommitted
suggest correct !php/const format for symfony 3.4 and above (#2336)
* suggest correct !php/const format for symfony 3.4 and above * fix some const references
1 parent a21e504 commit 3be32c1

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ private function addExceptionToStatusSection(ArrayNodeDefinition $rootNode)
267267
}
268268

269269
if (\defined($httpStatusCodeConstant = sprintf('%s::%s', Response::class, $httpStatusCode))) {
270-
@trigger_error(sprintf('Using a string "%s" as a constant of the "%s" 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:%s").', $httpStatusCode, Response::class, $httpStatusCodeConstant), E_USER_DEPRECATED);
270+
@trigger_error(sprintf('Using a string "%s" as a constant of the "%s" 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 %s").', $httpStatusCode, Response::class, $httpStatusCodeConstant), E_USER_DEPRECATED);
271271

272272
$httpStatusCode = \constant($httpStatusCodeConstant);
273273
}

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

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

150150
/**
151151
* @group legacy
152-
* @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").
152+
* @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").
153153
*/
154154
public function testLegacyExceptionToStatusConfig()
155155
{

tests/Fixtures/FileConfigurations/resources.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ resources:
2626
groups: ['default']
2727
hydra_context:
2828
'@type': 'hydra:Operation'
29-
'@hydra:title': 'File config Dummy'
30-
# Use this syntax with Symfony YAML 3.4+:
31-
#'@hydra:title': !php/const ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy::HYDRA_TITLE
29+
'@hydra:title': !php/const ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy::HYDRA_TITLE
3230
iri: 'someirischema'
3331
properties:
3432
'foo':

tests/Fixtures/app/config/config_test.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,9 @@ api_platform:
5353
client_partial: true
5454
items_per_page: 3
5555
exception_to_status:
56-
Symfony\Component\Serializer\Exception\ExceptionInterface: 400
57-
ApiPlatform\Core\Exception\InvalidArgumentException: 400
58-
ApiPlatform\Core\Exception\FilterValidationException: 400
59-
# Use this syntax with Symfony YAML 3.4+:
60-
#ApiPlatform\Core\Exception\InvalidArgumentException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST
56+
Symfony\Component\Serializer\Exception\ExceptionInterface: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST
57+
ApiPlatform\Core\Exception\InvalidArgumentException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST
58+
ApiPlatform\Core\Exception\FilterValidationException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST
6159
http_cache:
6260
invalidation:
6361
enabled: true

0 commit comments

Comments
 (0)