Skip to content

Commit 9e6b251

Browse files
[Config] Reduce the size of serialized resource checkers
1 parent 489512f commit 9e6b251

File tree

8 files changed

+37
-15
lines changed

8 files changed

+37
-15
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ public function isFresh(int $timestamp): bool
101101
return $this->exists[0] xor !$exists[0];
102102
}
103103

104-
/**
105-
* @internal
106-
*/
107104
public function __serialize(): array
108105
{
109106
if (null === $this->exists) {
@@ -116,9 +113,6 @@ public function __serialize(): array
116113
];
117114
}
118115

119-
/**
120-
* @internal
121-
*/
122116
public function __unserialize(array $data): void
123117
{
124118
$this->resource = array_shift($data);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ public function isFresh(int $timestamp): bool
4747
return array_values(self::$runtimeVendors) === array_values($this->vendors);
4848
}
4949

50+
public function __serialize(): array
51+
{
52+
return [
53+
'vendors' => $this->vendors,
54+
];
55+
}
56+
5057
private static function refresh(): void
5158
{
5259
self::$runtimeVendors = [];

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,12 @@ public function isFresh(int $timestamp): bool
9393

9494
return true;
9595
}
96+
97+
public function __serialize(): array
98+
{
99+
return [
100+
'resource' => $this->resource,
101+
'pattern' => $this->pattern,
102+
];
103+
}
96104
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ public function isFresh(int $timestamp): bool
4848
{
4949
return file_exists($this->resource) === $this->exists;
5050
}
51+
52+
public function __serialize(): array
53+
{
54+
return [
55+
'resource' => $this->resource,
56+
'exists' => $this->exists,
57+
];
58+
}
5159
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,11 @@ public function isFresh(int $timestamp): bool
5757
{
5858
return false !== ($filemtime = @filemtime($this->resource)) && $filemtime <= $timestamp;
5959
}
60+
61+
public function __serialize(): array
62+
{
63+
return [
64+
'resource' => $this->resource,
65+
];
66+
}
6067
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ public function isFresh(int $timestamp): bool
7676
return $this->hash === $hash;
7777
}
7878

79-
/**
80-
* @internal
81-
*/
8279
public function __serialize(): array
8380
{
8481
$this->hash ??= $this->computeHash();
@@ -93,9 +90,6 @@ public function __serialize(): array
9390
];
9491
}
9592

96-
/**
97-
* @internal
98-
*/
9993
public function __unserialize(array $data): void
10094
{
10195
$this->prefix = array_shift($data);

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@ public function __toString(): string
5959
return 'reflection.'.$this->className;
6060
}
6161

62-
/**
63-
* @internal
64-
*/
6562
public function __serialize(): array
6663
{
6764
if (!isset($this->hash)) {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,11 @@ public function isFresh(ResourceInterface $resource, int $timestamp): bool
3434
{
3535
return true;
3636
}
37+
38+
public function __serialize(): array
39+
{
40+
return [
41+
'skippedResourceTypes' => $this->skippedResourceTypes,
42+
];
43+
}
3744
}

0 commit comments

Comments
 (0)