Skip to content

Commit 6b27001

Browse files
wouterjnicolas-grekas
authored andcommitted
Add missing return types to magic methods
1 parent 3e172b3 commit 6b27001

Some content is hidden

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

48 files changed

+470
-49
lines changed

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

+360-30
Large diffs are not rendered by default.

.github/patch-types.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ class_exists($class);
7575
if (
7676
$method->getReturnType()
7777
|| str_contains($method->getDocComment(), '@return')
78-
|| str_starts_with($method->getName(), '__')
78+
|| '__construct' === $method->getName()
79+
|| '__destruct' === $method->getName()
80+
|| '__clone' === $method->getName()
7981
|| $method->getDeclaringClass()->getName() !== $class
8082
|| str_contains($method->getDeclaringClass()->getName(), '\\Test\\')
8183
) {

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

+3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ public function __sleep(): array
154154
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
155155
}
156156

157+
/**
158+
* @return void
159+
*/
157160
public function __wakeup()
158161
{
159162
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ final class WrappedListener
2424
{
2525
use TraceableListenerTrait;
2626

27+
/**
28+
* @param callable(RequestEvent):void $listener
29+
*/
2730
public function __construct(callable $listener)
2831
{
2932
$this->listener = $listener;
3033
}
3134

32-
public function __invoke(RequestEvent $event)
35+
public function __invoke(RequestEvent $event): void
3336
{
3437
$startTime = microtime(true);
3538
($this->listener)($event);

src/Symfony/Bundle/SecurityBundle/Security/LazyFirewallContext.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function getListeners(): iterable
3939
return [$this];
4040
}
4141

42-
public function __invoke(RequestEvent $event)
42+
public function __invoke(RequestEvent $event): void
4343
{
4444
$listeners = [];
4545
$request = $event->getRequest();

src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php

+3
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ public function __sleep(): array
295295
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
296296
}
297297

298+
/**
299+
* @return void
300+
*/
298301
public function __wakeup()
299302
{
300303
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Cache/Messenger/EarlyExpirationDispatcher.php

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function __construct(MessageBusInterface $bus, ReverseContainer $reverseC
3434
$this->callbackWrapper = null === $callbackWrapper ? null : $callbackWrapper(...);
3535
}
3636

37+
/**
38+
* @return mixed
39+
*/
3740
public function __invoke(callable $callback, CacheItem $item, bool &$save, AdapterInterface $pool, \Closure $setMetadata, LoggerInterface $logger = null)
3841
{
3942
if (!$item->isHit() || null === $message = EarlyExpirationMessage::create($this->reverseContainer, $callback, $item, $pool)) {

src/Symfony/Component/Cache/Messenger/EarlyExpirationHandler.php

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public function __construct(ReverseContainer $reverseContainer)
2828
$this->reverseContainer = $reverseContainer;
2929
}
3030

31+
/**
32+
* @return void
33+
*/
3134
public function __invoke(EarlyExpirationMessage $message)
3235
{
3336
$item = $message->getItem();

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

+3
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ public function __sleep(): array
283283
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
284284
}
285285

286+
/**
287+
* @return void
288+
*/
286289
public function __wakeup()
287290
{
288291
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

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

+3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ public function __sleep(): array
171171
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
172172
}
173173

174+
/**
175+
* @return void
176+
*/
174177
public function __wakeup()
175178
{
176179
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __serialize(): array
5555
return [$pack => $this->value] + ($this->metadata['tags'] ?? []);
5656
}
5757

58-
public function __unserialize(array $data)
58+
public function __unserialize(array $data): void
5959
{
6060
$pack = array_key_first($data);
6161
$this->value = $data[$pack];

src/Symfony/Component/Config/Resource/ClassExistenceResource.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function __sleep(): array
116116
/**
117117
* @internal
118118
*/
119-
public function __wakeup()
119+
public function __wakeup(): void
120120
{
121121
if (\is_bool($this->exists)) {
122122
$this->exists = [$this->exists, null];

src/Symfony/Component/DependencyInjection/Loader/Configurator/AbstractConfigurator.php

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ abstract class AbstractConfigurator
3434
/** @internal */
3535
protected Definition|Alias|null $definition = null;
3636

37+
/**
38+
* @return mixed
39+
*/
3740
public function __call(string $method, array $args)
3841
{
3942
if (method_exists($this, 'set'.$method)) {
@@ -48,6 +51,9 @@ public function __sleep(): array
4851
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
4952
}
5053

54+
/**
55+
* @return void
56+
*/
5157
public function __wakeup()
5258
{
5359
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/DependencyInjection/ServiceLocator.php

+3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public function get(string $id): mixed
6060
}
6161
}
6262

63+
/**
64+
* @return mixed
65+
*/
6366
public function __invoke(string $id)
6467
{
6568
return isset($this->factories[$id]) ? $this->get($id) : null;

src/Symfony/Component/ErrorHandler/BufferingLogger.php

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public function __sleep(): array
4040
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
4141
}
4242

43+
/**
44+
* @return void
45+
*/
4346
public function __wakeup()
4447
{
4548
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Form/Util/OrderedHashMapIterator.php

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ public function __sleep(): array
6262
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
6363
}
6464

65+
/**
66+
* @return void
67+
*/
6568
public function __wakeup()
6669
{
6770
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/HttpClient/Chunk/ErrorChunk.php

+3
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ public function __sleep(): array
9898
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
9999
}
100100

101+
/**
102+
* @return void
103+
*/
101104
public function __wakeup()
102105
{
103106
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/HttpClient/HttplugClient.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function __sleep(): array
251251
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
252252
}
253253

254-
public function __wakeup()
254+
public function __wakeup(): void
255255
{
256256
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
257257
}

src/Symfony/Component/HttpClient/Response/AmpResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function __sleep(): array
144144
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
145145
}
146146

147-
public function __wakeup()
147+
public function __wakeup(): void
148148
{
149149
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
150150
}

src/Symfony/Component/HttpClient/Response/CommonResponseTrait.php

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ public function __sleep(): array
122122
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
123123
}
124124

125+
/**
126+
* @return void
127+
*/
125128
public function __wakeup()
126129
{
127130
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/HttpClient/Response/TraceableResponse.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __sleep(): array
4949
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
5050
}
5151

52-
public function __wakeup()
52+
public function __wakeup(): void
5353
{
5454
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
5555
}

src/Symfony/Component/HttpKernel/DataCollector/DataCollector.php

+3
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ public function __sleep(): array
8282
return ['data'];
8383
}
8484

85+
/**
86+
* @return void
87+
*/
8588
public function __wakeup()
8689
{
8790
}

src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function __sleep(): array
167167
/**
168168
* @internal
169169
*/
170-
public function __wakeup()
170+
public function __wakeup(): void
171171
{
172172
parent::__wakeup();
173173

src/Symfony/Component/HttpKernel/Kernel.php

+3
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,9 @@ public function __sleep(): array
835835
return ['environment', 'debug'];
836836
}
837837

838+
/**
839+
* @return void
840+
*/
838841
public function __wakeup()
839842
{
840843
if (\is_object($this->environment) || \is_object($this->debug)) {

src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public function __sleep(): array
4646
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
4747
}
4848

49+
/**
50+
* @return void
51+
*/
4952
public function __wakeup()
5053
{
5154
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function __sleep(): array
3636
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
3737
}
3838

39+
/**
40+
* @return void
41+
*/
3942
public function __wakeup()
4043
{
4144
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Lock/Lock.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __sleep(): array
5454
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
5555
}
5656

57-
public function __wakeup()
57+
public function __wakeup(): void
5858
{
5959
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
6060
}

src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php

+3
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ public function __sleep(): array
377377
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
378378
}
379379

380+
/**
381+
* @return void
382+
*/
380383
public function __wakeup()
381384
{
382385
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public function __sleep(): array
7070
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
7171
}
7272

73+
/**
74+
* @return void
75+
*/
7376
public function __wakeup()
7477
{
7578
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/PostgreSqlConnection.php

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public function __sleep(): array
3838
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
3939
}
4040

41+
/**
42+
* @return void
43+
*/
4144
public function __wakeup()
4245
{
4346
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Messenger/Handler/RedispatchMessageHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(
2222
) {
2323
}
2424

25-
public function __invoke(RedispatchMessage $message)
25+
public function __invoke(RedispatchMessage $message): void
2626
{
2727
$this->bus->dispatch($message->envelope, [new TransportNamesStamp($message->transportNames)]);
2828
}

src/Symfony/Component/Mime/Part/DataPart.php

+3
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ public function __sleep(): array
146146
return ['_headers', '_parent', 'filename', 'mediaType'];
147147
}
148148

149+
/**
150+
* @return void
151+
*/
149152
public function __wakeup()
150153
{
151154
$r = new \ReflectionProperty(AbstractPart::class, 'headers');

src/Symfony/Component/Mime/Part/MessagePart.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function __sleep(): array
6565
return ['message'];
6666
}
6767

68-
public function __wakeup()
68+
public function __wakeup(): void
6969
{
7070
$this->__construct($this->message);
7171
}

src/Symfony/Component/Mime/Part/TextPart.php

+3
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,9 @@ public function __sleep(): array
236236
return ['_headers', 'body', 'charset', 'subtype', 'disposition', 'name', 'encoding'];
237237
}
238238

239+
/**
240+
* @return void
241+
*/
239242
public function __wakeup()
240243
{
241244
$r = new \ReflectionProperty(AbstractPart::class, 'headers');

src/Symfony/Component/Process/Pipes/UnixPipes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __sleep(): array
4040
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
4141
}
4242

43-
public function __wakeup()
43+
public function __wakeup(): void
4444
{
4545
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
4646
}

src/Symfony/Component/Process/Pipes/WindowsPipes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function __sleep(): array
9393
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
9494
}
9595

96-
public function __wakeup()
96+
public function __wakeup(): void
9797
{
9898
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
9999
}

src/Symfony/Component/Process/Process.php

+3
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ public function __sleep(): array
200200
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
201201
}
202202

203+
/**
204+
* @return void
205+
*/
203206
public function __wakeup()
204207
{
205208
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Routing/Loader/Configurator/CollectionConfigurator.php

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public function __sleep(): array
4343
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
4444
}
4545

46+
/**
47+
* @return void
48+
*/
4649
public function __wakeup()
4750
{
4851
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Routing/Loader/Configurator/ImportConfigurator.php

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public function __sleep(): array
3535
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
3636
}
3737

38+
/**
39+
* @return void
40+
*/
3841
public function __wakeup()
3942
{
4043
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);

src/Symfony/Component/Security/Http/Authenticator/Debug/TraceableAuthenticator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getAuthenticator(): AuthenticatorInterface
9797
return $this->authenticator;
9898
}
9999

100-
public function __call($method, $args)
100+
public function __call($method, $args): mixed
101101
{
102102
return $this->authenticator->{$method}(...$args);
103103
}

0 commit comments

Comments
 (0)