mirror of
https://github.com/itflow-org/itflow
synced 2026-08-22 23:45:11 +00:00
Allow PHP-8.2 and up Compatibility instead of just PHP-8.4
This commit is contained in:
121
plugins/vendor/symfony/mime/Part/SMimePart.php
vendored
121
plugins/vendor/symfony/mime/Part/SMimePart.php
vendored
@@ -18,6 +18,9 @@ use Symfony\Component\Mime\Header\Headers;
|
||||
*/
|
||||
class SMimePart extends AbstractPart
|
||||
{
|
||||
/** @internal, to be removed in 8.0 */
|
||||
protected Headers $_headers;
|
||||
|
||||
public function __construct(
|
||||
private iterable|string $body,
|
||||
private string $type,
|
||||
@@ -83,18 +86,35 @@ class SMimePart extends AbstractPart
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
// convert iterables to strings for serialization
|
||||
if (is_iterable($this->body)) {
|
||||
$this->body = $this->bodyToString();
|
||||
if (self::class === (new \ReflectionMethod($this, '__sleep'))->class || self::class !== (new \ReflectionMethod($this, '__serialize'))->class) {
|
||||
// convert iterables to strings for serialization
|
||||
if (is_iterable($this->body)) {
|
||||
$this->body = $this->bodyToString();
|
||||
}
|
||||
|
||||
return [
|
||||
'_headers' => $this->getHeaders(),
|
||||
'body' => $this->body,
|
||||
'type' => $this->type,
|
||||
'subtype' => $this->subtype,
|
||||
'parameters' => $this->parameters,
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
'_headers' => $this->getHeaders(),
|
||||
'body' => $this->body,
|
||||
'type' => $this->type,
|
||||
'subtype' => $this->subtype,
|
||||
'parameters' => $this->parameters,
|
||||
];
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
@@ -105,10 +125,81 @@ class SMimePart extends AbstractPart
|
||||
}
|
||||
}
|
||||
|
||||
parent::__unserialize(['headers' => $data['_headers'] ?? $data["\0*\0_headers"]]);
|
||||
$this->body = $data['body'] ?? $data["\0".self::class."\0body"];
|
||||
$this->type = $data['type'] ?? $data["\0".self::class."\0type"];
|
||||
$this->subtype = $data['subtype'] ?? $data["\0".self::class."\0subtype"];
|
||||
$this->parameters = $data['parameters'] ?? $data["\0".self::class."\0parameters"];
|
||||
if ($wakeup = self::class !== (new \ReflectionMethod($this, '__wakeup'))->class && self::class === (new \ReflectionMethod($this, '__unserialize'))->class) {
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Implementing "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
|
||||
}
|
||||
|
||||
if (['_headers', 'body', 'type', 'subtype', 'parameters'] === array_keys($data)) {
|
||||
parent::__unserialize(['headers' => $data['_headers']]);
|
||||
$this->body = $data['body'];
|
||||
$this->type = $data['type'];
|
||||
$this->subtype = $data['subtype'];
|
||||
$this->parameters = $data['parameters'];
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$p = "\0".self::class."\0";
|
||||
if (["\0*\0_headers", $p.'body', $p.'type', $p.'subtype', $p.'parameters'] === array_keys($data)) {
|
||||
$r = new \ReflectionProperty(parent::class, 'headers');
|
||||
$r->setValue($this, $data["\0*\0_headers"]);
|
||||
|
||||
$this->body = $data[$p.'body'];
|
||||
$this->type = $data[$p.'type'];
|
||||
$this->subtype = $data[$p.'subtype'];
|
||||
$this->parameters = $data[$p.'parameters'];
|
||||
|
||||
if ($wakeup) {
|
||||
$this->_headers = $data["\0*\0_headers"];
|
||||
$this->__wakeup();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Passing extra keys to "%s::__unserialize()" is deprecated, populate properties in "%s::__unserialize()" instead.', self::class, get_debug_type($this));
|
||||
|
||||
\Closure::bind(function ($data) use ($wakeup) {
|
||||
foreach ($data as $key => $value) {
|
||||
$this->{("\0" === $key[0] ?? '') ? substr($key, 1 + strrpos($key, "\0")) : $key} = $value;
|
||||
}
|
||||
|
||||
if ($wakeup) {
|
||||
$this->__wakeup();
|
||||
}
|
||||
}, $this, static::class)($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, will be replaced by `__serialize()` in 8.0
|
||||
*/
|
||||
public function __sleep(): array
|
||||
{
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Calling "%s::__sleep()" is deprecated, use "__serialize()" instead.', get_debug_type($this));
|
||||
|
||||
// convert iterables to strings for serialization
|
||||
if (is_iterable($this->body)) {
|
||||
$this->body = $this->bodyToString();
|
||||
}
|
||||
|
||||
$this->_headers = $this->getHeaders();
|
||||
|
||||
return ['_headers', 'body', 'type', 'subtype', 'parameters'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Symfony 7.4, will be replaced by `__unserialize()` in 8.0
|
||||
*/
|
||||
public function __wakeup(): void
|
||||
{
|
||||
trigger_deprecation('symfony/mime', '7.4', 'Calling "%s::__wakeup()" is deprecated, use "__unserialize()" instead.', get_debug_type($this));
|
||||
|
||||
$r = new \ReflectionProperty(AbstractPart::class, 'headers');
|
||||
$r->setValue($this, $this->_headers);
|
||||
unset($this->_headers);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user