8000 Merge branch '6.4' into 7.0 · symfony/symfony@04724ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 04724ca

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: Fix CI [Translation] Prevent creating empty keys when key ends with a period #51928 Missing translations for Belarusian (be) [DoctrineBridge] Spread some PHP 8 love [Cache] Fix leftovers in generated Redis proxies [Cache] Add missing `@requires extension openssl` [Validator] Update Slovenian translations (sl)
2 parents 89c679f + 7074da9 commit 04724ca

File tree

73 files changed

+473
-515
lines changed

Some content is hidden

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

73 files changed

+473
-515
lines changed

src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
*/
2525
class ProxyCacheWarmer implements CacheWarmerInterface
2626
{
27-
private ManagerRegistry $registry;
28-
29-
public function __construct(ManagerRegistry $registry)
30-
{
31-
$this->registry = $registry;
27+
public function __construct(
28+
private readonly ManagerRegistry $registry,
29+
) {
3230
}
3331

3432
/**

src/Symfony/Bridge/Doctrine/DataCollector/ObjectParameter.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,14 @@
1313

1414
final class ObjectParameter
1515
{
16-
private object $object;
17-
private ?\Throwable $error;
1816
private bool $stringable;
1917
private string $class;
2018

21-
public function __construct(object $object, ?\Throwable $error)
22-
{
23-
$this->object = $object;
24-
$this->error = $error;
25-
$this->stringable = \is_callable([$object, '__toString']);
19+
public function __construct(
20+
private readonly object $object,
21+
private readonly ?\Throwable $error,
22+
) {
23+
$this->stringable = $this->object instanceof \Stringable;
2624
$this->class = $object::class;
2725
}
2826

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
*/
2222
class DoctrineValidationPass implements CompilerPassInterface
2323
{
24-
private string $managerType;
25-
26-
public function __construct(string $managerType)
27-
{
28-
$this->managerType = $managerType;
24+
public function __construct(
25+
private readonly string $managerType,
26+
) {
2927
}
3028

3129
public function process(ContainerBuilder $container): void

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,23 @@
3030
*/
3131
class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
3232
{
33-
private string $connectionsParameter;
3433
private array $connections;
3534

3635
/**
3736
* @var array<string, Definition>
3837
*/
3938
private array $eventManagers = [];
4039

41-
private string $managerTemplate;
42-
private string $tagPrefix;
43-
4440
/**
4541
* @param string $managerTemplate sprintf() template for generating the event
4642
* manager's service ID for a connection name
4743
* @param string $tagPrefix Tag prefix for listeners
4844
*/
49-
public function __construct(string $connectionsParameter, string $managerTemplate, string $tagPrefix)
50-
{
51-
$this->connectionsParameter = $connectionsParameter;
52-
$this->managerTemplate = $managerTemplate;
53-
$this->tagPrefix = $tagPrefix;
45+
public function __construct(
46+
private readonly string $connectionsParameter,
47+
private readonly string $managerTemplate,
48+
private readonly string $tagPrefix,
49+
) {
5450
}
5551

5652
public function process(ContainerBuilder $container): void

src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterMappingsPass.php

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,6 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
6767
*/
6868
protected string|false $enabledParameter;
6969

70-
/**
71-
* Naming pattern for the configuration service id, for example
72-
* 'doctrine.orm.%s_configuration'.
73-
*/
74-
private string $configurationPattern;
75-
76-
/**
77-
* Method name to call on the configuration service. This depends on the
78-
* Doctrine implementation. For example addEntityNamespace.
79-
*/
80-
private string $registerAliasMethodName;
81-
82-
/**
83-
* Map of alias to namespace.
84-
*
85-
* @var string[]
86-
*/
87-
private array $aliasMap;
88-
8970
/**
9071
* The $managerParameters is an ordered list of container parameters that could provide the
9172
* name of the manager to register these namespaces and alias on. The first non-empty name
@@ -102,24 +83,32 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
10283
* @param string|false $enabledParameter Service container parameter that must be
10384
* present to enable the mapping. Set to false
10485
* to not do any check, optional.
105-
* @param string $configurationPattern Pattern for the Configuration service name
106-
* @param string $registerAliasMethodName Name of Configuration class method to
107-
* register alias
86+
* @param string $configurationPattern Pattern for the Configuration service name,
87+
* for example 'doctrine.orm.%s_configuration'.
88+
* @param string $registerAliasMethodName Method name to call on the configuration service. This
89+
* depends on the Doctrine implementation.
90+
* For example addEntityNamespace.
10891
* @param string[] $aliasMap Map of alias to namespace
10992
*/
110-
public function __construct(Definition|Reference $driver, array $namespaces, array $managerParameters, string $driverPattern, string|false $enabledParameter = false, string $configurationPattern = '', string $registerAliasMethodName = '', array $aliasMap = [])
111-
{
93+
public function __construct(
94+
Definition|Reference $driver,
95+
array $namespaces,
96+
array $managerParameters,
97+
string $driverPattern,
98+
string|false $enabledParameter = false,
99+
private readonly string $configurationPattern = '',
100+
private readonly string $registerAliasMethodName = '',
101+
private readonly array $aliasMap = [],
102+
) {
112103
$this->driver = $driver;
113104
$this->namespaces = $namespaces;
114105
$this->managerParameters = $managerParameters;
115106
$this->driverPattern = $driverPattern;
116107
$this->enabledParameter = $enabledParameter;
117-
if (\count($aliasMap) && (!$configurationPattern || !$registerAliasMethodName)) {
108+
109+
if ($aliasMap && (!$configurationPattern || !$registerAliasMethodName)) {
118110
throw new \InvalidArgumentException('configurationPattern and registerAliasMethodName are required to register namespace alias.');
119111
}
120-
$this->configurationPattern = $configurationPattern;
121-
$this->registerAliasMethodName = $registerAliasMethodName;
122-
$this->aliasMap = $aliasMap;
123112
}
124113

125114
/**

src/Symfony/Bridge/Doctrine/DependencyInjection/Security/UserProvider/EntityFactory.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424
*/
2525
class EntityFactory implements UserProviderFactoryInterface
2626
{
27-
private string $key;
28-
private string $providerId;
29-
30-
public function __construct(string $key, string $providerId)
31-
{
32-
$this->key = $key;
33-
$this->providerId = $providerId;
27+
public function __construct(
28+
private readonly string $key,
29+
private readonly string $providerId,
30+
) {
3431
}
3532

3633
public function create(ContainerBuilder $container, string $id, array $config): void

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
*/
2323
class DoctrineChoiceLoader extends AbstractChoiceLoader
2424
{
25-
private ObjectManager $manager;
26-
private string $class;
27-
private ?IdReader $idReader;
28-
private ?EntityLoaderInterface $objectLoader;
25+
/** @var class-string */
26+
private readonly string $class;
2927

3028
/**
3129
* Creates a new choice loader.
@@ -36,18 +34,17 @@ class DoctrineChoiceLoader extends AbstractChoiceLoader
3634
*
3735
* @param string $class The class name of the loaded objects
3836
*/
39-
public function __construct(ObjectManager $manager, string $class, IdReader $idReader = null, EntityLoaderInterface $objectLoader = null)
40-
{
41-
$classMetadata = $manager->getClassMetadata($class);
42-
37+
public function __construct(
38+
private readonly ObjectManager $manager,
39+
string $class,
40+
private readonly ?IdReader $idReader = null,
41+
private readonly ?EntityLoaderInterface $objectLoader = null,
42+
) {
4343
if ($idReader && !$idReader->isSingleId()) {
4444
throw new \InvalidArgumentException(sprintf('The second argument "$idReader" of "%s" must be null when the query cannot be optimized because of composite id fields.', __METHOD__));
4545
}
4646

47-
$this->manager = $manager;
48-
$this->class = $classMetadata->getName();
49-
$this->idReader = $idReader;
50-
$this->objectLoader = $objectLoader;
47+
$this->class = $manager->getClassMetadata($class)->getName();
5148
}
5249

5350
protected function loadChoices(): iterable

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,35 @@
2424
*/
2525
class IdReader
2626
{
27-
private ObjectManager $om;
28-
private ClassMetadata $classMetadata;
29-
private bool $singleId;
30-
private bool $intId;
31-
private string $idField;
32-
pri 10000 vate ?self $associationIdReader = null;
33-
34-
public function __construct(ObjectManager $om, ClassMetadata $classMetadata)
35-
{
27+
private readonly bool $singleId;
28+
private readonly bool $intId;
29+
private readonly string $idField;
30+
private readonly ?self $associationIdReader;
31+
32+
public function __construct(
33+
private readonly ObjectManager $om,
34+
private readonly ClassMetadata $classMetadata,
35+
) {
3636
$ids = $classMetadata->getIdentifierFieldNames();
3737
$idType = $classMetadata->getTypeOfField(current($ids));
3838

39-
$this->om = $om;
40-
$this->classMetadata = $classMetadata;
41-
$this->singleId = 1 === \count($ids);
42-
$this->intId = $this->singleId && \in_array($idType, ['integer', 'smallint', 'bigint']);
39+
$singleId = 1 === \count($ids);
4340
$this->idField = current($ids);
4441

4542
// single field association are resolved, since the schema column could be an int
46-
if ($this->singleId && $classMetadata->hasAssociation($this->idField)) {
43+
if ($singleId && $classMetadata->hasAssociation($this->idField)) {
4744
$this->associationIdReader = new self($om, $om->getClassMetadata(
4845
$classMetadata->getAssociationTargetClass($this->idField)
4946
));
5047

51-
$this->singleId = $this->associationIdReader->isSingleId();
48+
$singleId = $this->associationIdReader->isSingleId();
5249
$this->intId = $this->associationIdReader->isIntId();
50+
} else {
51+
$this->intId = $singleId && \in_array($idType, ['integer', 'smallint', 'bigint']);
52+
$this->associationIdReader = null;
5353
}
54+
55+
$this->singleId = $singleId;
5456
}
5557

5658
/**

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

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,9 @@
2525
*/
2626
class ORMQueryBuilderLoader implements EntityLoaderInterface
2727
{
28-
/**
29-
* Contains the query builder that builds the query for fetching the
30-
* entities.
31-
*
32-
* This property should only be accessed through queryBuilder.
33-
*/
34-
private QueryBuilder $queryBuilder;
35-
36-
public function __construct(QueryBuilder $queryBuilder)
37-
{
38-
$this->queryBuilder = $queryBuilder;
28+
public function __construct(
29+
private readonly QueryBuilder $queryBuilder,
30+
) {
3931
}
4032

4133
public function getEntities(): array

src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919

2020
final class UlidGenerator extends AbstractIdGenerator
2121
{
22-
private ?UlidFactory $factory;
23-
24-
public function __construct(UlidFactory $factory = null)
25-
{
26-
$this->factory = $factory;
22+
public function __construct(
23+
private readonly ?UlidFactory $factory = null
24+
) {
2725
}
2826

2927
/**

src/Symfony/Bridge/Doctrine/IdGenerator/UuidGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
final class UuidGenerator extends AbstractIdGenerator
2424
{
25-
private UuidFactory $protoFactory;
25+
private readonly UuidFactory $protoFactory;
2626
private UuidFactory|NameBasedUuidFactory|RandomBasedUuidFactory|TimeBasedUuidFactory $factory;
2727
private ?string $entityGetter = null;
2828

src/Symfony/Bridge/Doctrine/Messenger/DoctrineClearEntityManagerWorkerSubscriber.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
*/
2424
class DoctrineClearEntityManagerWorkerSubscriber implements EventSubscriberInterface
2525
{
26-
private ManagerRegistry $managerRegistry;
27-
28-
public function __construct(ManagerRegistry $managerRegistry)
29-
{
30-
$this->managerRegistry = $managerRegistry;
26+
public function __construct(
27+
private readonly ManagerRegistry $managerRegistry,
28+
) {
3129
}
3230

3331
public function onWorkerMessageHandled(): void

src/Symfony/Bridge/Doctrine/Messenger/DoctrineOpenTransactionLoggerMiddleware.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@
2424
*/
2525
class DoctrineOpenTransactionLoggerMiddleware extends AbstractDoctrineMiddleware
2626
{
27-
private ?LoggerInterface $logger;
28-
29-
public function __construct(ManagerRegistry $managerRegistry, string $entityManagerName = null, LoggerInterface $logger = null)
30-
{
27+
public function __construct(
28+
ManagerRegistry $managerRegistry,
29+
string $entityManagerName = null,
30+
private readonly ?LoggerInterface $logger = null,
31+
) {
3132
parent::__construct($managerRegistry, $entityManagerName);
32-
33-
$this->logger = $logger;
3433
}
3534

3635
protected function handleForManager(EntityManagerInterface $entityManager, Envelope $envelope, StackInterface $stack): Envelope

src/Symfony/Bridge/Doctrine/Middleware/Debug/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ final class Connection extends AbstractConnectionMiddleware
2626
{
2727
public function __construct(
2828
ConnectionInterface $connection,
29-
private DebugDataHolder $debugDataHolder,
30-
private ?Stopwatch $stopwatch,
31-
private string $connectionName,
29+
private readonly DebugDataHolder $debugDataHolder,
30+
private readonly ?Stopwatch $stopwatch,
31+
private readonly string $connectionName,
3232
) {
3333
parent::__construct($connection);
3434
}

src/Symfony/Bridge/Doctrine/Middleware/Debug/DBAL3/Connection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ final class Connection extends AbstractConnectionMiddleware
2929

3030
public function __construct(
3131
ConnectionInterface $connection,
32-
private DebugDataHolder $debugDataHolder,
33-
private ?Stopwatch $stopwatch,
34-
private string $connectionName,
32+
private readonly DebugDataHolder $debugDataHolder,
33+
private readonly ?Stopwatch $stopwatch,
34+
private readonly string $connectionName,
3535
) {
3636
parent::__construct($connection);
3737
}

src/Symfony/Bridge/Doctrine/Middleware/Debug/DBAL3/Statement.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
*/
2727
final class Statement extends AbstractStatementMiddleware
2828
{
29-
private Query $query;
29+
private readonly Query $query;
3030

3131
public function __construct(
3232
StatementInterface $statement,
33-
private DebugDataHolder $debugDataHolder,
34-
private string $connectionName,
33+
private readonly DebugDataHolder $debugDataHolder,
34+
private readonly string $connectionName,
3535
string $sql,
36-
private ?Stopwatch $stopwatch = null,
36+
private readonly ?Stopwatch $stopwatch = null,
3737
) {
3838
$this->query = new Query($sql);
3939

src/Symfony/Bridge/Doctrine/Middleware/Debug/Middleware.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
final class Middleware implements MiddlewareInterface
2424
{
2525
public function __construct(
26-
private DebugDataHolder $debugDataHolder,
27-
private ?Stopwatch $stopwatch,
28-
private string $connectionName = 'default',
26+
private readonly DebugDataHolder $debugDataHolder,
27+
private readonly ?Stopwatch $stopwatch,
28+
private readonly string $connectionName = 'default',
2929
) {
3030
}
3131

0 commit comments

Comments
 (0)
0