Skip to content

Commit a638b29

Browse files
Merge branch '6.4' into 7.3
* 6.4: Replace __sleep/wakeup() by __(un)serialize() for throwing and internal usages
2 parents 547c040 + f18dc59 commit a638b29

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

Resource/ClassExistenceResource.php

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

104-
/**
105-
* @internal
106-
*/
107-
public function __sleep(): array
104+
public function __serialize(): array
108105
{
109106
if (null === $this->exists) {
110107
$this->isFresh(0);
111108
}
112109

113-
return ['resource', 'exists'];
110+
return [
111+
'resource' => $this->resource,
112+
'exists' => $this->exists,
113+
];
114114
}
115115

116-
/**
117-
* @internal
118-
*/
119-
public function __wakeup(): void
116+
public function __unserialize(array $data): void
120117
{
118+
$this->resource = array_shift($data);
119+
$this->exists = array_shift($data);
120+
121121
if (\is_bool($this->exists)) {
122122
$this->exists = [$this->exists, null];
123123
}

Resource/GlobResource.php

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

79-
/**
80-
* @internal
81-
*/
82-
public function __sleep(): array
79+
public function __serialize(): array
8380
{
8481
$this->hash ??= $this->computeHash();
8582

86-
return ['prefix', 'pattern', 'recursive', 'hash', 'forExclusion', 'excludedPrefixes'];
83+
return [
84+
'prefix' => $this->prefix,
85+
'pattern' => $this->pattern,
86+
'recursive' => $this->recursive,
87+
'hash' => $this->hash,
88+
'forExclusion' => $this->forExclusion,
89+
'excludedPrefixes' => $this->excludedPrefixes,
90+
];
8791
}
8892

89-
/**
90-
* @internal
91-
*/
92-
public function __wakeup(): void
93+
public function __unserialize(array $data): void
9394
{
95+
$this->prefix = array_shift($data);
96+
$this->pattern = array_shift($data);
97+
$this->recursive = array_shift($data);
98+
$this->hash = array_shift($data);
99+
$this->forExclusion = array_shift($data);
100+
$this->excludedPrefixes = array_shift($data);
94101
$this->globBrace = \defined('GLOB_BRACE') ? \GLOB_BRACE : 0;
95102
}
96103

Resource/ReflectionClassResource.php

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

62-
/**
63-
* @internal
64-
*/
65-
public function __sleep(): array
62+
public function __serialize(): array
6663
{
6764
if (!isset($this->hash)) {
6865
$this->hash = $this->computeHash();
6966
$this->loadFiles($this->classReflector);
7067
}
7168

72-
return ['files', 'className', 'excludedVendors', 'hash'];
69+
return [
70+
'files' => $this->files,
71+
'className' => $this->className,
72+
'excludedVendors' => $this->excludedVendors,
73+
'hash' => $this->hash,
74+
];
7375
}
7476

7577
private function loadFiles(\ReflectionClass $class): void

0 commit comments

Comments
 (0)