Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ea501d

Browse files
Add return types to bridges
1 parent de2dd61 commit 1ea501d

Some content is hidden

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

41 files changed

+103
-162
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ public function __construct(ManagerRegistry $registry)
3333

3434
/**
3535
* This cache warmer is not optional, without proxies fatal error occurs!
36-
*
37-
* @return bool
3836
*/
39-
public function isOptional()
37+
public function isOptional(): bool
4038
{
4139
return false;
4240
}
@@ -46,7 +44,7 @@ public function isOptional()
4644
*
4745
* @return string[] A list of files to preload on PHP 7.4+
4846
*/
49-
public function warmUp(string $cacheDir)
47+
public function warmUp(string $cacheDir): array
5048
{
5149
$files = [];
5250
foreach ($this->registry->getManagers() as $em) {

src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ public function __construct(ContainerInterface $container, array $subscriberIds
4646

4747
/**
4848
* {@inheritdoc}
49-
*
50-
* @return void
5149
*/
52-
public function dispatchEvent($eventName, EventArgs $eventArgs = null)
50+
public function dispatchEvent($eventName, EventArgs $eventArgs = null): void
5351
{
5452
if (!$this->initializedSubscribers) {
5553
$this->initializeSubscribers();
@@ -74,7 +72,7 @@ public function dispatchEvent($eventName, EventArgs $eventArgs = null)
7472
*
7573
* @return object[][]
7674
*/
77-
public function getListeners($event = null)
75+
public function getListeners($event = null): array
7876
{
7977
if (!$this->initializedSubscribers) {
8078
$this->initializeSubscribers();
@@ -98,10 +96,8 @@ public function getListeners($event = null)
9896

9997
/**
10098
* {@inheritdoc}
101-
*
102-
* @return bool
10399
*/
104-
public function hasListeners($event)
100+
public function hasListeners($event): bool
105101
{
106102
if (!$this->initializedSubscribers) {
107103
$this->initializeSubscribers();
@@ -112,10 +108,8 @@ public function hasListeners($event)
112108

113109
/**
114110
* {@inheritdoc}
115-
*
116-
* @return void
117111
*/
118-
public function addEventListener($events, $listener)
112+
public function addEventListener($events, $listener): void
119113
{
120114
if (!$this->initializedSubscribers) {
121115
$this->initializeSubscribers();
@@ -138,10 +132,8 @@ public function addEventListener($events, $listener)
138132

139133
/**
140134
* {@inheritdoc}
141-
*
142-
* @return void
143135
*/
144-
public function removeEventListener($events, $listener)
136+
public function removeEventListener($events, $listener): void
145137
{
146138
if (!$this->initializedSubscribers) {
147139
$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 & 18 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();
@@ -300,11 +300,9 @@ protected function loadObjectManagerCacheDriver(array $objectManager, ContainerB
300300
/**
301301
* Loads a cache driver.
302302
*
303-
* @return string
304-
*
305303
* @throws \InvalidArgumentException
306304
*/
307-
protected function loadCacheDriver(string $cacheName, string $objectManagerName, array $cacheDriver, ContainerBuilder $container)
305+
protected function loadCacheDriver(string $cacheName, string $objectManagerName, array $cacheDriver, ContainerBuilder $container): string
308306
{
309307
$cacheDriverServiceId = $this->getObjectManagerElementName($objectManagerName.'_'.$cacheName);
310308

@@ -381,7 +379,7 @@ protected function loadCacheDriver(string $cacheName, string $objectManagerName,
381379
*
382380
* @return array The modified version of $managerConfigs
383381
*/
384-
protected function fixManagersAutoMappings(array $managerConfigs, array $bundles)
382+
protected function fixManagersAutoMappings(array $managerConfigs, array $bundles): array
385383
{
386384
if ($autoMappedManager = $this->validateAutoMapping($managerConfigs)) {
387385
foreach (array_keys($bundles) as $bundle) {
@@ -405,33 +403,25 @@ protected function fixManagersAutoMappings(array $managerConfigs, array $bundles
405403
* Prefixes the relative dependency injection container path with the object manager prefix.
406404
*
407405
* @example $name is 'entity_manager' then the result would be 'doctrine.orm.entity_manager'
408-
*
409-
* @return string
410406
*/
411-
abstract protected function getObjectManagerElementName(string $name);
407+
abstract protected function getObjectManagerElementName(string $name): string;
412408

413409
/**
414410
* Noun that describes the mapped objects such as Entity or Document.
415411
*
416412
* Will be used for autodetection of persistent objects directory.
417-
*
418-
* @return string
419413
*/
420-
abstract protected function getMappingObjectDefaultName();
414+
abstract protected function getMappingObjectDefaultName(): string;
421415

422416
/**
423417
* Relative path from the bundle root to the directory where mapping files reside.
424-
*
425-
* @return string
426418
*/
427-
abstract protected function getMappingResourceConfigDirectory();
419+
abstract protected function getMappingResourceConfigDirectory(): string;
428420

429421
/**
430422
* Extension used by the mapping files.
431-
*
432-
* @return string
433423
*/
434-
abstract protected function getMappingResourceExtension();
424+
abstract protected function getMappingResourceExtension(): string;
435425

436426
/**
437427
* 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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\Persistence\ManagerRegistry;
1515
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
1616
use Symfony\Component\Form\AbstractExtension;
17+
use Symfony\Component\Form\FormTypeGuesserInterface;
1718

1819
class DoctrineOrmExtension extends AbstractExtension
1920
{
@@ -24,14 +25,14 @@ public function __construct(ManagerRegistry $registry)
2425
$this->registry = $registry;
2526
}
2627

27-
protected function loadTypes()
28+
protected function loadTypes(): array
2829
{
2930
return [
3031
new EntityType($this->registry),
3132
];
3233
}
3334

34-
protected function loadTypeGuesser()
35+
protected function loadTypeGuesser(): ?FormTypeGuesserInterface
3536
{
3637
return new DoctrineOrmTypeGuesser($this->registry);
3738
}

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)) {

src/Symfony/Bridge/Doctrine/Form/EventListener/MergeDoctrineCollectionListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
class MergeDoctrineCollectionListener implements EventSubscriberInterface
2929
{
30-
public static function getSubscribedEvents()
30+
public static function getSubscribedEvents(): array
3131
{
3232
// Higher priority than core MergeCollectionListener so that this one
3333
// is called before

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,10 @@ public function configureOptions(OptionsResolver $resolver)
229229

230230
/**
231231
* Return the default loader object.
232-
*
233-
* @return EntityLoaderInterface
234232
*/
235-
abstract public function getLoader(ObjectManager $manager, object $queryBuilder, string $class);
233+
abstract public function getLoader(ObjectManager $manager, object $queryBuilder, string $class): EntityLoaderInterface;
236234

237-
/**
238-
* @return string
239-
*/
240-
public function getParent()
235+
public function getParent(): string
241236
{
242237
return ChoiceType::class;
243238
}

src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ public function configureOptions(OptionsResolver $resolver)
4747
* Return the default loader object.
4848
*
4949
* @param QueryBuilder $queryBuilder
50-
*
51-
* @return ORMQueryBuilderLoader
5250
*/
53-
public function getLoader(ObjectManager $manager, object $queryBuilder, string $class)
51+
public function getLoader(ObjectManager $manager, object $queryBuilder, string $class): ORMQueryBuilderLoader
5452
{
5553
if (!$queryBuilder instanceof QueryBuilder) {
5654
throw new \TypeError(sprintf('Expected an instance of "%s", but got "%s".', QueryBuilder::class, get_debug_type($queryBuilder)));
@@ -62,7 +60,7 @@ public function getLoader(ObjectManager $manager, object $queryBuilder, string $
6260
/**
6361
* {@inheritdoc}
6462
*/
65-
public function getBlockPrefix()
63+
public function getBlockPrefix(): string
6664
{
6765
return 'entity';
6866
}

src/Symfony/Bridge/Doctrine/Logger/DbalLogger.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ public function __construct(LoggerInterface $logger = null, Stopwatch $stopwatch
3434

3535
/**
3636
* {@inheritdoc}
37-
*
38-
* @return void
3937
*/
40-
public function startQuery($sql, array $params = null, array $types = null)
38+
public function startQuery($sql, array $params = null, array $types = null): void
4139
{
4240
if (null !== $this->stopwatch) {
4341
$this->stopwatch->start('doctrine', 'doctrine');
@@ -50,10 +48,8 @@ public function startQuery($sql, array $params = null, array $types = null)
5048

5149
/**
5250
* {@inheritdoc}
53-
*
54-
* @return void
5551
*/
56-
public function stopQuery()
52+
public function stopQuery(): void
5753
{
5854
if (null !== $this->stopwatch) {
5955
$this->stopwatch->stop('doctrine');

0 commit comments

Comments
 (0)