10000 Merge branch '5.4' into 6.2 · symfony/symfony@f3b6e77 · GitHub
[go: up one dir, main page]

Skip to content

Commit f3b6e77

Browse files
Merge branch '5.4' into 6.2
* 5.4: Fix Doctrine deprecations [Validator] Remove internal from methods on non-internal interfaces [PhpUnitBridge] Fix support for the NO_COLOR env var
2 parents 24347bf + b4128fd commit f3b6e77

File tree

65 files changed

+1681
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1681
-106
lines changed

.github/deprecations-baseline.json

Lines changed: 1237 additions & 0 deletions
Large diffs are not rendered by default.

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
services:
3030
postgres:
31-
image: postgres:9.6-alpine
31+
image: postgres:10.6-alpine
3232
ports:
3333
- 5432:5432
3434
env:

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ jobs:
8888
8989
# Create local composer packages for each patched components and reference them in composer.json files when cross-testing components
9090
if [[ ! "${{ matrix.mode }}" = *-deps ]]; then
91+
echo SYMFONY_DEPRECATIONS_HELPER="baselineFile=$(pwd)/.github/deprecations-baseline.json" >> $GITHUB_ENV
9192
php .github/build-packages.php HEAD^ $SYMFONY_VERSION src/Symfony/Bridge/PhpUnit
9293
else
9394
echo SYMFONY_DEPRECATIONS_HELPER=weak >> $GITHUB_ENV

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

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

1212
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
1313

