Skip to content

Commit

Permalink
Convert void return types to natives ones
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Jul 2, 2023
1 parent 5c8c659 commit 45060bd
Show file tree
Hide file tree
Showing 72 changed files with 111 additions and 1,469 deletions.
1,046 changes: 2 additions & 1,044 deletions .github/expected-missing-return-types.diff

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ public function __construct(
$this->managers = $registry->getManagerNames();
}

/**
* @return void
*/
public function collect(Request $request, Response $response, \Throwable $exception = null)
public function collect(Request $request, Response $response, \Throwable $exception = null): void
{
$this->data = [
'queries' => $this->collectQueries(),
Expand All @@ -62,10 +59,7 @@ private function collectQueries(): array
return $queries;
}

/**
* @return void
*/
public function reset()
public function reset(): void
{
$this->data = [];
$this->debugDataHolder->reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ abstract class AbstractDoctrineExtension extends Extension
/**
* @param array $objectManager A configured object manager
*
* @return void
*
* @throws \InvalidArgumentException
*/
protected function loadMappingInformation(array $objectManager, ContainerBuilder $container)
protected function loadMappingInformation(array $objectManager, ContainerBuilder $container): void
{
if ($objectManager['auto_mapping']) {
// automatically register bundle mappings
Expand Down Expand Up @@ -107,10 +105,8 @@ protected function loadMappingInformation(array $objectManager, ContainerBuilder
* Register the alias for this mapping driver.
*
* Aliases can be used in the Query languages of all the Doctrine object managers to simplify writing tasks.
*
* @return void
*/
protected function setMappingDriverAlias(array $mappingConfig, string $mappingName)
protected function setMappingDriverAlias(array $mappingConfig, string $mappingName): void
{
if (isset($mappingConfig['alias'])) {
$this->aliasMap[$mappingConfig['alias']] = $mappingConfig['prefix'];
Expand All @@ -122,11 +118,9 @@ protected function setMappingDriverAlias(array $mappingConfig, string $mappingNa
/**
* Register the mapping driver configuration for later use with the object managers metadata driver chain.
*
* @return void
*
* @throws \InvalidArgumentException
*/
protected function setMappingDriverConfig(array $mappingConfig, string $mappingName)
protected function setMappingDriverConfig(array $mappingConfig, string $mappingName): void
{
$mappingDirectory = $mappingConfig['dir'];
if (!is_dir($mappingDirectory)) {
Expand Down Expand Up @@ -178,10 +172,8 @@ protected function getMappingDriverBundleConfigDefaults(array $bundleConfig, \Re

/**
* Register all the collected mapping information with the object manager by registering the appropriate mapping drivers.
*
* @return void
*/
protected function registerMappingDrivers(array $objectManager, ContainerBuilder $container)
protected function registerMappingDrivers(array $objectManager, ContainerBuilder $container): void
{
// configure metadata driver for each bundle based on the type of mapping files found
if ($container->hasDefinition($this->getObjectManagerElementName($objectManager['name'].'_metadata_driver'))) {
Expand Down Expand Up @@ -235,11 +227,9 @@ protected function registerMappingDrivers(array $objectManager, ContainerBuilder
/**
* Assertion if the specified mapping information is valid.
*
* @return void
*
* @throws \InvalidArgumentException
*/
protected function assertValidMappingConfiguration(array $mappingConfig, string $objectManagerName)
protected function assertValidMappingConfiguration(array $mappingConfig, string $objectManagerName): void
{
if (!$mappingConfig['type'] || !$mappingConfig['dir'] || !$mappingConfig['prefix']) {
throw new \InvalidArgumentException(sprintf('Mapping definitions for Doctrine manager "%s" require at least the "type", "dir" and "prefix" options.', $objectManagerName));
Expand Down Expand Up @@ -325,11 +315,9 @@ private function detectMappingType(string $directory, ContainerBuilder $containe
/**
* Loads a configured object manager metadata, query or result cache driver.
*
* @return void
*
* @throws \InvalidArgumentException in case of unknown driver type
*/
protected function loadObjectManagerCacheDriver(array $objectManager, ContainerBuilder $container, string $cacheName)
protected function loadObjectManagerCacheDriver(array $objectManager, ContainerBuilder $container, string $cacheName): void
{
$this->loadCacheDriver($cacheName, $objectManager['name'], $objectManager[$cacheName.'_driver'], $container);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ public function __construct(string $managerType)
$this->managerType = $managerType;
}

/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
$this->updateValidatorMappingFiles($container, 'xml', 'xml');
$this->updateValidatorMappingFiles($container, 'yaml', 'yml');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ public function __construct(string $connectionsParameter, string $managerTemplat
$this->tagPrefix = $tagPrefix;
}

/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasParameter($this->connectionsParameter)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ public function __construct(Definition|Reference $driver, array $namespaces, arr

/**
* Register mappings and alias with the metadata drivers.
*
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$this->enabled($container)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ public function __construct(string $key, string $providerId)
$this->providerId = $providerId;
}

/**
* @return void
*/
public function create(ContainerBuilder $container, string $id, array $config)
public function create(ContainerBuilder $container, string $id, array $config): void
{
$container
->setDefinition($id, new ChildDefinition($this->providerId))
Expand All @@ -51,10 +48,7 @@ public function getKey(): string
return $this->key;
}

/**
* @return void
*/
public function addConfiguration(NodeDefinition $node)
public function addConfiguration(NodeDefinition $node): void
{
$node
->children()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ public static function getSubscribedEvents(): array
];
}

/**
* @return void
*/
public function onSubmit(FormEvent $event)
public function onSubmit(FormEvent $event): void
{
$collection = $event->getForm()->getData();
$data = $event->getData();
Expand Down
15 changes: 3 additions & 12 deletions src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,7 @@ public function __construct(ManagerRegistry $registry)
$this->registry = $registry;
}

/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if ($options['multiple'] && interface_exists(Collection::class)) {
$builder
Expand All @@ -110,10 +107,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}
}

/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$choiceLoader = function (Options $options) {
// Unless the choices are given explicitly, load them on demand
Expand Down Expand Up @@ -238,10 +232,7 @@ public function getParent(): string
return ChoiceType::class;
}

/**
* @return void
*/
public function reset()
public function reset(): void
{
$this->idReaders = [];
$this->entityLoaders = [];
Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@

class EntityType extends DoctrineType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,12 @@ public function __construct(ManagerRegistry $managerRegistry)
$this->managerRegistry = $managerRegistry;
}

/**
* @return void
*/
public function onWorkerMessageHandled()
public function onWorkerMessageHandled(): void
{
$this->clearEntityManagers();
}

/**
* @return void
*/
public function onWorkerMessageFailed()
public function onWorkerMessageFailed(): void
{
$this->clearEntityManagers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,15 @@ public function loadTokenBySeries(string $series): PersistentTokenInterface
return new PersistentToken($row['class'], $row['username'], $series, $row['value'], new \DateTime($row['last_used']));
}

/**
* @return void
*/
public function deleteTokenBySeries(string $series)
public function deleteTokenBySeries(string $series): void
{
$sql = 'DELETE FROM rememberme_token WHERE series=:series';
$paramValues = ['series' => $series];
$paramTypes = ['series' => ParameterType::STRING];
$this->conn->executeStatement($sql, $paramValues, $paramTypes);
}

/**
* @return void
*/
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed)
public function updateToken(string $series, #[\SensitiveParameter] string $tokenValue, \DateTime $lastUsed): void
{
$sql = 'UPDATE rememberme_token SET value=:value, lastUsed=:lastUsed WHERE series=:series';
$paramValues = [
Expand All @@ -92,10 +86,7 @@ public function updateToken(string $series, #[\SensitiveParameter] string $token
}
}

/**
* @return void
*/
public function createNewToken(PersistentTokenInterface $token)
public function createNewToken(PersistentTokenInterface $token): void
{
$sql = 'INSERT INTO rememberme_token (class, username, series, value, lastUsed) VALUES (:class, :username, :series, :value, :lastUsed)';
$paramValues = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ public function __construct(ManagerRegistry $registry)
/**
* @param object $entity
*
* @return void
*
* @throws UnexpectedTypeException
* @throws ConstraintDefinitionException
*/
public function validate(mixed $entity, Constraint $constraint)
public function validate(mixed $entity, Constraint $constraint): void
{
if (!$constraint instanceof UniqueEntity) {
throw new UnexpectedTypeException($constraint, UniqueEntity::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ public function __construct(ManagerRegistry $registry)
$this->registry = $registry;
}

/**
* @return void
*/
public function initialize(object $object)
public function initialize(object $object): void
{
$this->registry->getManagerForClass($object::class)?->initializeObject($object);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Symfony/Bridge/Monolog/Command/ServerLogCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,7 @@ public function isEnabled(): bool
return parent::isEnabled();
}

/**
* @return void
*/
protected function configure()
protected function configure(): void
{
if (!class_exists(ConsoleFormatter::class)) {
return;
Expand Down
12 changes: 3 additions & 9 deletions src/Symfony/Bridge/Monolog/Handler/ConsoleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,8 @@ private function doHandle(array|LogRecord $record): bool

/**
* Sets the console output to use for printing logs.
*
* @return void
*/
public function setOutput(OutputInterface $output)
public function setOutput(OutputInterface $output): void
{
$this->output = $output;
}
Expand All @@ -148,10 +146,8 @@ public function close(): void
/**
* Before a command is executed, the handler gets activated and the console output
* is set in order to know where to write the logs.
*
* @return void
*/
public function onCommand(ConsoleCommandEvent $event)
public function onCommand(ConsoleCommandEvent $event): void
{
$output = $event->getOutput();
if ($output instanceof ConsoleOutputInterface) {
Expand All @@ -163,10 +159,8 @@ public function onCommand(ConsoleCommandEvent $event)

/**
* After a command has been executed, it disables the output.
*
* @return void
*/
public function onTerminate(ConsoleTerminateEvent $event)
public function onTerminate(ConsoleTerminateEvent $event): void
{
$this->close();
}
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Bridge/Monolog/Handler/MailerHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ private function doWrite(array|LogRecord $record): void
*
* @param string $content formatted email body to be sent
* @param array $records the array of log records that formed this content
*
* @return void
*/
protected function send(string $content, array $records)
protected function send(string $content, array $records): void
{
$this->mailer->send($this->buildMessage($content, $records));
}
Expand Down
10 changes: 2 additions & 8 deletions src/Symfony/Bridge/Monolog/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ public function countErrors(Request $request = null): int
return 0;
}

/**
* @return void
*/
public function clear()
public function clear(): void
{
if ($logger = $this->getDebugLogger()) {
$logger->clear();
Expand All @@ -59,10 +56,7 @@ public function reset(): void
}
}

/**
* @return void
*/
public function removeDebugLogger()
public function removeDebugLogger(): void
{
foreach ($this->processors as $k => $processor) {
if ($processor instanceof DebugLoggerInterface) {
Expand Down

0 comments on commit 45060bd

Please sign in to comment.