Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add missing return types to magic methods #50842

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
Jul 5, 2023
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
390 changes: 360 additions & 30 deletions .github/expected-missing-return-types.diff

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion .github/patch-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ class_exists($class);
if (
$method->getReturnType()
|| str_contains($method->getDocComment(), '@return')
|| str_starts_with($method->getName(), '__')
|| '__construct' === $method->getName()
|| '__destruct' === $method->getName()
|| '__clone' === $method->getName()
|| $method->getDeclaringClass()->getName() !== $class
|| str_contains($method->getDeclaringClass()->getName(), '\\Test\\')
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ final class WrappedListener
{
use TraceableListenerTrait;

/**
* @param callable(RequestEvent):void $listener
*/
public function __construct(callable $listener)
{
$this->listener = $listener;
}

public function __invoke(RequestEvent $event)
public function __invoke(RequestEvent $event): void
{
$startTime = microtime(true);
($this->listener)($event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getListeners(): iterable
return [$this];
}

public function __invoke(RequestEvent $event)
public function __invoke(RequestEvent $event): void
{
$listeners = [];
$request = $event->getRequest();
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public function __construct(MessageBusInterface $bus, ReverseContainer $reverseC
$this->callbackWrapper = null === $callbackWrapper ? null : $callbackWrapper(...);
}

/**
* @return mixed
*/
public function __invoke(callable $callback, CacheItem $item, bool &$save, AdapterInterface $pool, \Closure $setMetadata, LoggerInterface $logger = null)
{
if (!$item->isHit() || null === $message = EarlyExpirationMessage::create($this->reverseContainer, $callback, $item, $pool)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public function __construct(ReverseContainer $reverseContainer)
$this->reverseContainer = $reverseContainer;
}

/**
* @return void
*/
public function __invoke(EarlyExpirationMessage $message)
{
$item = $message->getItem();
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Traits/ValueWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function __serialize(): array
return [$pack => $this->value] + ($this->metadata['tags'] ?? []);
}

public function __unserialize(array $data)
public function __unserialize(array $data): void
{
$pack = array_key_first($data);
$this->value = $data[$pack];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function __sleep(): array
/**
* @internal
*/
public function __wakeup()
public function __wakeup(): void
{
if (\is_bool($this->exists)) {
$this->exists = [$this->exists, null];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ abstract class AbstractConfigurator
/** @internal */
protected Definition|Alias|null $definition = null;

/**
* @return mixed
*/
public function __call(string $method, array $args)
{
if (method_exists($this, 'set'.$method)) {
Expand All @@ -48,6 +51,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/DependencyInjection/ServiceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public function get(string $id): mixed
}
}

/**
* @return mixed
*/
public function __invoke(string $id)
{
return isset($this->factories[$id]) ? $this->get($id) : null;
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/ErrorHandler/BufferingLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Form/Util/OrderedHashMapIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/HttpClient/Chunk/ErrorChunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/HttplugClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpClient/Response/AmpResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public function __sleep(): array
return ['data'];
}

/**
* @return void
*/
public function __wakeup()
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function __sleep(): array
/**
* @internal
*/
public function __wakeup()
public function __wakeup(): void
{
parent::__wakeup();

Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,9 @@ public function __sleep(): array
return ['environment', 'debug'];
}

/**
* @return void
*/
public function __wakeup()
{
if (\is_object($this->environment) || \is_object($this->debug)) {
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Ldap/Adapter/ExtLdap/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Mailer/Transport/Smtp/SmtpTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(
) {
}

public function __invoke(RedispatchMessage $message)
public function __invoke(RedispatchMessage $message): void
{
$this->bus->dispatch($message->envelope, [new TransportNamesStamp($message->transportNames)]);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Mime/Part/DataPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public function __sleep(): array
return ['_headers', '_parent', 'filename', 'mediaType'];
}

/**
* @return void
*/
public function __wakeup()
{
$r = new \ReflectionProperty(AbstractPart::class, 'headers');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Mime/Part/MessagePart.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __sleep(): array
return ['message'];
}

public function __wakeup()
public function __wakeup(): void
{
$this->__construct($this->message);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Mime/Part/TextPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ public function __sleep(): array
return ['_headers', 'body', 'charset', 'subtype', 'disposition', 'name', 'encoding'];
}

/**
* @return void
*/
public function __wakeup()
{
$r = new \ReflectionProperty(AbstractPart::class, 'headers');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/Pipes/UnixPipes.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/Pipes/WindowsPipes.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public function __sleep(): array
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function getAuthenticator(): AuthenticatorInterface
return $this->authenticator;
}

public function __call($method, $args)
public function __call($method, $args): mixed
{
return $this->authenticator->{$method}(...$args);
}
Expand Down
Loading