14+
use Doctrine\DBAL\ArrayParameterType;
1415
use Doctrine\DBAL\Connection;
1516
use Doctrine\DBAL\Types\ConversionException;
1617
use Doctrine\DBAL\Types\Type;
@@ -70,15 +71,15 @@ public function getEntitiesByIds(string $identifier, array $values): array
7071
$entity = current($qb->getRootEntities());
7172
$metadata = $qb->getEntityManager()->getClassMetadata($entity);
7273
if (\in_array($type = $metadata->getTypeOfField($identifier), ['integer', 'bigint', 'smallint'])) {
73-
$parameterType = Connection::PARAM_INT_ARRAY;
74+
$parameterType = class_exists(ArrayParameterType::class) ? ArrayParameterType::INTEGER : Connection::PARAM_INT_ARRAY;
7475

7576
// Filter out non-integer values (e.g. ""). If we don't, some
7677
// databases such as PostgreSQL fail.
7778
$values = array_values(array_filter($values, function ($v) {
7879
return (string) $v === (string) (int) $v || ctype_digit($v);
7980
}));
8081
} elseif (\in_array($type, ['ulid', 'uuid', 'guid'])) {
81-
$parameterType = Connection::PARAM_STR_ARRAY;
82+
$parameterType = class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY;
8283

8384
// Like above, but we just filter out empty strings.
8485
$values = array_values(array_filter($values, function ($v) {
@@ -99,7 +100,7 @@ public function getEntitiesByIds(string $identifier, array $values): array
99100
unset($value);
100101
}
101102
} else {
102-
$parameterType = Connection::PARAM_STR_ARRAY;
103+
$parameterType = class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY;
103104
}
104105
if (!$values) {
105106
return [];

src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/DoctrineExtensionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function testMappingTypeDetection()
187187

188188
// The ordinary fixtures contain annotation
189189
$mappingType = $method->invoke($this->extension, __DIR__.'/../Fixtures', $container);
190-
$this->assertSame($mappingType, 'annotation');
190+
$this->assertSame($mappingType, 'attribute');
191191

192192
// In the attribute folder, attributes are used
193193
$mappingType = $method->invoke($this->extension, __DIR__.'/../Fixtures/Attribute', $container);
@@ -275,9 +275,9 @@ public function testUnrecognizedCacheDriverException()
275275

276276
public static function providerBundles()
277277
{
278-
yield ['AnnotationsBundle', 'annotation', '/Entity'];
279-
yield ['AnnotationsOneLineBundle', 'annotation', '/Entity'];
280-
yield ['FullEmbeddableAnnotationsBundle', 'annotation', '/Entity'];
278+
yield ['AnnotationsBundle', 'attribute', '/Entity'];
279+
yield ['AnnotationsOneLineBundle', 'attribute', '/Entity'];
280+
yield ['FullEmbeddableAnnotationsBundle', 'attribute', '/Entity'];
281281
yield ['AttributesBundle', 'attribute', '/Entity'];
282282
yield ['FullEmbeddableAttributesBundle', 'attribute', '/Entity'];
283283
yield ['XmlBundle', 'xml', '/Resources/config/doctrine'];
@@ -286,7 +286,7 @@ public static function providerBundles()
286286

287287
yield ['SrcXmlBundle', 'xml', '/Resources/config/doctrine'];
288288

289-
yield ['NewAnnotationsBundle', 'annotation', \DIRECTORY_SEPARATOR.'src/Entity'];
289+
yield ['NewAnnotationsBundle', 'attribute', \DIRECTORY_SEPARATOR.'src/Entity'];
290290
yield ['NewXmlBundle', 'xml', '/config/doctrine'];
291291
}
292292

src/Symfony/Bridge/Doctrine/Tests/DoctrineTestHelper.php

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
namespace Symfony\Bridge\Doctrine\Tests;
1313

1414
use Doctrine\Common\Annotations\AnnotationReader;
15+
use Doctrine\DBAL\DriverManager;
16+
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
1517
use Doctrine\ORM\Configuration;
1618
use Doctrine\ORM\EntityManager;
1719
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
20+
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
1821
use Doctrine\ORM\Mapping\Driver\XmlDriver;
22+
use Doctrine\ORM\ORMSetup;
1923
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
2024
use Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator;
2125
use PHPUnit\Framework\TestCase;
@@ -41,17 +45,30 @@ public static function createTestEntityManager(Configuration $config = null): En
4145
'memory' => true,
4246
];
4347

44-
return EntityManager::create($params, $config ?? self::createTestConfiguration());
48+
$config ??= self::createTestConfiguration();
49+
50+
if (!(new \ReflectionMethod(EntityManager::class, '__construct'))->isPublic()) {
51+
return EntityManager::create($params, $config);
52+
}
53+
54+
return new EntityManager(DriverManager::getConnection($params, $config), $config);
4555
}
4656

4757
public static function createTestConfiguration(): Configuration
4858
{
49-
$config = new Configuration();
59+
$config = class_exists(ORMSetup::class) ? ORMSetup::createConfiguration(true) : new Configuration();
5060
$config->setEntityNamespaces(['SymfonyTestsDoctrine' => 'Symfony\Bridge\Doctrine\Tests\Fixtures']);
5161
$config->setAutoGenerateProxyClasses(true);
5262
$config->setProxyDir(sys_get_temp_dir());
5363
$config->setProxyNamespace('SymfonyTests\Doctrine');
54-
$config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader()));
64+
if (class_exists(AttributeDriver::class)) {
65+
$config->setMetadataDriverImpl(new AttributeDriver([__DIR__.'/../Tests/Fixtures' => 'Symfony\Bridge\Doctrine\Tests\Fixtures'], true));
66+
} else {
67+
$config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), null, true));
68+
}
69+
if (class_exists(DefaultSchemaManagerFactory::class)) {
70+
$config->setSchemaManagerFactory(new DefaultSchemaManagerFactory());
71+
}
5572

5673
return $config;
5774
}
@@ -65,7 +82,9 @@ public static function createTestConfigurationWithXmlLoader(): Configuration
6582
new XmlDriver(
6683
new SymfonyFileLocator(
6784
[__DIR__.'/../Tests/Resources/orm' => 'Symfony\\Bridge\\Doctrine\\Tests\\Fixtures'], '.orm.xml'
68-
)
85+
),
86+
'.orm.xml',
87+
true
6988
),
7089
'Symfony\\Bridge\\Doctrine\\Tests\\Fixtures'
7190
);

