Skip to content

Commit 8d0bd66

Browse files
authored
Merge pull request #2925 from teohhanhui/fix/symfony-messenger-4.3-compatibility
Fix compatibility with Symfony 4.3
2 parents b448e74 + b694ef8 commit 8d0bd66

File tree

15 files changed

+45
-37
lines changed

15 files changed

+45
-37
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ jobs:
209209
- *validate-openapi-v3-yaml
210210

211211
- php: '7.3'
212-
env: SYMFONY_DEPRECATIONS_HELPER=0
212+
env: SYMFONY_DEPRECATIONS_HELPER=max[total]=5 # 5 deprecation notices from FOSUserBundle
213213
before_install:
214214
- *install-mongodb-php-extension
215215
- *disable-xdebug-php-extension
@@ -229,5 +229,5 @@ jobs:
229229
- *validate-openapi-v3-yaml
230230

231231
allow_failures:
232-
- env: SYMFONY_DEPRECATIONS_HELPER=0
232+
- env: SYMFONY_DEPRECATIONS_HELPER=max[total]=5 # 5 deprecation notices from FOSUserBundle
233233
fast_finish: true

composer.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"guzzlehttp/guzzle": "^6.0",
4545
"jangregor/phpstan-prophecy": "^0.3",
4646
"justinrainbow/json-schema": "^5.0",
47-
"nelmio/api-doc-bundle": "^2.13.3",
47+
"nelmio/api-doc-bundle": "^2.13.4",
4848
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0",
4949
"phpdocumentor/type-resolver": "^0.3 || ^0.4",
5050
"phpspec/prophecy": "^1.8",
@@ -74,7 +74,7 @@
7474
"symfony/framework-bundle": "^4.2",
7575
"symfony/mercure-bundle": "*",
7676
"symfony/messenger": "^4.2",
77-
"symfony/phpunit-bridge": "^4.3",
77+
"symfony/phpunit-bridge": "^4.3.1",
7878
"symfony/routing": "^3.4 || ^4.0",
7979
"symfony/security-bundle": "^3.4 || ^4.0",
8080
"symfony/security-core": "^3.4 || ^4.0",
@@ -86,8 +86,7 @@
8686
},
8787
"conflict": {
8888
"doctrine/common": "<2.7",
89-
"doctrine/mongodb-odm": "<2.0",
90-
"symfony/messenger": ">=4.3"
89+
"doctrine/mongodb-odm": "<2.0"
9190
},
9291
"suggest": {
9392
"doctrine/mongodb-odm-bundle": "To support MongoDB. Only versions 4.0 and later are supported.",

features/bootstrap/HydraContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ private function getPropertyInfo(string $propertyName, string $className): stdCl
230230
}
231231
}
232232

233-
throw new \InvalidArgumentException(sprintf('Property "%s" of class "%s" does\'nt exist', $propertyName, $className));
233+
throw new \InvalidArgumentException(sprintf('Property "%s" of class "%s" doesn\'t exist', $propertyName, $className));
234234
}
235235

