Skip to content

Commit 7e1172f

Browse files
authored
Merge pull request #703 from driehle/feature/typed-properties
Use typed properties where possible
2 parents 1b1e451 + 83cc7f6 commit 7e1172f

Some content is hidden

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

49 files changed

+175
-416
lines changed

phpcs.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<arg name="cache" value=".phpcs.cache"/>
77
<arg name="colors"/>
88

9-
<!-- set minimal required PHP version (7.3) -->
10-
<config name="php_version" value="70300"/>
9+
<!-- set minimal required PHP version (7.4) -->
10+
<config name="php_version" value="70400"/>
1111

1212
<!-- Ignore warnings, show progress of the run and show sniff names -->
1313
<arg value="nps"/>

src/CliConfigurator.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,10 @@
2121

2222
class CliConfigurator
2323
{
24-
/** @var string */
25-
private $defaultObjectManagerName = 'doctrine.entitymanager.orm_default';
24+
private string $defaultObjectManagerName = 'doctrine.entitymanager.orm_default';
2625

2726
/** @var string[] */
28-
private $commands = [
27+
private array $commands = [
2928
'doctrine.dbal_cmd.runsql',
3029
'doctrine.dbal_cmd.reserved_words',
3130
'doctrine.orm_cmd.clear_cache_metadata',
@@ -46,7 +45,7 @@ class CliConfigurator
4645
];
4746

4847
/** @var string[] */
49-
private $migrationCommands = [
48+
private array $migrationCommands = [
5049
'doctrine.migrations_cmd.current',
5150
'doctrine.migrations_cmd.diff',
5251
'doctrine.migrations_cmd.dumpschema',
@@ -62,8 +61,7 @@ class CliConfigurator
6261
'doctrine.migrations_cmd.uptodate',
6362
];
6463

65-
/** @var ContainerInterface */
66-
private $container;
64+
private ContainerInterface $container;
6765

6866
public function __construct(ContainerInterface $container)
6967
{

src/Collector/MappingCollector.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ class MappingCollector implements CollectorInterface, AutoHideInterface, Seriali
2525
*/
2626
public const PRIORITY = 10;
2727

28-
/** @var string */
29-
protected $name;
28+
protected string $name;
3029

31-
/** @var ClassMetadataFactory|null */
32-
protected $classMetadataFactory = null;
30+
protected ?ClassMetadataFactory $classMetadataFactory = null;
3331

3432
/** @var ClassMetadata[] indexed by class name */
35-
protected $classes = [];
33+
protected array $classes = [];
3634

3735
public function __construct(ClassMetadataFactory $classMetadataFactory, string $name)
3836
{

src/Collector/SQLLoggerCollector.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ class SQLLoggerCollector implements CollectorInterface, AutoHideInterface
2121
*/
2222
public const PRIORITY = 10;
2323

24-
/** @var DebugStack */
25-
protected $sqlLogger;
24+
protected DebugStack $sqlLogger;
2625

27-
/** @var string */
28-
protected $name;
26+
protected string $name;
2927

3028
public function __construct(DebugStack $sqlLogger, string $name)
3129
{

src/Form/Annotation/DoctrineAnnotationListener.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
class DoctrineAnnotationListener extends AbstractListenerAggregate
2121
{
22-
/** @var ObjectManager */
23-
protected $objectManager;
22+
protected ObjectManager $objectManager;
2423

2524
public function __construct(ObjectManager $objectManager)
2625
{

src/Form/Annotation/EntityBasedFormBuilder.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ final class EntityBasedFormBuilder
3333
public const EVENT_EXCLUDE_FIELD = 'excludeField';
3434
public const EVENT_EXCLUDE_ASSOCIATION = 'excludeAssociation';
3535

36-
/** @var AbstractBuilder */
37-
protected $builder;
36+
protected AbstractBuilder $builder;
3837

39-
/** @var ObjectManager */
40-
protected $objectManager;
38+
protected ObjectManager $objectManager;
4139

4240
/**
4341
* Constructor. Ensures ObjectManager is present.

src/Options/Configuration.php

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -25,168 +25,148 @@ class Configuration extends DBALConfiguration
2525
* Set the cache key for the metadata cache. Cache key
2626
* is assembled as "doctrine.cache.{key}" and pulled from
2727
* service locator.
28-
*
29-
* @var string
3028
*/
31-
protected $metadataCache = 'array';
29+
protected string $metadataCache = 'array';
3230

3331
/**
3432
* Set the cache key for the query cache. Cache key
3533
* is assembled as "doctrine.cache.{key}" and pulled from
3634
* service locator.
37-
*
38-
* @var string
3935
*/
40-
protected $queryCache = 'array';
36+
protected string $queryCache = 'array';
4137

4238
/**
4339
* Set the cache key for the result cache. Cache key
4440
* is assembled as "doctrine.cache.{key}" and pulled from
4541
* service locator.
46-
*
47-
* @var string
4842
*/
49-
protected $resultCache = 'array';
43+
protected string $resultCache = 'array';
5044

5145
/**
5246
* Set the cache key for the hydration cache. Cache key
5347
* is assembled as "doctrine.cache.{key}" and pulled from
5448
* service locator.
55-
*
56-
* @var string
5749
*/
58-
protected $hydrationCache = 'array';
50+
protected string $hydrationCache = 'array';
5951

6052
/**
6153
* Set the driver key for the metadata driver. Driver key
6254
* is assembled as "doctrine.driver.{key}" and pulled from
6355
* service locator.
64-
*
65-
* @var string
6656
*/
67-
protected $driver = 'orm_default';
57+
protected string $driver = 'orm_default';
6858

6959
/**
7060
* Automatic generation of proxies (disable for production!)
71-
*
72-
* @var bool
7361
*/
74-
protected $generateProxies = true;
62+
protected bool $generateProxies = true;
7563

7664
/**
7765
* Proxy directory.
78-
*
79-
* @var string
8066
*/
81-
protected $proxyDir = 'data';
67+
protected string $proxyDir = 'data';
8268

8369
/**
8470
* Proxy namespace.
85-
*
86-
* @var string
8771
*/
88-
protected $proxyNamespace = 'DoctrineORMModule\Proxy';
72+
protected string $proxyNamespace = 'DoctrineORMModule\Proxy';
8973

9074
/**
9175
* Entity alias map.
9276
*
9377
* @var mixed[]
9478
*/
95-
protected $entityNamespaces = [];
79+
protected array $entityNamespaces = [];
9680

9781
/**
9882
* Keys must be function names and values the FQCN of the implementing class.
9983
* The function names will be case-insensitive in DQL.
10084
*
10185
* @var mixed[]
10286
*/
103-
protected $datetimeFunctions = [];
87+
protected array $datetimeFunctions = [];
10488

10589
/**
10690
* Keys must be function names and values the FQCN of the implementing class.
10791
* The function names will be case-insensitive in DQL.
10892
*
10993
* @var mixed[]
11094
*/
111-
protected $stringFunctions = [];
95+
protected array $stringFunctions = [];
11296

11397
/**
11498
* Keys must be function names and values the FQCN of the implementing class.
11599
* The function names will be case-insensitive in DQL.
116100
*
117101
* @var mixed[]
118102
*/
119-
protected $numericFunctions = [];
103+
protected array $numericFunctions = [];
120104

121105
/**
122106
* Keys must be the name of the custom filter and the value must be
123107
* the class name for the custom filter.
124108
*
125109
* @var mixed[]
126110
*/
127-
protected $filters = [];
111+
protected array $filters = [];
128112

129113
/**
130114
* Keys must be the name of the query and values the DQL query string.
131115
*
132116
* @var mixed[]
133117
*/
134-
protected $namedQueries = [];
118+
protected array $namedQueries = [];
135119

136120
/**
137121
* Keys must be the name of the query and the value is an array containing
138122
* the keys 'sql' for native SQL query string and 'rsm' for the Query\ResultSetMapping.
139123
*
140124
* @var mixed[]
141125
*/
142-
protected $namedNativeQueries = [];
126+
protected array $namedNativeQueries = [];
143127

144128
/**
145129
* Keys must be the name of the custom hydration method and the value must be
146130
* the class name for the custom hydrator
147131
*
148132
* @var mixed[]
149133
*/
150-
protected $customHydrationModes = [];
134+
protected array $customHydrationModes = [];
151135

152136
/**
153137
* Naming strategy or name of the naming strategy service to be set in ORM
154138
* configuration (if any)
155139
*
156140
* @var string|NamingStrategy|null
157141
*/
158-
protected $namingStrategy;
142+
protected $namingStrategy = null;
159143

160144
/**
161145
* Quote strategy or name of the quote strategy service to be set in ORM
162146
* configuration (if any)
163147
*
164148
* @var string|QuoteStrategy|null
165149
*/
166-
protected $quoteStrategy;
150+
protected $quoteStrategy = null;
167151

168152
/**
169153
* Default repository class
170-
*
171-
* @var string|null
172154
*/
173-
protected $defaultRepositoryClassName;
155+
protected ?string $defaultRepositoryClassName = null;
174156

175157
/**
176158
* Repository factory or name of the repository factory service to be set in ORM
177159
* configuration (if any)
178160
*
179161
* @var string|RepositoryFactory|null
180162
*/
181-
protected $repositoryFactory;
163+
protected $repositoryFactory = null;
182164

183165
/**
184166
* Class name of MetaData factory to be set in ORM.
185167
* The entityManager will create a new instance on construction.
186-
*
187-
* @var string
188168
*/
189-
protected $classMetadataFactoryName;
169+
protected ?string $classMetadataFactoryName = null;
190170

191171
/**
192172
* Entity listener resolver or service name of the entity listener resolver
@@ -196,23 +176,19 @@ class Configuration extends DBALConfiguration
196176
*
197177
* @var string|EntityListenerResolver|null
198178
*/
199-
protected $entityListenerResolver;
179+
protected $entityListenerResolver = null;
200180

201181
/**
202182
* Configuration for second level cache
203183
*
204184
* @link http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/second-level-cache.html
205-
*
206-
* @var SecondLevelCacheConfiguration|null
207185
*/
208-
protected $secondLevelCache;
186+
protected ?SecondLevelCacheConfiguration $secondLevelCache = null;
209187

210188
/**
211189
* Configuration option for the filter schema assets expression
212-
*
213-
* @var string|null
214190
*/
215-
protected $filterSchemaAssetsExpression;
191+
protected ?string $filterSchemaAssetsExpression = null;
216192

217193
/**
218194
* @param mixed[] $datetimeFunctions

src/Options/DBALConfiguration.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,21 @@ class DBALConfiguration extends AbstractOptions
1515
* Set the cache key for the result cache. Cache key
1616
* is assembled as "doctrine.cache.{key}" and pulled from
1717
* service locator.
18-
*
19-
* @var string
2018
*/
21-
protected $resultCache = 'array';
19+
protected string $resultCache = 'array';
2220

2321
/**
2422
* Set the class name of the SQL Logger, or null, to disable.
25-
*
26-
* @var string
2723
*/
28-
protected $sqlLogger = null;
24+
protected ?string $sqlLogger = null;
2925

3026
/**
3127
* Keys must be the name of the type identifier and value is
3228
* the class name of the Type
3329
*
3430
* @var mixed[]
3531
*/
36-
protected $types = [];
32+
protected array $types = [];
3733

3834
public function setResultCache(string $resultCache): void
3935
{

0 commit comments

Comments
 (0)