Skip to content

Commit 9f72be3

Browse files
derrabusnicolas-grekas
authored andcommitted
[DoctrineBridge] Add types to private properties
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent 599e58c commit 9f72be3

21 files changed

+72
-65
lines changed

CacheWarmer/ProxyCacheWarmer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
class ProxyCacheWarmer implements CacheWarmerInterface
2626
{
27-
private $registry;
27+
private ManagerRegistry $registry;
2828

2929
public function __construct(ManagerRegistry $registry)
3030
{

ContainerAwareEventManager.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ class ContainerAwareEventManager extends EventManager
2828
*
2929
* <event> => <listeners>
3030
*/
31-
private $listeners = [];
32-
private $subscribers;
33-
private $initialized = [];
34-
private $initializedSubscribers = false;
35-
private $methods = [];
36-
private $container;
31+
private array $listeners = [];
32+
private array $subscribers;
33+
private array $initialized = [];
34+
private bool $initializedSubscribers = false;
35+
private array $methods = [];
36+
private ContainerInterface $container;
3737

3838
/**
3939
* @param list<string|EventSubscriber|array{string[], string|object}> $subscriberIds List of subscribers, subscriber ids, or [events, listener] tuples

DataCollector/DoctrineDataCollector.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
*/
2929
class DoctrineDataCollector extends DataCollector
3030
{
31-
private $registry;
32-
private $connections;
33-
private $managers;
31+
private ManagerRegistry $registry;
32+
private array $connections;
33+
private array $managers;
3434

3535
/**
36-
* @var DebugStack[]
36+
* @var array<string, DebugStack>
3737
*/
38-
private $loggers = [];
38+
private array $loggers = [];
3939

4040
public function __construct(ManagerRegistry $registry)
4141
{

DataCollector/ObjectParameter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
final class ObjectParameter
1515
{
16-
private $object;
17-
private $error;
18-
private $stringable;
19-
private $class;
16+
private object $object;
17+
private ?\Throwable $error;
18+
private bool $stringable;
19+
private string $class;
2020

2121
public function __construct(object $object, ?\Throwable $error)
2222
{

DataFixtures/ContainerAwareLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
class ContainerAwareLoader extends Loader
2727
{
28-
private $container;
28+
private ContainerInterface $container;
2929

3030
public function __construct(ContainerInterface $container)
3131
{

DependencyInjection/CompilerPass/DoctrineValidationPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class DoctrineValidationPass implements CompilerPassInterface
2323
{
24-
private $managerType;
24+
private string $managerType;
2525

2626
public function __construct(string $managerType)
2727
{

DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
1717
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
1818
use Symfony\Component\DependencyInjection\ContainerBuilder;
19+
use Symfony\Component\DependencyInjection\Definition;
1920
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2021
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
2122
use Symfony\Component\DependencyInjection\Reference;
@@ -29,20 +30,25 @@
2930
*/
3031
class RegisterEventListenersAndSubscribersPass implements CompilerPassInterface
3132
{
32-
private $connections;
33-
private $eventManagers;
34-
private $managerTemplate;
35-
private $tagPrefix;
33+
private string $connectionsParameter;
34+
private array $connections;
35+
36+
/**
37+
* @var array<string, Definition>
38+
*/
39+
private array $eventManagers = [];
40+
41+
private string $managerTemplate;
42+
private string $tagPrefix;
3643

3744
/**
38-
* @param string $connections Parameter ID for connections
3945
* @param string $managerTemplate sprintf() template for generating the event
4046
* manager's service ID for a connection name
4147
* @param string $tagPrefix Tag prefix for listeners and subscribers
4248
*/
43-
public function __construct(string $connections, string $managerTemplate, string $tagPrefix)
49+
public function __construct(string $connectionsParameter, string $managerTemplate, string $tagPrefix)
4450
{
45-
$this->connections = $connections;
51+
$this->connectionsParameter = $connectionsParameter;
4652
$this->managerTemplate = $managerTemplate;
4753
$this->tagPrefix = $tagPrefix;
4854
}
@@ -52,11 +58,11 @@ public function __construct(string $connections, string $managerTemplate, string
5258
*/
5359
public function process(ContainerBuilder $container)
5460
{
55-
if (!$container->hasParameter($this->connections)) {
61+
if (!$container->hasParameter($this->connectionsParameter)) {
5662
return;
5763
}
5864

59-
$this->connections = $container->getParameter($this->connections);
65+
$this->connections = $container->getParameter($this->connectionsParameter);
6066
$listenerRefs = $this->addTaggedServices($container);
6167

6268
// replace service container argument of event managers with smaller service locator

DependencyInjection/CompilerPass/RegisterMappingsPass.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,21 @@ abstract class RegisterMappingsPass implements CompilerPassInterface
7676
/**
7777
* Naming pattern for the configuration service id, for example
7878
* 'doctrine.orm.%s_configuration'.
79-
*
80-
* @var string
8179
*/
82-
private $configurationPattern;
80+
private string $configurationPattern;
8381

8482
/**
8583
* Method name to call on the configuration service. This depends on the
8684
* Doctrine implementation. For example addEntityNamespace.
87-
*
88-
* @var string
8985
*/
90-
private $registerAliasMethodName;
86+
private string $registerAliasMethodName;
9187

9288
/**
9389
* Map of alias to namespace.
9490
*
9591
* @var string[]
9692
*/
97-
private $aliasMap;
93+
private array $aliasMap;
9894

9995
/**
10096
* The $managerParameters is an ordered list of container parameters that could provide the

DependencyInjection/Security/UserProvider/EntityFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
*/
2525
class EntityFactory implements UserProviderFactoryInterface
2626
{
27-
private $key;
28-
private $providerId;
27+
private string $key;
28+
private string $providerId;
2929

3030
public function __construct(string $key, string $providerId)
3131
{

Form/ChoiceList/DoctrineChoiceLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
*/
2222
class DoctrineChoiceLoader extends AbstractChoiceLoader
2323
{
24-
private $manager;
25-
private $class;
26-
private $idReader;
27-
private $objectLoader;
24+
private ObjectManager $manager;
25+
private string $class;
26+
private ?IdReader $idReader;
27+
private ?EntityLoaderInterface $objectLoader;
2828

2929
/**
3030
* Creates a new choice loader.

0 commit comments

Comments
 (0)