Skip to content

Commit 90f046f

Browse files
committed
Merge branch '6.4' into 7.2
* 6.4: [TwigBridge] Fix `ModuleNode` call in `TwigNodeProvider` fix compatibility with Doctrine ORM 4 Fix CS
2 parents f9914f5 + 6d289e7 commit 90f046f

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Doctrine\ORM\EntityRepository;
1717
use Doctrine\ORM\Mapping\ClassMetadata;
1818
use Doctrine\ORM\Mapping\ClassMetadataInfo;
19+
use Doctrine\ORM\Mapping\PropertyAccessors\RawValuePropertyAccessor;
1920
use Doctrine\ORM\Tools\SchemaTool;
2021
use Doctrine\Persistence\ManagerRegistry;
2122
use Doctrine\Persistence\ObjectManager;
@@ -132,11 +133,21 @@ class_exists(ClassMetadataInfo::class) ? ClassMetadataInfo::class : ClassMetadat
132133
->willReturn(true)
133134
;
134135
$refl = $this->createMock(\ReflectionProperty::class);
136+
$refl
137+
->method('getName')
138+
->willReturn('name')
139+
;
135140
$refl
136141
->method('getValue')
137142
->willReturn(true)
138143
;
139-
$classMetadata->reflFields = ['name' => $refl];
144+
145+
if (property_exists(ClassMetadata::class, 'propertyAccessors')) {
146+
$classMetadata->propertyAccessors['name'] = RawValuePropertyAccessor::fromReflectionProperty($refl);
147+
} else {
148+
$classMetadata->reflFields = ['name' => $refl];
149+
}
150+
140151
$em->expects($this->any())
141152
->method('getClassMetadata')
142153
->willReturn($classMetadata)

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Validator\Constraints;
1313

14+
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
1415
use Doctrine\ORM\Mapping\MappingException as ORMMappingException;
1516
use Doctrine\Persistence\ManagerRegistry;
1617
use Doctrine\Persistence\Mapping\ClassMetadata;
@@ -287,9 +288,13 @@ private function getFieldValues(mixed $object, ClassMetadata $class, array $fiel
287288
throw new ConstraintDefinitionException(\sprintf('The field "%s" is not a property of class "%s".', $fieldName, $objectClass));
288289
}
289290

290-
$fieldValues[$entityFieldName] = $isValueEntity && $object instanceof ($class->getName())
291-
? $class->reflFields[$fieldName]->getValue($object)
292-
: $this->getPropertyValue($objectClass, $fieldName, $object);
291+
if ($isValueEntity && $object instanceof ($class->getName()) && property_exists(OrmClassMetadata::class, 'propertyAccessors')) {
292+
$fieldValues[$entityFieldName] = $class->propertyAccessors[$fieldName]->getValue($object);
293+
} elseif ($isValueEntity && $object instanceof ($class->getName())) {
294+
$fieldValues[$entityFieldName] = $class->reflFields[$fieldName]->getValue($object);
295+
} else {
296+
$fieldValues[$entityFieldName] = $this->getPropertyValue($objectClass, $fieldName, $object);
297+
}
293298
}
294299

295300
return $fieldValues;

src/Symfony/Bridge/Twig/Tests/NodeVisitor/TwigNodeProvider.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Bridge\Twig\Node\TransDefaultDomainNode;
1515
use Symfony\Bridge\Twig\Node\TransNode;
1616
use Twig\Node\BodyNode;
17+
use Twig\Node\EmptyNode;
1718
use Twig\Node\Expression\ArrayExpression;
1819
use Twig\Node\Expression\ConstantExpression;
1920
use Twig\Node\Expression\FilterExpression;
@@ -27,13 +28,15 @@ class TwigNodeProvider
2728
{
2829
public static function getModule($content)
2930
{
31+
$emptyNodeExists = class_exists(EmptyNode::class);
32+
3033
return new ModuleNode(
3134
new BodyNode([new ConstantExpression($content, 0)]),
3235
null,
33-
new ArrayExpression([], 0),
34-
new ArrayExpression([], 0),
35-
new ArrayExpression([], 0),
36-
null,
36+
$emptyNodeExists ? new EmptyNode() : new ArrayExpression([], 0),
37+
$emptyNodeExists ? new EmptyNode() : new ArrayExpression([], 0),
38+
$emptyNodeExists ? new EmptyNode() : new ArrayExpression([], 0),
39+
$emptyNodeExists ? new EmptyNode() : null,
3740
new Source('', '')
3841
);
3942
}

src/Symfony/Bundle/FrameworkBundle/Test/HttpClientAssertionsTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
1515
use Symfony\Component\HttpClient\DataCollector\HttpClientDataCollector;
1616

17-
/*
17+
/**
1818
* @author Mathieu Santostefano <[email protected]>
1919
*/
20-
2120
trait HttpClientAssertionsTrait
2221
{
2322
public static function assertHttpClientRequest(string $expectedUrl, string $expectedMethod = 'GET', string|array|null $expectedBody = null, array $expectedHeaders = [], string $httpClientId = 'http_client'): void

src/Symfony/Bundle/FrameworkBundle/Test/NotificationAssertionsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Component\Notifier\Message\MessageInterface;
1818
use Symfony\Component\Notifier\Test\Constraint as NotifierConstraint;
1919

20-
/*
20+
/**
2121
* @author Smaïne Milianni <[email protected]>
2222
*/
2323
trait NotificationAssertionsTrait

0 commit comments

Comments
 (0)