Skip to content

Commit 2c0ad1e

Browse files
jrushlowweaverryan
authored andcommitted
add return types for symfony 6
1 parent 9862577 commit 2c0ad1e

33 files changed

+113
-139
lines changed

src/Command/MakerCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ public function __construct(MakerInterface $maker, FileManager $fileManager, Gen
5050
parent::__construct();
5151
}
5252

53-
protected function configure()
53+
protected function configure(): void
5454
{
5555
$this->maker->configureCommand($this, $this->inputConfig);
5656
}
5757

58-
protected function initialize(InputInterface $input, OutputInterface $output)
58+
protected function initialize(InputInterface $input, OutputInterface $output): void
5959
{
6060
$this->io = new ConsoleStyle($input, $output);
6161
$this->fileManager->setIO($this->io);
@@ -74,7 +74,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
7474
}
7575
}
7676

77-
protected function interact(InputInterface $input, OutputInterface $output)
77+
protected function interact(InputInterface $input, OutputInterface $output): void
7878
{
7979
if (!$this->fileManager->isNamespaceConfiguredToAutoload($this->generator->getRootNamespace())) {
8080
$this->io->note([
@@ -111,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
111111
return 0;
112112
}
113113

114-
public function setApplication(Application $application = null)
114+
public function setApplication(Application $application = null): void
115115
{
116116
parent::setApplication($application);
117117

@@ -127,7 +127,7 @@ public function setApplication(Application $application = null)
127127
/**
128128
* @internal Used for testing commands
129129
*/
130-
public function setCheckDependencies(bool $checkDeps)
130+
public function setCheckDependencies(bool $checkDeps): void
131131
{
132132
$this->checkDependencies = $checkDeps;
133133
}

src/ConsoleStyle.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ public function __construct(InputInterface $input, OutputInterface $output)
3030
parent::__construct($input, $output);
3131
}
3232

33-
public function success($message)
33+
public function success($message): void
3434
{
3535
$this->writeln('<fg=green;options=bold,underscore>OK</> '.$message);
3636
}
3737

38-
public function comment($message)
38+
public function comment($message): void
3939
{
4040
$this->text($message);
4141
}

src/DependencyBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class DependencyBuilder
2525
* the user if other required dependencies are missing. An example
2626
* is the "validator" when trying to work with forms.
2727
*/
28-
public function addClassDependency(string $class, string $package, bool $required = true, bool $devDependency = false)
28+
public function addClassDependency(string $class, string $package, bool $required = true, bool $devDependency = false): void
2929
{
3030
if ($devDependency) {
3131
$this->devDependencies[] = [
@@ -42,7 +42,7 @@ public function addClassDependency(string $class, string $package, bool $require
4242
}
4343
}
4444

45-
public function requirePHP71()
45+
public function requirePHP71(): void
4646
{
4747
// no-op - MakerBundle now required PHP 7.1
4848
}

src/DependencyInjection/CompilerPass/MakeCommandRegistrationPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class MakeCommandRegistrationPass implements CompilerPassInterface
2525
{
2626
public const MAKER_TAG = 'maker.command';
2727

28-
public function process(ContainerBuilder $container)
28+
public function process(ContainerBuilder $container): void
2929
{
3030
foreach ($container->findTaggedServiceIds(self::MAKER_TAG) as $id => $tags) {
3131
$def = $container->getDefinition($id);

src/DependencyInjection/CompilerPass/RemoveMissingParametersPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class RemoveMissingParametersPass implements CompilerPassInterface
2323
{
24-
public function process(ContainerBuilder $container)
24+
public function process(ContainerBuilder $container): void
2525
{
2626
if (!$container->hasParameter('twig.default_path')) {
2727
$container->getDefinition('maker.file_manager')

src/DependencyInjection/CompilerPass/SetDoctrineAnnotatedPrefixesPass.php

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

2121
class SetDoctrineAnnotatedPrefixesPass implements CompilerPassInterface
2222
{
23-
public function process(ContainerBuilder $container)
23+
public function process(ContainerBuilder $container): void
2424
{
2525
$annotatedPrefixes = null;
2626

src/DependencyInjection/CompilerPass/SetDoctrineManagerRegistryClassPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class SetDoctrineManagerRegistryClassPass implements CompilerPassInterface
2222
{
23-
public function process(ContainerBuilder $container)
23+
public function process(ContainerBuilder $container): void
2424
{
2525
if ($container->hasAlias(ManagerRegistry::class)) {
2626
$definition = $container->getDefinition('maker.entity_class_generator');

src/DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Configuration implements ConfigurationInterface
1919
/**
2020
* {@inheritdoc}
2121
*/
22-
public function getConfigTreeBuilder()
22+
public function getConfigTreeBuilder(): TreeBuilder
2323
{
2424
$treeBuilder = new TreeBuilder('maker');
2525
if (method_exists($treeBuilder, 'getRootNode')) {

src/DependencyInjection/MakerExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MakerExtension extends Extension
3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function load(array $configs, ContainerBuilder $container)
37+
public function load(array $configs, ContainerBuilder $container): void
3838
{
3939
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
4040
$loader->load('services.xml');

src/Doctrine/BaseRelation.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,36 @@ abstract class BaseRelation
2626

2727
abstract public function isOwning(): bool;
2828

29-
public function getPropertyName()
29+
public function getPropertyName(): string
3030
{
3131
return $this->propertyName;
3232
}
3333

34-
public function setPropertyName($propertyName)
34+
public function setPropertyName(string $propertyName): self
3535
{
3636
$this->propertyName = $propertyName;
3737

3838
return $this;
3939
}
4040

41-
public function getTargetClassName()
41+
public function getTargetClassName(): string
4242
{
4343
return $this->targetClassName;
4444
}
4545

46-
public function setTargetClassName($targetClassName)
46+
public function setTargetClassName(string $targetClassName): self
4747
{
4848
$this->targetClassName = $targetClassName;
4949

5050
return $this;
5151
}
5252

53-
public function getTargetPropertyName()
53+
public function getTargetPropertyName(): ?string
5454
{
5555
return $this->targetPropertyName;
5656
}
5757

58-
public function setTargetPropertyName($targetPropertyName)
58+
public function setTargetPropertyName(?string $targetPropertyName): self
5959
{
6060
$this->targetPropertyName = $targetPropertyName;
6161

@@ -67,7 +67,7 @@ public function isSelfReferencing(): bool
6767
return $this->isSelfReferencing;
6868
}
6969

70-
public function setIsSelfReferencing(bool $isSelfReferencing)
70+
public function setIsSelfReferencing(bool $isSelfReferencing): self
7171
{
7272
$this->isSelfReferencing = $isSelfReferencing;
7373

@@ -79,7 +79,7 @@ public function getMapInverseRelation(): bool
7979
return $this->mapInverseRelation;
8080
}
8181

82-
public function setMapInverseRelation(bool $mapInverseRelation)
82+
public function setMapInverseRelation(bool $mapInverseRelation): self
8383
{
8484
$this->mapInverseRelation = $mapInverseRelation;
8585

@@ -91,7 +91,7 @@ public function shouldAvoidSetter(): bool
9191
return $this->avoidSetter;
9292
}
9393

94-
public function avoidSetter(bool $avoidSetter = true)
94+
public function avoidSetter(bool $avoidSetter = true): self
9595
{
9696
$this->avoidSetter = $avoidSetter;
9797

src/Doctrine/BaseSingleRelation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function isNullable(): bool
2727
return false;
2828
}
2929

30-
public function setIsNullable($isNullable)
30+
public function setIsNullable(bool $isNullable): self
3131
{
3232
$this->isNullable = $isNullable;
3333

src/Doctrine/DoctrineHelper.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,7 @@ public function getMetadata(string $classOrNamespace = null, bool $disconnected
213213
return $metadata;
214214
}
215215

216-
/**
217-
* @return EntityDetails|null
218-
*/
219-
public function createDoctrineDetails(string $entityClassName)
216+
public function createDoctrineDetails(string $entityClassName): ?EntityDetails
220217
{
221218
$metadata = $this->getMetadata($entityClassName);
222219

src/Doctrine/EntityDetails.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct($metadata)
3131
$this->metadata = $metadata;
3232
}
3333

34-
public function getRepositoryClass()
34+
public function getRepositoryClass(): ?string
3535
{
3636
return $this->metadata->customRepositoryClassName;
3737
}
@@ -41,12 +41,12 @@ public function getIdentifier()
4141
return $this->metadata->identifier[0];
4242
}
4343

44-
public function getDisplayFields()
44+
public function getDisplayFields(): array
4545
{
4646
return $this->metadata->fieldMappings;
4747
}
4848

49-
public function getFormFields()
49+
public function getFormFields(): array
5050
{
5151
$fields = (array) $this->metadata->fieldNames;
5252
// Remove the primary key field if it's not managed manually

src/Doctrine/EntityRegenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct(DoctrineHelper $doctrineHelper, FileManager $fileMan
4040
$this->overwrite = $overwrite;
4141
}
4242

43-
public function regenerateEntities(string $classOrNamespace)
43+
public function regenerateEntities(string $classOrNamespace): void
4444
{
4545
try {
4646
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace);
@@ -215,7 +215,7 @@ private function getPathOfClass(string $class): string
215215
return (new \ReflectionClass($class))->getFileName();
216216
}
217217

218-
private function generateRepository(ClassMetadata $metadata)
218+
private function generateRepository(ClassMetadata $metadata): void
219219
{
220220
if (!$metadata->customRepositoryClassName) {
221221
return;
@@ -235,7 +235,7 @@ private function generateRepository(ClassMetadata $metadata)
235235
$this->generator->writeChanges();
236236
}
237237

238-
private function getMappedFieldsInEntity(ClassMetadata $classMetadata)
238+
private function getMappedFieldsInEntity(ClassMetadata $classMetadata): array
239239
{
240240
/* @var $classReflection \ReflectionClass */
241241
$classReflection = $classMetadata->reflClass;

src/Doctrine/EntityRelation.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ public function __construct(string $type, string $owningClass, string $inverseCl
5555
$this->isSelfReferencing = $owningClass === $inverseClass;
5656
}
5757

58-
public function setOwningProperty(string $owningProperty)
58+
public function setOwningProperty(string $owningProperty): void
5959
{
6060
$this->owningProperty = $owningProperty;
6161
}
6262

63-
public function setInverseProperty(string $inverseProperty)
63+
public function setInverseProperty(string $inverseProperty): void
6464
{
6565
if (!$this->mapInverseRelation) {
6666
throw new \Exception('Cannot call setInverseProperty() when the inverse relation will not be mapped.');
@@ -69,12 +69,12 @@ public function setInverseProperty(string $inverseProperty)
6969
$this->inverseProperty = $inverseProperty;
7070
}
7171

72-
public function setIsNullable(bool $isNullable)
72+
public function setIsNullable(bool $isNullable): void
7373
{
7474
$this->isNullable = $isNullable;
7575
}
7676

77-
public function setOrphanRemoval(bool $orphanRemoval)
77+
public function setOrphanRemoval(bool $orphanRemoval): void
7878
{
7979
$this->orphanRemoval = $orphanRemoval;
8080
}

src/Doctrine/ORMDependencyBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class ORMDependencyBuilder
2323
/**
2424
* Central method to add dependencies needed for Doctrine ORM.
2525
*/
26-
public static function buildDependencies(DependencyBuilder $dependencies)
26+
public static function buildDependencies(DependencyBuilder $dependencies): void
2727
{
2828
$classes = [
2929
// guarantee DoctrineBundle

src/Doctrine/RelationManyToMany.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function isOwning(): bool
2525
return $this->isOwning;
2626
}
2727

28-
public function setIsOwning($isOwning)
28+
public function setIsOwning($isOwning): self
2929
{
3030
$this->isOwning = $isOwning;
3131

src/Doctrine/RelationOneToMany.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function getOrphanRemoval(): bool
2525
return $this->orphanRemoval;
2626
}
2727

28-
public function setOrphanRemoval($orphanRemoval)
28+
public function setOrphanRemoval($orphanRemoval): self
2929
{
3030
$this->orphanRemoval = $orphanRemoval;
3131

src/Doctrine/RelationOneToOne.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ public function isOwning(): bool
2525
return $this->isOwning;
2626
}
2727

28-
public function setIsOwning($isOwning)
28+
public function setIsOwning($isOwning): self
2929
{
3030
$this->isOwning = $isOwning;
3131

3232
return $this;
3333
}
3434

35-
public function getTargetGetterMethodName()
35+
public function getTargetGetterMethodName(): string
3636
{
3737
return 'get'.Str::asCamelCase($this->getTargetPropertyName());
3838
}
3939

40-
public function getTargetSetterMethodName()
40+
public function getTargetSetterMethodName(): string
4141
{
4242
return 'set'.Str::asCamelCase($this->getTargetPropertyName());
4343
}

src/Event/ConsoleErrorSubscriber.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class ConsoleErrorSubscriber implements EventSubscriberInterface
2727
{
2828
private $setExitCode = false;
2929

30-
public function onConsoleError(ConsoleErrorEvent $event)
30+
public function onConsoleError(ConsoleErrorEvent $event): void
3131
{
3232
if (!$event->getError() instanceof RuntimeCommandException) {
3333
return;
@@ -43,7 +43,7 @@ public function onConsoleError(ConsoleErrorEvent $event)
4343
$io->error($event->getError()->getMessage());
4444
}
4545

46-
public function onConsoleTerminate(ConsoleTerminateEvent $event)
46+
public function onConsoleTerminate(ConsoleTerminateEvent $event): void
4747
{
4848
if (!$this->setExitCode) {
4949
return;
@@ -53,7 +53,7 @@ public function onConsoleTerminate(ConsoleTerminateEvent $event)
5353
$event->setExitCode(1);
5454
}
5555

56-
public static function getSubscribedEvents()
56+
public static function getSubscribedEvents(): array
5757
{
5858
return [
5959
ConsoleEvents::ERROR => 'onConsoleError',

src/EventRegistry.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function getAllActiveEvents(): array
123123
/**
124124
* Attempts to get the event class for a given event.
125125
*/
126-
public function getEventClassName(string $event)
126+
public function getEventClassName(string $event): ?string
127127
{
128128
// if the event is already a class name, use it
129129
if (class_exists($event)) {
@@ -169,7 +169,7 @@ public function getEventClassName(string $event)
169169
return null;
170170
}
171171

172-
public function listActiveEvents(array $events)
172+
public function listActiveEvents(array $events): array
173173
{
174174
foreach ($events as $key => $event) {
175175
$events[$key] = sprintf('%s (<fg=yellow>%s</>)', $event, self::$eventsMap[$event]);

0 commit comments

Comments
 (0)