Skip to content
Closed
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
211 changes: 33 additions & 178 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 @@ -149,15 +149,12 @@ private function sendToElasticsearch(array $records): void
$this->wait(false);
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ public function __construct(array $mockedNamespaces = [])
}
}

public function __sleep()
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup()
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ protected function build(ContainerBuilder $container): void
$container->registerExtension(new TestDumpExtension());
}

public function __sleep(): array
public function __serialize(): array
{
return ['varDir', 'testCase', 'rootConfig', 'environment', 'debug'];
return [$this->varDir, $this->testCase, $this->rootConfig, $this->environment, $this->debug];
}

public function __wakeup(): void
public function __unserialize(array $data): void
{
foreach ($this as $k => $v) {
[$this->varDir, $this->testCase, $this->rootConfig, $this->environment, $this->debug] = $data;

foreach ($this as $v) {
if (\is_object($v)) {
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ public function getLogDir(): string
return $this->cacheDir;
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup(): void
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ public function getProjectDir(): string
return \dirname((new \ReflectionObject($this))->getFileName(), 2);
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup(): void
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
7 changes: 2 additions & 5 deletions src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,12 @@ public function reset()
$this->tags instanceof ResettableInterface && $this->tags->reset();
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

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

class NotUnserializable
{
public function __wakeup()
public function __unserialize(array $data): void
{
throw new \Exception(__CLASS__);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Cache/Tests/Psr16CacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ protected function isPruned(CacheInterface $cache, string $name): bool

class NotUnserializable
{
public function __wakeup()
public function __unserialize(array $data): void
{
throw new \Exception(__CLASS__);
}
Expand Down
7 changes: 2 additions & 5 deletions src/Symfony/Component/Cache/Traits/AbstractAdapterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,12 @@ public function reset(): void
$this->ids = [];
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
7 changes: 2 additions & 5 deletions src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,12 @@ private function scanHashDir(string $directory): \Generator
}
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
33 changes: 33 additions & 0 deletions src/Symfony/Component/Config/Resource/ClassExistenceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,39 @@
return $this->exists[0] xor !$exists[0];
}

/**
* @internal
*/
public function __serialize(): array
{
$data = [];
foreach ($this->__sleep() as $key) {
try {
if (($r = new \ReflectionProperty($this, $key))->isInitialized($this)) {
$data[$key] = $r->getValue($this);
}
} catch (\ReflectionException) {
$data[$key] = $this->$key;
}
}

return $data;
}

/**
* @internal
*/
public function __unserialize(array $data): void
{
\Closure::bind(function ($data) {
foreach ($data as $key => $value) {
$this->{("\0" === $key[0] ?? '') ? substr($key, 1 + strrpos($key, "\0")) : $key} = $value;

Check failure on line 130 in src/Symfony/Component/Config/Resource/ClassExistenceResource.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidArgument

src/Symfony/Component/Config/Resource/ClassExistenceResource.php:130:26: InvalidArgument: Isset only works with variables and array elements (see https://psalm.dev/004)

Check failure on line 130 in src/Symfony/Component/Config/Resource/ClassExistenceResource.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidArgument

src/Symfony/Component/Config/Resource/ClassExistenceResource.php:130:26: InvalidArgument: Isset only works with variables and array elements (see https://psalm.dev/004)
}

$this->__wakeup();
}, $this, static::class)($data);
}

/**
* @internal
*/
Expand Down
33 changes: 33 additions & 0 deletions src/Symfony/Component/Config/Resource/GlobResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,39 @@
return $this->hash === $hash;
}

/**
* @internal
*/
public function __serialize(): array
{
$data = [];
foreach ($this->__sleep() as $key) {
try {
if (($r = new \ReflectionProperty($this, $key))->isInitialized($this)) {
$data[$key] = $r->getValue($this);
}
} catch (\ReflectionException) {
$data[$key] = $this->$key;
}
}

return $data;
}

/**
* @internal
*/
public function __unserialize(array $data): void
{
\Closure::bind(function ($data) {
foreach ($data as $key => $value) {
$this->{("\0" === $key[0] ?? '') ? substr($key, 1 + strrpos($key, "\0")) : $key} = $value;

Check failure on line 106 in src/Symfony/Component/Config/Resource/GlobResource.php

View workflow job for this annotation

GitHub Actions / Psalm

InvalidArgument

src/Symfony/Component/Config/Resource/GlobResource.php:106:26: InvalidArgument: Isset only works with variables and array elements (see https://psalm.dev/004)
}

$this->__wakeup();
}, $this, static::class)($data);
}

/**
* @internal
*/
Expand Down
19 changes: 19 additions & 0 deletions src/Symfony/Component/Config/Resource/ReflectionClassResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,25 @@ public function __toString(): string
return 'reflection.'.$this->className;
}

/**
* @internal
*/
public function __serialize(): array
{
$data = [];
foreach ($this->__sleep() as $key) {
try {
if (($r = new \ReflectionProperty($this, $key))->isInitialized($this)) {
$data[$key] = $r->getValue($this);
}
} catch (\ReflectionException) {
$data[$key] = $this->$key;
}
}

return $data;
}

/**
* @internal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ public function __call(string $method, array $args)
throw new \BadMethodCallException(\sprintf('Call to undefined method "%s::%s()".', static::class, $method));
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
7 changes: 2 additions & 5 deletions src/Symfony/Component/ErrorHandler/BufferingLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ public function cleanLogs(): array
return $logs;
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public function format(string $file, int $line): string|bool
/**
* @internal
*/
public function __sleep(): array
public function __serialize(): array
{
$this->fileLinkFormat = $this->getFileLinkFormat();

return ['fileLinkFormat'];
return ['fileLinkFormat' => $this->fileLinkFormat];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,25 @@ public function getData(): array|Data
return $this->data;
}

/**
* @internal
*/
public function __serialize(): array
{
$data = [];
foreach ($this->__sleep() as $key) {
try {
if (($r = new \ReflectionProperty($this, $key))->isInitialized($this)) {
$data[$key] = $r->getValue($this);
}
} catch (\ReflectionException) {
$data[$key] = $this->$key;
}
}

return $data;
}

/**
* @internal
*/
Expand Down
7 changes: 2 additions & 5 deletions src/Symfony/Component/Form/Util/OrderedHashMapIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,12 @@ public function __construct(array &$elements, array &$orderedKeys, array &$manag
$this->managedCursors[$this->cursorId] = &$this->cursor;
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
7 changes: 2 additions & 5 deletions src/Symfony/Component/HttpClient/Chunk/ErrorChunk.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,12 @@ public function didThrow(?bool $didThrow = null): bool
return $this->didThrow;
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
* @return void
*/
public function __wakeup()
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpClient/HttplugClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,12 @@ public function createUri($uri = ''): UriInterface
throw new \LogicException(\sprintf('You cannot use "%s()" as no PSR-17 factories have been found. Try running "composer require php-http/discovery psr/http-factory-implementation:*".', __METHOD__));
}

public function __sleep(): array
public function __serialize(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __wakeup(): void
public function __unserialize(array $data): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}
Expand Down
Loading
Loading