Skip to content

Commit 9194a17

Browse files
Add return types everywhere possible
1 parent de2dd61 commit 9194a17

File tree

1,072 files changed

+3765
-3810
lines changed

Some content is hidden

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

1,072 files changed

+3765
-3810
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(ManagerRegistry $registry)
3636
*
3737
* @return bool
3838
*/
39-
public function isOptional()
39+
public function isOptional(): bool
4040
{
4141
return false;
4242
}
@@ -46,7 +46,7 @@ public function isOptional()
4646
*
4747
* @return string[] A list of files to preload on PHP 7.4+
4848
*/
49-
public function warmUp(string $cacheDir)
49+
public function warmUp(string $cacheDir): array
5050
{
5151
$files = [];
5252
foreach ($this->registry->getManagers() as $em) {

src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct(ContainerInterface $container, array $subscriberIds
4949
*
5050
* @return void
5151
*/
52-
public function dispatchEvent($eventName, EventArgs $eventArgs = null)
52+
public function dispatchEvent($eventName, EventArgs $eventArgs = null): void
5353
{
5454
if (!$this->initializedSubscribers) {
5555
$this->initializeSubscribers();
@@ -74,7 +74,7 @@ public function dispatchEvent($eventName, EventArgs $eventArgs = null)
7474
*
7575
* @return object[][]
7676
*/
77-
public function getListeners($event = null)
77+
public function getListeners($event = null): array
7878
{
7979
if (!$this->initializedSubscribers) {
8080
$this->initializeSubscribers();
@@ -101,7 +101,7 @@ public function getListeners($event = null)
101101
*
102102
* @return bool
103103
*/
104-
public function hasListeners($event)
104+
public function hasListeners($event): bool
105105
{
106106
if (!$this->initializedSubscribers) {
107107
$this->initializeSubscribers();
@@ -115,7 +115,7 @@ public function hasListeners($event)
115115
*
116116
* @return void
117117
*/
118-
public function addEventListener($events, $listener)
118+
public function addEventListener($events, $listener): void
119119
{
120120
if (!$this->initializedSubscribers) {
121121
$this->initializeSubscribers();
@@ -141,7 +141,7 @@ public function addEventListener($events, $listener)
141141
*
142142
* @return void
143143
*/
144-
public function removeEventListener($events, $listener)
144+
public function removeEventListener($events, $listener): void
145145
{
146146
if (!$this->initializedSubscribers) {
147147
$this->initializeSubscribers();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,15 @@ public function getTime()
114114
/**
115115
* {@inheritdoc}
116116
*/
117-
public function getName()
117+
public function getName(): string
118118
{
119119
return 'db';
120120
}
121121

122122
/**
123123
* {@inheritdoc}
124124
*/
125-
protected function getCasters()
125+
protected function getCasters(): array
126126
{
127127
return parent::getCasters() + [
128128
ObjectParameter::class => static function (ObjectParameter $o, array $a, Stub $s): array {

src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ protected function setMappingDriverConfig(array $mappingConfig, string $mappingN
152152
*
153153
* @return array|false
154154
*/
155-
protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \ReflectionClass $bundle, ContainerBuilder $container)
155+
protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \ReflectionClass $bundle, ContainerBuilder $container): array|false
156156
{
157157
$bundleDir = \dirname($bundle->getFileName());
158158

@@ -261,7 +261,7 @@ protected function assertValidMappingConfiguration(array $mappingConfig, string
261261
*
262262
* @return string|null A metadata driver short name, if one can be detected
263263
*/
264-
protected function detectMetadataDriver(string $dir, ContainerBuilder $container)
264+
protected function detectMetadataDriver(string $dir, ContainerBuilder $container): ?string
265265
{
266266
$configPath = $this->getMappingResourceConfigDirectory();
267267
$extension = $this->getMappingResourceExtension();
@@ -304,7 +304,7 @@ protected function loadObjectManagerCacheDriver(array $objectManager, ContainerB
304304
*
305305
* @throws \InvalidArgumentException
306306
*/
307-
protected function loadCacheDriver(string $cacheName, string $objectManagerName, array $cacheDriver, ContainerBuilder $container)
307+
protected function loadCacheDriver(string $cacheName, string $objectManagerName, array $cacheDriver, ContainerBuilder $container): string
308308
{
309309
$cacheDriverServiceId = $this->getObjectManagerElementName($objectManagerName.'_'.$cacheName);
310310

@@ -381,7 +381,7 @@ protected function loadCacheDriver(string $cacheName, string $objectManagerName,
381381
*
382382
* @return array The modified version of $managerConfigs
383383
*/
384-
protected function fixManagersAutoMappings(array $managerConfigs, array $bundles)
384+
protected function fixManagersAutoMappings(array $managerConfigs, array $bundles): array
385385
{
386386
if ($autoMappedManager = $this->validateAutoMapping($managerConfigs)) {
387387
foreach (array_keys($bundles) as $bundle) {
@@ -408,7 +408,7 @@ protected function fixManagersAutoMappings(array $managerConfigs, array $bundles
408408
*
409409
* @return string
410410
*/
411-
abstract protected function getObjectManagerElementName(string $name);
411+
abstract protected function getObjectManagerElementName(string $name): string;
412412

413413
/**
414414
* Noun that describes the mapped objects such as Entity or Document.
@@ -417,21 +417,21 @@ abstract protected function getObjectManagerElementName(string $name);
417417
*
418418
* @return string
419419
*/
420-
abstract protected function getMappingObjectDefaultName();
420+
abstract protected function getMappingObjectDefaultName(): string;
421421

422422
/**
423423
* Relative path from the bundle root to the directory where mapping files reside.
424424
*
425425
* @return string
426426
*/
427-
abstract protected function getMappingResourceConfigDirectory();
427+
abstract protected function getMappingResourceConfigDirectory(): string;
428428

429429
/**
430430
* Extension used by the mapping files.
431431
*
432432
* @return string
433433
*/
434-
abstract protected function getMappingResourceExtension();
434+
abstract protected function getMappingResourceExtension(): string;
435435

436436
/**
437437
* The class name used by the various mapping drivers.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function process(ContainerBuilder $container)
170170
* @throws InvalidArgumentException if non of the managerParameters has a
171171
* non-empty value
172172
*/
173-
protected function getChainDriverServiceName(ContainerBuilder $container)
173+
protected function getChainDriverServiceName(ContainerBuilder $container): string
174174
{
175175
return sprintf($this->driverPattern, $this->getManagerName($container));
176176
}
@@ -183,7 +183,7 @@ protected function getChainDriverServiceName(ContainerBuilder $container)
183183
*
184184
* @return Definition|Reference the metadata driver to add to all chain drivers
185185
*/
186-
protected function getDriver(ContainerBuilder $container)
186+
protected function getDriver(ContainerBuilder $container): Definition|Reference
187187
{
188188
return $this->driver;
189189
}
@@ -230,7 +230,7 @@ private function getManagerName(ContainerBuilder $container): string
230230
*
231231
* @return bool whether this compiler pass really should register the mappings
232232
*/
233-
protected function enabled(ContainerBuilder $container)
233+
protected function enabled(ContainerBuilder $container): bool
234234
{
235235
return !$this->enabledParameter || $container->hasParameter($this->enabledParameter);
236236
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ interface EntityLoaderInterface
2323
*
2424
* @return array The entities
2525
*/
26-
public function getEntities();
26+
public function getEntities(): array;
2727

2828
/**
2929
* Returns an array of entities matching the given identifiers.
3030
*
3131
* @return array The entities
3232
*/
33-
public function getEntitiesByIds(string $identifier, array $values);
33+
public function getEntitiesByIds(string $identifier, array $values): array;
3434
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ public function __construct(QueryBuilder $queryBuilder)
4141
/**
4242
* {@inheritdoc}
4343
*/
44-
public function getEntities()
44+
public function getEntities(): array
4545
{
4646
return $this->queryBuilder->getQuery()->execute();
4747
}
4848

4949
/**
5050
* {@inheritdoc}
5151
*/
52-
public function getEntitiesByIds(string $identifier, array $values)
52+
public function getEntitiesByIds(string $identifier, array $values): array
5353
{
5454
if (null !== $this->queryBuilder->getMaxResults() || null !== $this->queryBuilder->getFirstResult()) {
5555
// an offset or a limit would apply on results including the where clause with submitted id values

src/Symfony/Bridge/Doctrine/Form/DataTransformer/CollectionToArrayTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CollectionToArrayTransformer implements DataTransformerInterface
2828
*
2929
* @throws TransformationFailedException
3030
*/
31-
public function transform(mixed $collection)
31+
public function transform(mixed $collection): mixed
3232
{
3333
if (null === $collection) {
3434
return [];
@@ -54,7 +54,7 @@ public function transform(mixed $collection)
5454
*
5555
* @return Collection A collection of entities
5656
*/
57-
public function reverseTransform(mixed $array)
57+
public function reverseTransform(mixed $array): Collection
5858
{
5959
if ('' === $array || null === $array) {
6060
$array = [];

src/Symfony/Bridge/Doctrine/Form/DoctrineOrmExtension.php

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

1212
namespace Symfony\Bridge\Doctrine\Form;
1313

14+
use Symfony\Component\Form\FormTypeGuesserInterface;
15+
use Symfony\Component\Form\FormTypeInterface;
1416
use Doctrine\Persistence\ManagerRegistry;
1517
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
1618
use Symfony\Component\Form\AbstractExtension;
@@ -24,14 +26,14 @@ public function __construct(ManagerRegistry $registry)
2426
$this->registry = $registry;
2527
}
2628

27-
protected function loadTypes()
29+
protected function loadTypes(): array
2830
{
2931
return [
3032
new EntityType($this->registry),
3133
];
3234
}
3335

34-
protected function loadTypeGuesser()
36+
protected function loadTypeGuesser(): ?FormTypeGuesserInterface
3537
{
3638
return new DoctrineOrmTypeGuesser($this->registry);
3739
}

src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(ManagerRegistry $registry)
3636
/**
3737
* {@inheritdoc}
3838
*/
39-
public function guessType(string $class, string $property)
39+
public function guessType(string $class, string $property): ?TypeGuess
4040
{
4141
if (!$ret = $this->getMetadata($class)) {
4242
return new TypeGuess('Symfony\Component\Form\Extension\Core\Type\TextType', [], Guess::LOW_CONFIDENCE);
@@ -94,7 +94,7 @@ public function guessType(string $class, string $property)
9494
/**
9595
* {@inheritdoc}
9696
*/
97-
public function guessRequired(string $class, string $property)
97+
public function guessRequired(string $class, string $property): ?ValueGuess
9898
{
9999
$classMetadatas = $this->getMetadata($class);
100100

@@ -134,7 +134,7 @@ public function guessRequired(string $class, string $property)
134134
/**
135135
* {@inheritdoc}
136136
*/
137-
public function guessMaxLength(string $class, string $property)
137+
public function guessMaxLength(string $class, string $property): ?ValueGuess
138138
{
139139
$ret = $this->getMetadata($class);
140140
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {
@@ -155,7 +155,7 @@ public function guessMaxLength(string $class, string $property)
155155
/**
156156
* {@inheritdoc}
157157
*/
158-
public function guessPattern(string $class, string $property)
158+
public function guessPattern(string $class, string $property): ?ValueGuess
159159
{
160160
$ret = $this->getMetadata($class);
161161
if ($ret && isset($ret[0]->fieldMappings[$property]) && !$ret[0]->hasAssociation($property)) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy