Skip to content

add return types for symfony 6 #963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Command/MakerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public function __construct(MakerInterface $maker, FileManager $fileManager, Gen
parent::__construct();
}

protected function configure()
protected function configure(): void
{
$this->maker->configureCommand($this, $this->inputConfig);
}

protected function initialize(InputInterface $input, OutputInterface $output)
protected function initialize(InputInterface $input, OutputInterface $output): void
{
$this->io = new ConsoleStyle($input, $output);
$this->fileManager->setIO($this->io);
Expand All @@ -74,7 +74,7 @@ protected function initialize(InputInterface $input, OutputInterface $output)
}
}

protected function interact(InputInterface $input, OutputInterface $output)
protected function interact(InputInterface $input, OutputInterface $output): void
{
if (!$this->fileManager->isNamespaceConfiguredToAutoload($this->generator->getRootNamespace())) {
$this->io->note([
Expand Down Expand Up @@ -111,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

public function setApplication(Application $application = null)
public function setApplication(Application $application = null): void
{
parent::setApplication($application);

Expand All @@ -127,7 +127,7 @@ public function setApplication(Application $application = null)
/**
* @internal Used for testing commands
*/
public function setCheckDependencies(bool $checkDeps)
public function setCheckDependencies(bool $checkDeps): void
{
$this->checkDependencies = $checkDeps;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ConsoleStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ public function __construct(InputInterface $input, OutputInterface $output)
parent::__construct($input, $output);
}

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

public function comment($message)
public function comment($message): void
{
$this->text($message);
}
Expand Down
4 changes: 2 additions & 2 deletions src/DependencyBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class DependencyBuilder
* the user if other required dependencies are missing. An example
* is the "validator" when trying to work with forms.
*/
public function addClassDependency(string $class, string $package, bool $required = true, bool $devDependency = false)
public function addClassDependency(string $class, string $package, bool $required = true, bool $devDependency = false): void
{
if ($devDependency) {
$this->devDependencies[] = [
Expand All @@ -42,7 +42,7 @@ public function addClassDependency(string $class, string $package, bool $require
}
}

public function requirePHP71()
public function requirePHP71(): void
{
// no-op - MakerBundle now required PHP 7.1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MakeCommandRegistrationPass implements CompilerPassInterface
{
public const MAKER_TAG = 'maker.command';

public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
foreach ($container->findTaggedServiceIds(self::MAKER_TAG) as $id => $tags) {
$def = $container->getDefinition($id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
class RemoveMissingParametersPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasParameter('twig.default_path')) {
$container->getDefinition('maker.file_manager')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class SetDoctrineAnnotatedPrefixesPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$annotatedPrefixes = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class SetDoctrineManagerRegistryClassPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if ($container->hasAlias(ManagerRegistry::class)) {
$definition = $container->getDefinition('maker.entity_class_generator');
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Configuration implements ConfigurationInterface
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('maker');
if (method_exists($treeBuilder, 'getRootNode')) {
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/MakerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class MakerExtension extends Extension
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
Expand Down
18 changes: 9 additions & 9 deletions src/Doctrine/BaseRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,36 @@ abstract class BaseRelation

abstract public function isOwning(): bool;

public function getPropertyName()
public function getPropertyName(): string
{
return $this->propertyName;
}

public function setPropertyName($propertyName)
public function setPropertyName(string $propertyName): self
{
$this->propertyName = $propertyName;

return $this;
}

public function getTargetClassName()
public function getTargetClassName(): string
{
return $this->targetClassName;
}

public function setTargetClassName($targetClassName)
public function setTargetClassName(string $targetClassName): self
{
$this->targetClassName = $targetClassName;

return $this;
}

public function getTargetPropertyName()
public function getTargetPropertyName(): ?string
{
return $this->targetPropertyName;
}

public function setTargetPropertyName($targetPropertyName)
public function setTargetPropertyName(?string $targetPropertyName): self
{
$this->targetPropertyName = $targetPropertyName;

Expand All @@ -67,7 +67,7 @@ public function isSelfReferencing(): bool
return $this->isSelfReferencing;
}

public function setIsSelfReferencing(bool $isSelfReferencing)
public function setIsSelfReferencing(bool $isSelfReferencing): self
{
$this->isSelfReferencing = $isSelfReferencing;

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

public function setMapInverseRelation(bool $mapInverseRelation)
public function setMapInverseRelation(bool $mapInverseRelation): self
{
$this->mapInverseRelation = $mapInverseRelation;

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

public function avoidSetter(bool $avoidSetter = true)
public function avoidSetter(bool $avoidSetter = true): self
{
$this->avoidSetter = $avoidSetter;

Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/BaseSingleRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function isNullable(): bool
return false;
}

public function setIsNullable($isNullable)
public function setIsNullable(bool $isNullable): self
{
$this->isNullable = $isNullable;

Expand Down
5 changes: 1 addition & 4 deletions src/Doctrine/DoctrineHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,7 @@ public function getMetadata(string $classOrNamespace = null, bool $disconnected
return $metadata;
}

/**
* @return EntityDetails|null
*/
public function createDoctrineDetails(string $entityClassName)
public function createDoctrineDetails(string $entityClassName): ?EntityDetails
{
$metadata = $this->getMetadata($entityClassName);

Expand Down
6 changes: 3 additions & 3 deletions src/Doctrine/EntityDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct($metadata)
$this->metadata = $metadata;
}

public function getRepositoryClass()
public function getRepositoryClass(): ?string
{
return $this->metadata->customRepositoryClassName;
}
Expand All @@ -41,12 +41,12 @@ public function getIdentifier()
return $this->metadata->identifier[0];
}

public function getDisplayFields()
public function getDisplayFields(): array
{
return $this->metadata->fieldMappings;
}

public function getFormFields()
public function getFormFields(): array
{
$fields = (array) $this->metadata->fieldNames;
// Remove the primary key field if it's not managed manually
Expand Down
6 changes: 3 additions & 3 deletions src/Doctrine/EntityRegenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __construct(DoctrineHelper $doctrineHelper, FileManager $fileMan
$this->overwrite = $overwrite;
}

public function regenerateEntities(string $classOrNamespace)
public function regenerateEntities(string $classOrNamespace): void
{
try {
$metadata = $this->doctrineHelper->getMetadata($classOrNamespace);
Expand Down Expand Up @@ -215,7 +215,7 @@ private function getPathOfClass(string $class): string
return (new \ReflectionClass($class))->getFileName();
}

private function generateRepository(ClassMetadata $metadata)
private function generateRepository(ClassMetadata $metadata): void
{
if (!$metadata->customRepositoryClassName) {
return;
Expand All @@ -235,7 +235,7 @@ private function generateRepository(ClassMetadata $metadata)
$this->generator->writeChanges();
}

private function getMappedFieldsInEntity(ClassMetadata $classMetadata)
private function getMappedFieldsInEntity(ClassMetadata $classMetadata): array
{
/* @var $classReflection \ReflectionClass */
$classReflection = $classMetadata->reflClass;
Expand Down
8 changes: 4 additions & 4 deletions src/Doctrine/EntityRelation.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public function __construct(string $type, string $owningClass, string $inverseCl
$this->isSelfReferencing = $owningClass === $inverseClass;
}

public function setOwningProperty(string $owningProperty)
public function setOwningProperty(string $owningProperty): void
{
$this->owningProperty = $owningProperty;
}

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

public function setIsNullable(bool $isNullable)
public function setIsNullable(bool $isNullable): void
{
$this->isNullable = $isNullable;
}

public function setOrphanRemoval(bool $orphanRemoval)
public function setOrphanRemoval(bool $orphanRemoval): void
{
$this->orphanRemoval = $orphanRemoval;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/ORMDependencyBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class ORMDependencyBuilder
/**
* Central method to add dependencies needed for Doctrine ORM.
*/
public static function buildDependencies(DependencyBuilder $dependencies)
public static function buildDependencies(DependencyBuilder $dependencies): void
{
$classes = [
// guarantee DoctrineBundle
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/RelationManyToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function isOwning(): bool
return $this->isOwning;
}

public function setIsOwning($isOwning)
public function setIsOwning($isOwning): self
{
$this->isOwning = $isOwning;

Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/RelationOneToMany.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getOrphanRemoval(): bool
return $this->orphanRemoval;
}

public function setOrphanRemoval($orphanRemoval)
public function setOrphanRemoval($orphanRemoval): self
{
$this->orphanRemoval = $orphanRemoval;

Expand Down
6 changes: 3 additions & 3 deletions src/Doctrine/RelationOneToOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ public function isOwning(): bool
return $this->isOwning;
}

public function setIsOwning($isOwning)
public function setIsOwning($isOwning): self
{
$this->isOwning = $isOwning;

return $this;
}

public function getTargetGetterMethodName()
public function getTargetGetterMethodName(): string
{
return 'get'.Str::asCamelCase($this->getTargetPropertyName());
}

public function getTargetSetterMethodName()
public function getTargetSetterMethodName(): string
{
return 'set'.Str::asCamelCase($this->getTargetPropertyName());
}
Expand Down
6 changes: 3 additions & 3 deletions src/Event/ConsoleErrorSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class ConsoleErrorSubscriber implements EventSubscriberInterface
{
private $setExitCode = false;

public function onConsoleError(ConsoleErrorEvent $event)
public function onConsoleError(ConsoleErrorEvent $event): void
{
if (!$event->getError() instanceof RuntimeCommandException) {
return;
Expand All @@ -43,7 +43,7 @@ public function onConsoleError(ConsoleErrorEvent $event)
$io->error($event->getError()->getMessage());
}

public function onConsoleTerminate(ConsoleTerminateEvent $event)
public function onConsoleTerminate(ConsoleTerminateEvent $event): void
{
if (!$this->setExitCode) {
return;
Expand All @@ -53,7 +53,7 @@ public function onConsoleTerminate(ConsoleTerminateEvent $event)
$event->setExitCode(1);
}

public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
ConsoleEvents::ERROR => 'onConsoleError',
Expand Down
4 changes: 2 additions & 2 deletions src/EventRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function getAllActiveEvents(): array
/**
* Attempts to get the event class for a given event.
*/
public function getEventClassName(string $event)
public function getEventClassName(string $event): ?string
{
// if the event is already a class name, use it
if (class_exists($event)) {
Expand Down Expand Up @@ -169,7 +169,7 @@ public function getEventClassName(string $event)
return null;
}

public function listActiveEvents(array $events)
public function listActiveEvents(array $events): array
{
foreach ($events as $key => $event) {
$events[$key] = sprintf('%s (<fg=yellow>%s</>)', $event, self::$eventsMap[$event]);
Expand Down
Loading