src/Symfony/Bridge/Doctrine/Tests/Fixtures/AssociationEntity.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@
1616
/**
1717
* @ORM\Entity
1818
*/
19+
#[ORM\Entity]
1920
class AssociationEntity
2021
{
2122
/**
2223
* @var int
2324
* @ORM\Id @ORM\GeneratedValue
2425
* @ORM\Column(type="integer")
2526
*/
27+
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
2628
private $id;
2729

2830
/**
2931
* @ORM\ManyToOne(targetEntity="SingleIntIdEntity")
3032
*
3133
* @var \Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity
3234
*/
35+
#[ORM\ManyToOne(targetEntity: SingleIntIdEntity::class)]
3336
public $single;
3437

3538
/**
@@ -41,5 +44,8 @@ class AssociationEntity
4144
*
4245
* @var \Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity
4346
*/
47+
#[ORM\ManyToOne(targetEntity: CompositeIntIdEntity::class)]
48+
#[ORM\JoinColumn(name: 'composite_id1', referencedColumnName: 'id1')]
49+
#[ORM\JoinColumn(name: 'composite_id2', referencedColumnName: 'id2')]
4450
public $composite;
4551
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/AssociationEntity2.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@
1616
/**
1717
* @ORM\Entity
1818
*/
19+
#[ORM\Entity]
1920
class AssociationEntity2
2021
{
2122
/**
2223
* @var int
2324
* @ORM\Id @ORM\GeneratedValue
2425
* @ORM\Column(type="integer")
2526
*/
27+
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
2628
private $id;
2729

2830
/**
2931
* @ORM\ManyToOne(targetEntity="SingleIntIdNoToStringEntity")
3032
*
3133
* @var \Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity
3234
*/
35+
#[ORM\ManyToOne(targetEntity: SingleIntIdNoToStringEntity::class)]
3336
public $single;
3437

3538
/**
@@ -41,5 +44,8 @@ class AssociationEntity2
4144
*
4245
* @var \Symfony\Bridge\Doctrine\Tests\Fixtures\CompositeIntIdEntity
4346
*/
47+
#[ORM\ManyToOne(targetEntity: CompositeIntIdEntity::class)]
48+
#[ORM\JoinColumn(name: 'composite_id1', referencedColumnName: 'id1')]
49+
#[ORM\JoinColumn(name: 'composite_id2', referencedColumnName: 'id2')]
4450
public $composite;
4551
}

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Bundles/AnnotationsBundle/Entity/Person.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
/**
1919
* @Entity
2020
*/
21+
#[Entity]
2122
class Person
2223
{
2324
/** @Id @Column(type="integer") */
25+
#[Id, Column(type: 'integer')]
2426
protected $id;
2527

2628
/** @Column(type="string") */
29+
#[Column(type: 'string')]
2730
public $name;
2831

2932
public function __construct($id, $name)

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Bundles/AnnotationsOneLineBundle/Entity/Person.php

Lines changed: 3 additions & 0 deletions
Original 341A file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
use Doctrine\ORM\Mapping\Id;
1717

1818
/** @Entity */
19+
#[Entity]
1920
class Person
2021
{
2122
/** @Id @Column(type="integer") */
23+
#[Id, Column(type: 'integer')]
2224
protected $id;
2325

2426
/** @Column(type="string") */
27+
#[Column(type: 'string')]
2528
public $name;
2629

2730
public function __construct($id, $name)

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Bundles/AttributesBundle/AnnotatedEntity/Person.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
/**
1919
* @Entity
2020
*/
21+
#[Entity]
2122
class Person
2223
{
2324
/** @Id @Column(type="integer") */
25+
#[Id, Column(type: 'integer')]
2426
protected $id;
2527

2628
/** @Column(type="string") */
29+
#[Column(type: 'string')]
2730
public $name;
2831

2932
public function __construct($id, $name)

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Bundles/FullEmbeddableAnnotationsBundle/Entity/Address.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,24 @@
1313

1414
use Doctrine\ORM\Mapping\Column;
1515
use Doctrine\ORM\Mapping\Embeddable;
16-
use Doctrine\ORM\Mapping\Id;
1716

1817
/**
1918
* @Embeddable
2019
*/
20+
#[Embeddable]
2121
class Address
2222
{
2323

2424
/** @Column(type="string") */
25+
#[Column(type: 'string')]
2526
public $street;
2627

2728
/** @Column(type="string") */
29+
#[Column(type: 'string')]
2830
public $zipCode;
2931

3032
/** @Column(type="string") */
33+
#[Column(type: 'string')]
3134
public $city;
3235

3336
public function __construct($street, $zipCode, $city)

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Bundles/FullEmbeddableAttributesBundle/Entity/Address.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Doctrine\ORM\Mapping\Column;
1515
use Doctrine\ORM\Mapping\Embeddable;
16-
use Doctrine\ORM\Mapping\Id;
1716

1817
#[Embeddable]
1918
class Address

src/Symfony/Bridge/Doctrine/Tests/Fixtures/Bundles/NewAnnotationsBundle/src/Entity/Person.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@
1818
/**
1919
* @Entity
2020
*/
21+
#[Entity]
2122
class Person
2223
{
2324
/** @Id @Column(type="integer") */
25+
#[Id, Column(type: 'integer')]
2426
protected $id;
2527

2628
/** @Column(type="string") */
29+
#[Column(type: 'string')]
2730
public $name;
2831

2932
public function __construct($id, $name)

src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeIntIdEntity.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@
1616
use Doctrine\ORM\Mapping\Id;
1717

1818
/** @Entity */
19+
#[Entity]
1920
class CompositeIntIdEntity
2021
{
2122
/** @Id @Column(type="integer") */
23+
#[Id, Column(type: 'integer')]
2224
protected $id1;
2325

2426
/** @Id @Column(type="integer") */
27+
#[Id, Column(type: 'integer')]
2528
protected $id2;
2629

2730
/** @Column(type="string") */
31+
#[Column(type: 'string')]
2832
public $name;
2933

3034
public function __construct($id1, $id2, $name)

src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeObjectNoToStringIdEntity.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*
1919
* @ORM\Entity
2020
*/
21+
#[ORM\Entity]
2122
class CompositeObjectNoToStringIdEntity
2223
{
2324
/**
@@ -27,6 +28,9 @@ class CompositeObjectNoToStringIdEntity
2728
* @ORM\ManyToOne(targetEntity="SingleIntIdNoToStringEntity", cascade={"persist"})
2829
* @ORM\JoinColumn(name="object_one_id")
2930
*/
31+
#[ORM\Id]
32+
#[ORM\ManyToOne(targetEntity: SingleIntIdNoToStringEntity::class, cascade: ['persist'])]
33+
#[ORM\JoinColumn(name: 'object_one_id')]
3034
protected $objectOne;
3135

3236
/**
@@ -36,6 +40,9 @@ class CompositeObjectNoToStringIdEntity
3640
* @ORM\ManyToOne(targetEntity="SingleIntIdNoToStringEntity", cascade={"persist"})
3741
* @ORM\JoinColumn(name="object_two_id")
3842
*/
43+
#[ORM\Id]
44+
#[ORM\ManyToOne(targetEntity: SingleIntIdNoToStringEntity::class, cascade: ['persist'])]
45+
#[ORM\JoinColumn(name: 'object_two_id')]
3946
protected $objectTwo;
4047

4148
public function __construct(SingleIntIdNoToStringEntity $objectOne, SingleIntIdNoToStringEntity $objectTwo)

src/Symfony/Bridge/Doctrine/Tests/Fixtures/CompositeStringIdEntity.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@
1616
use Doctrine\ORM\Mapping\Id;
1717

1818
/** @Entity */
19+
#[Entity]
1920
class CompositeStringIdEntity
2021
{
2122
/** @Id @Column(type="string") */
23+
#[Id, Column(type: 'string')]
2224
protected $id1;
2325

2426
/** @Id @Column(type="string") */
27+
#[Id, Column(type: 'string')]
2528
protected $id2;
2629

2730
/** @Column(type="string") */
31+
#[Column(type: 'string')]
2832
public $name;
2933

3034
public function __construct($id1, $id2, $name)

src/Symfony/Bridge/Doctrine/Tests/Fixtures/DoctrineLoaderEmbed.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616
/**
1717
* @ORM\Embeddable
1818
*/
19+
#[ORM\Embeddable]
1920
class DoctrineLoaderEmbed
2021
{
2122
/**
2223
* @ORM\Column(length=25)
2324
*/
25+
#[ORM\Column(length: 25)]
2426
public $embeddedMaxLength;
2527

2628
/**
2729
* @ORM\Embedded(class=DoctrineLoaderNestedEmbed::class)
2830
*/
31+
#[ORM\Embedded(class: DoctrineLoaderNestedEmbed::class)]
2932
public $nestedEmbedded;
3033
}

0 commit comments

Comments
 (0)
0