Skip to content

Commit 6e2c268

Browse files
authored
Compatiblity with Symfony 4.3 (#2784)
* Compatiblity with Symfony 4.3 * Fix all broken unit tests * Fix some deprecations * Remove @Final from ItemNormalizer * Fix Behat tests * Use composition for the Exception Listener * Fix default firewall logout_on_user_change deprecation * Make sure that sodium is supported * Fix composer and tests * Fix PHPStan config and CS * Remove deprecated option * Fix MongoDB * Fix rebase
1 parent e18bffb commit 6e2c268

File tree

21 files changed

+128
-46
lines changed

21 files changed

+128
-46
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]=0
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]=0
233233
fast_finish: true

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"symfony/http-kernel": "^3.4 || ^4.0",
2222
"symfony/property-access": "^3.4 || ^4.0",
2323
"symfony/property-info": "^3.4 || ^4.0",
24-
"symfony/serializer": "^4.2.6",
24+
"symfony/serializer": "^4.3",
2525
"symfony/web-link": "^4.1",
2626
"willdurand/negotiation": "^2.0.3"
2727
},
@@ -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",
@@ -71,10 +71,10 @@
7171
"symfony/expression-language": "^3.4 || ^4.0",
7272
"symfony/finder": "^3.4 || ^4.0",
7373
"symfony/form": "^3.4 || ^4.0",
74-
"symfony/framework-bundle": "^4.2",
74+
"symfony/framework-bundle": "^4.3",
7575
"symfony/mercure-bundle": "*",
76-
"symfony/messenger": "^4.2",
77-
"symfony/phpunit-bridge": "^4.3",
76+
"symfony/messenger": "^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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ parameters:
3434
- '#Call to an undefined method Doctrine\\Common\\Persistence\\ObjectManager::getConnection\(\)#'
3535
# https://github.com/symfony/symfony/pull/31903
3636
-
37-
message: '#Access to an undefined property object::\$headers\.#'
37+
message: '#Access to property \$headers on an unknown class Symfony\\Component\\HttpKernel\\Response\.#'
3838
path: %currentWorkingDirectory%/tests/Bridge/Symfony/Bundle/Twig/ApiPlatformProfilerPanelTest.php
3939
-
40-
message: '#Call to an undefined method object::getStatusCode\(\)\.#'
40+
message: '#Call to method getStatusCode\(\) on an unknown class Symfony\\Component\\HttpKernel\\Response\.#'
4141
path: %currentWorkingDirectory%/tests/Bridge/Symfony/Bundle/Twig/ApiPlatformProfilerPanelTest.php
4242
- '#Parameter \#1 \$function of function call_user_func expects callable\(\): mixed, .+ given\.#'
4343
- '#Parameter \#1 \$exception of static method Symfony\\Component\\Debug\\Exception\\FlattenException::create\(\) expects Exception, Symfony\\Component\\Serializer\\Exception\\ExceptionInterface given\.#'

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

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
use Doctrine\Common\Collections\Collection;
1717
use Doctrine\Common\Persistence\Mapping\MappingException;
1818
use Doctrine\Common\Persistence\ObjectManager;
19+
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
1920
use Doctrine\ODM\MongoDB\Types\Type as MongoDbType;
21+
use Symfony\Component\PropertyInfo\PropertyAccessExtractorInterface;
2022
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
2123
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
2224
use Symfony\Component\PropertyInfo\Type;
@@ -29,7 +31,7 @@
2931
* @author Kévin Dunglas <[email protected]>
3032
* @author Alan Poulain <[email protected]>
3133
*/
32-
final class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeExtractorInterface
34+
final class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeExtractorInterface, PropertyAccessExtractorInterface
3335
{
3436
private $objectManager;
3537

@@ -43,9 +45,7 @@ public function __construct(ObjectManager $objectManager)
4345
*/
4446
public function getProperties($class, array $context = [])
4547
{
46-
try {
47-
$metadata = $this->objectManager->getClassMetadata($class);
48-
} catch (MappingException $exception) {
48+
if (null === $metadata = $this->getMetadata($class)) {
4949
return null;
5050
}
5151

@@ -57,9 +57,7 @@ public function getProperties($class, array $context = [])
5757
*/
5858
public function getTypes($class, $property, array $context = [])
5959
{
60-
try {
61-
$metadata = $this->objectManager->getClassMetadata($class);
62-
} catch (MappingException $exception) {
60+
if (null === $metadata = $this->getMetadata($class)) {
6361
return null;
6462
}
6563

@@ -111,6 +109,39 @@ public function getTypes($class, $property, array $context = [])
111109
}
112110
}
113111

112+
/**
113+
* {@inheritdoc}
114+
*/
115+
public function isReadable($class, $property, array $context = []): ?bool
116+
{
117+
return null;
118+
}
119+
120+
/**
121+
* {@inheritdoc}
122+
*/
123+
public function isWritable($class, $property, array $context = []): ?bool
124+
{
125+
if (
126+
null === ($metadata = $this->getMetadata($class))
127+
|| ClassMetadata::GENERATOR_TYPE_NONE === $metadata->generatorType
128+
|| !\in_array($property, $metadata->getIdentifierFieldNames(), true)
129+
) {
130+
return null;
131+
}
132+
133+
return false;
134+
}
135+
136+
private function getMetadata(string $class): ?ClassMetadata
137+
{
138+
try {
139+
return $this->objectManager->getClassMetadata($class);
140+
} catch (MappingException $exception) {
141+
return null;
142+
}
143+
}
144+
114145
/**
115146
* Gets the corresponding built-in PHP type.
116147
*/

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)