8000 Add remaining missing return types to safe methods · symfony/symfony@978e623 · GitHub
[go: up one dir, main page]

Skip to content

Commit 978e623

Browse files
wouterjnicolas-grekas
authored andcommitted
Add remaining missing return types to safe methods
1 parent 4ee55b0 commit 978e623

File tree

52 files changed

+119
-145
lines changed

Some content is hidden

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

52 files changed

+119
-145
lines changed

.github/expected-missing-return-types.diff

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ index 8bfaa0a22c..745ba6aff3 100644
386386
{
387387
$this->debug = $debug;
388388
diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php
389-
index fe581b5987..8109e7c68d 100644
389+
index 43e4d9c9f1..ea0116870b 100644
390390
--- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php
391391
+++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php
392392
@@ -63,5 +63,5 @@ class DebugCommand extends Command
@@ -397,7 +397,7 @@ index fe581b5987..8109e7c68d 100644
397397
{
398398
$this
399399
diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php
400-
index fa8effc12a..deced50a90 100644
400+
index e059740a13..e7d6fbdd05 100644
401401
--- a/src/Symfony/Bridge/Twig/Command/LintCommand.php
402402
+++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php
403403
@@ -52,5 +52,5 @@ class LintCommand extends Command
@@ -1500,7 +1500,7 @@ index 00e912686b..58872ec2bc 100644
15001500
{
15011501
if (!$container->hasDefinition('console.command.cache_pool_prune')) {
15021502
diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php
1503-
index 2ee96e9b37..f49ed24f68 100644
1503+
index 200406a564..0bad73fe6a 100644
15041504
--- a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php
15051505
+++ b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php
15061506
@@ -81,5 +81,5 @@ trait FilesystemCommonTrait
@@ -5038,28 +5038,10 @@ index 9e107401a2..7f92321a2b 100644
50385038
+ protected function registerFunctions(): void
50395039
{
50405040
$this->addFunction(ExpressionFunction::fromPhp('constant'));
5041-
diff --git a/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php b/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php
5042-
index fec02abaae..7d02544275 100644
5043-
--- a/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php
5044-
+++ b/src/Symfony/Component/ExpressionLanguage/Node/ConditionalNode.php
5045-
@@ -41,5 +41,5 @@ class ConditionalNode extends Node
5046-
}
5047-
5048-
- public function evaluate(array $functions, array $values)
5049-
+ public function evaluate(array $functions, array $values): mixed
5050-
{
5051-
if ($this->nodes['expr1']->evaluate($functions, $values)) {
50525041
diff --git a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php b/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php
5053-
index d4ab3e0922..811fec7e2e 100644
5042+
index 33323f388f..811fec7e2e 100644
50545043
--- a/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php
50555044
+++ b/src/Symfony/Component/ExpressionLanguage/Node/FunctionNode.php
5056-
@@ -41,5 +41,5 @@ class FunctionNode extends Node
5057-
}
5058-
5059-
- public function evaluate(array $functions, array $values)
5060-
+ public function evaluate(array $functions, array $values): mixed
5061-
{
5062-
$arguments = [$values];
50635045
@@ -54,5 +54,5 @@ class FunctionNode extends Node
50645046
* @return array
50655047
*/
@@ -5106,17 +5088,6 @@ index f6fff09b1e..4661f7d165 100644
51065088
+ protected function isHash(array $value): bool
51075089
{
51085090
$expectedKey = 0;
5109-
diff --git a/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php b/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php
5110-
index 580ee13095..55e2121fcf 100644
5111-
--- a/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php
5112-
+++ b/src/Symfony/Component/ExpressionLanguage/Node/UnaryNode.php
5113-
@@ -46,5 +46,5 @@ class UnaryNode extends Node
5114-
}
5115-
5116-
- public function evaluate(array $functions, array $values)
5117-
+ public function evaluate(array $functions, array $values): mixed
5118-
{
5119-
$value = $this->nodes['node']->evaluate($functions, $values);
51205091
diff --git a/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php b/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php
51215092
index 239624ec2c..3b497d5ccf 100644
51225093
--- a/src/Symfony/Component/ExpressionLanguage/ParsedExpression.php
@@ -10730,7 +10701,7 @@ index cf41e0c507..61f7397734 100644
1073010701
+ public function createNewToken(PersistentTokenInterface $token): void;
1073110702
}
1073210703
diff --git a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php
10733-
index 4416cda616..0fcf4303e0 100644
10704+
index 10cb8f776e..0da1b3330e 100644
1073410705
--- a/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php
1073510706
+++ b/src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php
1073610707
@@ -57,5 +57,5 @@ abstract class AbstractToken implements TokenInterface, \Serializable
@@ -11173,17 +11144,6 @@ index 91271d14a3..100c2fb549 100644
1117311144
- public function start(Request $request, AuthenticationException $authException = null);
1117411145
+ public function start(Request $request, AuthenticationException $authException = null): Response;
1117511146
}
11176-
diff --git a/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php b/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php
11177-
index 46a25eed07..b3e25f1af3 100644
11178-
--- a/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php
11179-
+++ b/src/Symfony/Component/Security/Http/Event/LazyResponseEvent.php
11180-
@@ -32,5 +32,5 @@ final class LazyResponseEvent extends RequestEvent
11181-
}
11182-
11183-
- public function setResponse(Response $response)
11184-
+ public function setResponse(Response $response): void
11185-
{
11186-
$this->stopPropagation();
1118711147
diff --git a/src/Symfony/Component/Security/Http/Event/LoginFailureEvent.php b/src/Symfony/Component/Security/Http/Event/LoginFailureEvent.php
1118811148
index 3b7c5086f2..97fb99f0b5 100644
1118911149
--- a/src/Symfony/Component/Security/Http/Event/LoginFailureEvent.php
@@ -11238,17 +11198,6 @@ index fc56733efa..8538f5f821 100644
1123811198
+ protected function callListeners(RequestEvent $event, iterable $listeners): void
1123911199
{
1124011200
foreach ($listeners as $listener) {
11241-
diff --git a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php
11242-
index ad343ef085..9a1a2563c4 100644
11243-
--- a/src/Symfony/Component/Security/Http/Firewall/AccessListener.php
11244-
+++ b/src/Symfony/Component/Security/Http/Firewall/AccessListener.php
11245-
@@ -65,5 +65,5 @@ class AccessListener extends AbstractListener
11246-
* @throws AccessDeniedException
11247-
*/
11248-
- public function authenticate(RequestEvent $event)
11249-
+ public function authenticate(RequestEvent $event): void
11250-
{
11251-
$request = $event->getRequest();
1125211201
diff --git a/src/Symfony/Component/Security/Http/Firewall/FirewallListenerInterface.php b/src/Symfony/Component/Security/Http/Firewall/FirewallListenerInterface.php
1125311202
index be200c0d12..69483f8f1d 100644
1125411203
--- a/src/Symfony/Component/Security/Http/Firewall/FirewallListenerInterface.php

src/Symfony/Bridge/Monolog/Handler/NotifierHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private function notify(array $records): void
7171
$this->notifier->send($notification, ...$this->notifier->getAdminRecipients());
7272
}
7373

74-
private function getHighestRecord(array $records)
74+
private function getHighestRecord(array $records): array
7575
{
7676
$highestRecord = null;
7777
foreach ($records as $record) {

src/Symfony/Bridge/Monolog/Handler/ServerLogHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function getDefaultFormatter(): FormatterInterface
126126
return new VarDumperFormatter();
127127
}
128128

129-
private static function nullErrorHandler()
129+
private static function nullErrorHandler(): void
130130
{
131131
}
132132

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private function getLoaderPaths(string $name = null): array
305305
return $loaderPaths;
306306
}
307307

308-
private function getMetadata(string $type, mixed $entity)
308+
private function getMetadata(string $type, mixed $entity): mixed
309309
{
310310
if ('globals' === $type) {
311311
return $entity;

src/Symfony/Bridge/Twig/Command/LintCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private function getFilesInfo(array $filenames): array
143143
return $filesInfo;
144144
}
145145

146-
protected function findFiles(string $filename)
146+
protected function findFiles(string $filename): iterable
147147
{
148148
if (is_file($filename)) {
149149
return [$filename];
@@ -172,7 +172,7 @@ private function validate(string $template, string $file): array
172172
return ['template' => $template, 'file' => $file, 'valid' => true];
173173
}
174174

175-
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, array $files)
175+
private function display(InputInterface $input, OutputInterface $output, SymfonyStyle $io, array $files): int
176176
{
177177
return match ($this->format) {
178178
'txt' => $this->displayTxt($output, $io, $files),
@@ -205,7 +205,7 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $fi
205205
return min($errors, 1);
206206
}
207207

208-
private function displayJson(OutputInterface $output, array $filesInfo)
208+
private function displayJson(OutputInterface $output, array $filesInfo): int
209209
{
210210
$errors = 0;
211211

@@ -224,7 +224,7 @@ private function displayJson(OutputInterface $output, array $filesInfo)
224224
return min($errors, 1);
225225
}
226226

227-
private function renderException(SymfonyStyle $output, string $template, Error $exception, string $file = null, GithubActionReporter $githubReporter = null)
227+
private function renderException(SymfonyStyle $output, string $template, Error $exception, string $file = null, GithubActionReporter $githubReporter = null): void
228228
{
229229
$line = $exception->getTemplateLine();
230230

src/Symfony/Bridge/Twig/Extension/WorkflowExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function getMarkedPlaces(object $subject, bool $placesNameOnly = true, st
9999
* Use a string (the place name) to get place metadata
100100
* Use a Transition instance to get transition metadata
101101
*/
102-
public function getMetadata(object $subject, string $key, string|Transition $metadataSubject = null, string $name = null)
102+
public function getMetadata(object $subject, string $key, string|Transition $metadataSubject = null, string $name = null): mixed
103103
{
104104
return $this
105105
->workflowRegistry

src/Symfony/Bundle/FrameworkBundle/Command/ConfigDebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private function getAvailableBundles(bool $alias): array
237237
97AE return $availableBundles;
238238
}
239239

240-
private function getConfig(ExtensionInterface $extension, ContainerBuilder $container, bool $resolveEnvs = false)
240+
private function getConfig(ExtensionInterface $extension, ContainerBuilder $container, bool $resolveEnvs = false): mixed
241241
{
242242
return $container->resolveEnvPlaceholders(
243243
$container->getParameterBag()->resolveValue(

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ abstract protected function describeContainerEnvVars(array $envs, array $options
120120
* Common options are:
121121
* * name: name of listened event
122122
*/
123-
abstract protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []);
123+
abstract protected function describeEventDispatcherListeners(EventDispatcherInterface $eventDispatcher, array $options = []): void;
124124

125-
abstract protected function describeCallable(mixed $callable, array $options = []);
125+
abstract protected function describeCallable(mixed $callable, array $options = []): void;
126126

127127
protected function formatValue(mixed $value): string
128128
{

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ protected function describeEventDispatcherListeners(EventDispatcherInterface $ev
336336
}
337337
}
338338

339-
protected function describeCallable(mixed $callable, array $options = [])
339+
protected function describeCallable(mixed $callable, array $options = []): void
340340
{
341341
$string = '';
342342

@@ -359,7 +359,9 @@ protected function describeCallable(mixed $callable, array $options = [])
359359
}
360360
}
361361

362-
return $this->write($string."\n");
362+
$this->write($string."\n");
363+
364+
return;
363365
}
364366

365367
if (\is_string($callable)) {
@@ -375,15 +377,19 @@ protected function describeCallable(mixed $callable, array $options = [])
375377
$string .= "\n- Static: yes";
376378
}
377379

378-
return $this->write($string."\n");
380+
$this->write($string."\n");
381+
382+
return;
379383
}
380384

381385
if ($callable instanceof \Closure) {
382386
$string .= "\n- Type: `closure`";
383387

384388
$r = new \ReflectionFunction($callable);
385389
if (str_contains($r->name, '{closure}')) {
386-
return $this->write($string."\n");
390+
$this->write($string."\n");
391+
392+
return;
387393
}
388394
$string .= "\n".sprintf('- Name: `%s`', $r->name);
389395

@@ -394,14 +400,18 @@ protected function describeCallable(mixed $callable, array $options = [])
394400
}
395401
}
396402

397-
return $this->write($string."\n");
403+
$this->write($string."\n");
404+
405+
return;
398406
}
399407

400408
if (method_exists($callable, '__invoke')) {
401409
$string .= "\n- Type: `object`";
402410
$string .= "\n".sprintf('- Name: `%s`', $callable::class);
403411

404-
return $this->write($string."\n");
412+
$this->write($string."\n");
413+
414+
return;
405415
}
406416

407417
throw new \InvalidArgumentException('Callable is not describable.');

src/Symfony/Bundle/SecurityBundle/Debug/TraceableListenerTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ trait TraceableListenerTrait
3030
/**
3131
* Proxies all method calls to the original listener.
3232
*/
33-
public function __call(string $method, array $arguments)
33+
public function __call(string $method, array $arguments): mixed
3434
{
3535
return $this->listener->{$method}(...$arguments);
3636
}
3737

38-
public function getWrappedListener()
38+
public function getWrappedListener(): mixed
3939
{
4040
return $this->listener;
4141
}

src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private function hasHashOrNonce(array $directives): bool
233233
return false;
234234
}
235235

236-
private function getDirectiveFallback(array $directiveSet, string $type)
236+
private function getDirectiveFallback(array $directiveSet, string $type): ?array
237237
{
238238
if (\in_array($type, ['script-src-elem', 'style-src-elem'], true) || !isset($directiveSet['default-src'])) {
239239
// Let the browser fallback on it's own

src/Symfony/Component/Cache/LockRegistry.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static function setFiles(array $files): array
8383
return $previousFiles;
8484
}
8585

86-
public static function compute(callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata = null, LoggerInterface $logger = null)
86+
public static function compute(callable $callback, ItemInterface $item, bool &$save, CacheInterface $pool, \Closure $setMetadata = null, LoggerInterface $logger = null): mixed
8787
{
8888
if ('\\' === \DIRECTORY_SEPARATOR && null === self::$lockedFiles) {
8989
// disable locking on Windows by default
@@ -146,6 +146,9 @@ public static function compute(callable $callback, ItemInterface $item, bool &$s
146146
return null;
147147
}
148148

149+
/**
150+
* @return resource|false
151+
*/
149152
private static function open(int $key)
150153
{
151154
if (null !== $h = self::$openedFiles[$key] ?? null) {

src/Symfony/Component/Cache/Marshaller/DefaultMarshaller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function unmarshall(string $value): mixed
9191
/**
9292
* @internal
9393
*/
94-
public static function handleUnserializeCallback(string $class)
94+
public static function handleUnserializeCallback(string $class): never
9595
{
9696
throw new \DomainException('Class not found: '.$class);
9797
}

src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ protected function getId(mixed $key): string
367367
/**
368368
* @internal
369369
*/
370-
public static function handleUnserializeCallback(string $class)
370+
public static function handleUnserializeCallback(string $class): never
371371
{
372372
throw new \DomainException('Class not found: '.$class);
373373
}

src/Symfony/Component/Cache/Traits/ContractsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function setCallbackWrapper(?callable $callbackWrapper): callable
5959
return $previousWrapper;
6060
}
6161

62-
private function doGet(AdapterInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null)
62+
private function doGet(AdapterInterface $pool, string $key, callable $callback, ?float $beta, array &$metadata = null): mixed
6363
{
6464
if (0 > $beta ??= 1.0) {
6565
throw new InvalidArgumentException(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta));

src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait FilesystemCommonTrait
2323
private string $directory;
2424
private string $tmpSuffix;
2525

26-
private function init(string $namespace, ?string $directory)
26+
private function init(string $namespace, ?string $directory): void
2727
{
2828
if (!isset($directory[0])) {
2929
$directory = sys_get_temp_dir().\DIRECTORY_SEPARATOR.'symfony-cache';
@@ -161,7 +161,7 @@ private function scanHashDir(string $directory): \Generator
161161
/**
162162
* @internal
163163
*/
164-
public static function throwError(int $type, string $message, string $file, int $line)
164+
public static function throwError(int $type, string $message, string $file, int $line): never
165165
{
166166
throw new \ErrorException($message, 0, $type, $file, $line);
167167
}

src/Symfony/Component/Console/Descriptor/Descriptor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@ protected function write(string $content, bool $decorated = false): void
5050
/**
5151
* Describes an InputArgument instance.
5252
*/
53-
abstract protected function describeInputArgument(InputArgument $argument, array $options = []);
53+
abstract protected function describeInputArgument(InputArgument $argument, array $options = []): void;
5454

5555
/**
5656
* Describes an InputOption instance.
5757
*/
58-
abstract protected function describeInputOption(InputOption $option, array $options = []);
58+
abstract protected function describeInputOption(InputOption < B6C1 span class="pl-c1">$option, array $options = []): void;
5959

6060
/**
6161
* Describes an InputDefinition instance.
6262
*/
63-
abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []);
63+
abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []): void;
6464

6565
/**
6666
* Describes a Command instance.
6767
*/
68-
abstract protected function describeCommand(Command $command, array $options = []);
68+
abstract protected function describeCommand(Command $command, array $options = []): void;
6969

7070
/**
7171
* Describes an Application instance.
7272
*/
73-
abstract protected function describeApplication(Application $application, array $options = []);
73+
abstract protected function describeApplication(Application $application, array $options = []): void;
7474
}

0 commit comments

Comments
 (0)
0