236236
/**

features/graphql/mutation.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Feature: GraphQL mutation support
324324
When I send the following GraphQL request:
325325
"""
326326
mutation {
327-
createDummy(input: {_id: 12, name: "", foo: [], clientMutationId: "myId"}) {
327+
createDummy(input: {name: "", foo: [], clientMutationId: "myId"}) {
328328
clientMutationId
329329
}
330330
}

features/hydra/docs.feature

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ Feature: Documentation support
5656
And the value of the node "hydra:title" of the Hydra class "Dummy" is "Dummy"
5757
And the value of the node "hydra:description" of the Hydra class "Dummy" is "Dummy."
5858
# Properties
59-
And "id" property is readable for Hydra class "Dummy"
60-
And "id" property is writable for Hydra class "Dummy"
6159
And "name" property is readable for Hydra class "Dummy"
6260
And "name" property is writable for Hydra class "Dummy"
6361
And "name" property is required for Hydra class "Dummy"

features/jsonld/context.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ Feature: JSON-LD contexts generation
4141
"jsonData": "Dummy/jsonData",
4242
"arrayData": "Dummy/arrayData",
4343
"nameConverted": "Dummy/nameConverted",
44-
"id": "Dummy/id",
4544
"name": "http://schema.org/name",
4645
"alias": "https://schema.org/alternateName",
4746
"foo": "Dummy/foo"

phpstan.neon.dist

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@ parameters:
3232
path: %currentWorkingDirectory%/src/GraphQl/Resolver/FieldsToAttributesTrait.php
3333
- '#Access to an undefined property Prophecy\\Prophecy\\ObjectProphecy<(\\?[a-zA-Z0-9_]+)+>::\$[a-zA-Z0-9_]+#'
3434
- '#Call to an undefined method Doctrine\\Common\\Persistence\\ObjectManager::getConnection\(\)#'
35-
# https://github.com/symfony/symfony/pull/31903
36-
-
37-
message: '#Access to an undefined property object::\$headers\.#'
38-
path: %currentWorkingDirectory%/tests/Bridge/Symfony/Bundle/Twig/ApiPlatformProfilerPanelTest.php
39-
-
40-
message: '#Call to an undefined method object::getStatusCode\(\)\.#'
41-
path: %currentWorkingDirectory%/tests/Bridge/Symfony/Bundle/Twig/ApiPlatformProfilerPanelTest.php
4235
- '#Parameter \#1 \$function of function call_user_func expects callable\(\): mixed, .+ given\.#'
4336
- '#Parameter \#1 \$exception of static method Symfony\\Component\\Debug\\Exception\\FlattenException::create\(\) expects Exception, Symfony\\Component\\Serializer\\Exception\\ExceptionInterface given\.#'
4437
- '#Parameter \#1 \$classes of class ApiPlatform\\Core\\Metadata\\Resource\\ResourceNameCollection constructor expects array<string>, array<int, int\|string> given\.#'
@@ -75,8 +68,9 @@ parameters:
7568
-
7669
message: '#Method ApiPlatform\\Core\\Bridge\\Doctrine\\Orm\\Util\\QueryBuilderHelper::mapJoinAliases() should return array<string, array<string>\|string> but returns array<int|string, mixed>\.#'
7770
path: %currentWorkingDirectory%/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php
71+
# https://github.com/phpstan/phpstan/issues/1482
7872
-
79-
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and '(removeBindings|addRemovedBindingIds)' will always evaluate to false\\.#"
73+
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and 'removeBindings' will always evaluate to false\\.#"
8074
path: %currentWorkingDirectory%/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php
8175
-
8276
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and 'getReachableRoleNam.+' will always evaluate to false\\.#"
@@ -85,7 +79,7 @@ parameters:
8579
message: "#Call to function method_exists\\(\\) with 'Symfony\\\\\\\\Component.+' and 'getRoleNames' will always evaluate to false\\.#"
8680
path: %currentWorkingDirectory%/tests/Security/EventListener/DenyAccessListenerTest.php
8781
- "#Call to method PHPUnit\\\\Framework\\\\Assert::assertSame\\(\\) with array\\('(collection_context|item_context|subresource_context)'\\) and array<Symfony\\\\Component\\\\VarDumper\\\\Cloner\\\\Data>\\|bool\\|float\\|int\\|string\\|null will always evaluate to false\\.#"
88-
# https://github.com/doctrine/doctrine2/pull/7298/files
82+
# https://github.com/doctrine/doctrine2/pull/7298
8983
- '#Strict comparison using === between null and int will always evaluate to false\.#'
9084
-
9185
message: '#Binary operation "\+" between (float\|int\|)?string and 0 results in an error\.#'

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@
3636
use Symfony\Component\Config\Resource\DirectoryResource;
3737
use Symfony\Component\DependencyInjection\ChildDefinition;
3838
use Symfony\Component\DependencyInjection\ContainerBuilder;
39+
use Symfony\Component\DependencyInjection\ContainerInterface;
3940
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
4041
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
4142
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
4243
use Symfony\Component\DependencyInjection\Reference;
4344
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
4445
use Symfony\Component\Finder\Finder;
4546
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
47+
use Symfony\Component\Messenger\Exception\UnrecoverableMessageHandlingException;
48+
use Symfony\Component\Messenger\MessageBusInterface;
4649
use Symfony\Component\Validator\Validator\ValidatorInterface;
4750
use Symfony\Component\Yaml\Yaml;
4851

@@ -521,6 +524,11 @@ private function registerMercureConfiguration(ContainerBuilder $container, array
521524

522525
if ($this->isConfigEnabled($container, $config['doctrine'])) {
523526
$loader->load('doctrine_orm_mercure_publisher.xml');
527+
528+
// BC for Symfony Messenger 4.2
529+
if (interface_exists(MessageBusInterface::class) && !class_exists(UnrecoverableMessageHandlingException::class)) {
530+
$container->getDefinition('api_platform.doctrine.listener.mercure.publish')->replaceArgument(5, new Reference('message_bus', ContainerInterface::IGNORE_ON_INVALID_REFERENCE));
531+
}
524532
}
525533
}
526534

@@ -531,6 +539,11 @@ private function registerMessengerConfiguration(ContainerBuilder $container, arr
531539
}
532540

533541
$loader->load('messenger.xml');
542+
543+
// BC for Symfony Messenger 4.2
544+
if (interface_exists(MessageBusInterface::class) && !class_exists(UnrecoverableMessageHandlingException::class)) {
545+
$container->setAlias('api_platform.message_bus', 'message_bus');
546+
}
534547
}
535548

536549
private function registerElasticsearchConfiguration(ContainerBuilder $container, array $config, XmlFileLoader $loader): void

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
1515
<argument type="service" id="api_platform.serializer" />
1616
<argument>%api_platform.formats%</argument>
17-
<argument type="service" id="message_bus" on-invalid="ignore" />
17+
<argument type="service" id="messenger.default_bus" on-invalid="ignore" />
1818
<argument type="service" id="mercure.hub.default.publisher" />
1919

2020
<tag name="doctrine.event_listener" event="onFlush" />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

77
<services>
8-
<service id="api_platform.message_bus" alias="message_bus" />
8+
<service id="api_platform.message_bus" alias="messenger.default_bus" />
99

1010
<service id="api_platform.messenger.data_persister" class="ApiPlatform\Core\Bridge\Symfony\Messenger\DataPersister" public="false">
1111
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />

0 commit comments

Comments
 (0)