mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 17:58:41 +00:00
fix deprecation
This commit is contained in:
parent
b1faa50caa
commit
fb3988e72c
|
|
@ -34,7 +34,7 @@ abstract class CacheValueType extends Enum
|
||||||
|
|
||||||
public const _ARRAY = 2; /* Data is array */
|
public const _ARRAY = 2; /* Data is array */
|
||||||
|
|
||||||
public const _SERIALIZABLE = 3; /* Data implements \Serializable */
|
public const _SERIALIZABLE = 3; /* Data implements __serialize and __unserialize() */
|
||||||
|
|
||||||
public const _FLOAT = 4; /* Data is float */
|
public const _FLOAT = 4; /* Data is float */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,8 +164,6 @@ abstract class ConnectionAbstract implements ConnectionInterface
|
||||||
return CacheValueType::_ARRAY;
|
return CacheValueType::_ARRAY;
|
||||||
} elseif ($value === null) {
|
} elseif ($value === null) {
|
||||||
return CacheValueType::_NULL;
|
return CacheValueType::_NULL;
|
||||||
} elseif ($value instanceof \Serializable) {
|
|
||||||
return CacheValueType::_SERIALIZABLE;
|
|
||||||
} elseif ($value instanceof \JsonSerializable) {
|
} elseif ($value instanceof \JsonSerializable) {
|
||||||
return CacheValueType::_JSONSERIALIZABLE;
|
return CacheValueType::_JSONSERIALIZABLE;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ use phpOMS\System\File\Local\File;
|
||||||
* This implementation uses the hard drive as cache by saving data to the disc as text files.
|
* This implementation uses the hard drive as cache by saving data to the disc as text files.
|
||||||
* The text files follow a defined strucuture which allows this implementation to parse the cached data.
|
* The text files follow a defined strucuture which allows this implementation to parse the cached data.
|
||||||
*
|
*
|
||||||
* Allowed datatypes: null, int, bool, float, string, \DateTime, \JsonSerializable, \Serializable
|
* Allowed datatypes: null, int, bool, float, string, \DateTime, \JsonSerializable
|
||||||
* File structure:
|
* File structure:
|
||||||
* data type (1 byte)
|
* data type (1 byte)
|
||||||
* delimiter (1 byte)
|
* delimiter (1 byte)
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ final class MemCached extends ConnectionAbstract
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(\is_scalar($value) || $value === null || \is_array($value) || $value instanceof \JsonSerializable || $value instanceof \Serializable)) {
|
if (!(\is_scalar($value) || $value === null || \is_array($value) || $value instanceof \JsonSerializable) {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ final class MemCached extends ConnectionAbstract
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(\is_scalar($value) || $value === null || \is_array($value) || $value instanceof \JsonSerializable || $value instanceof \Serializable)) {
|
if (!(\is_scalar($value) || $value === null || \is_array($value) || $value instanceof \JsonSerializable) {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1454,8 +1454,6 @@ class Builder extends BuilderAbstract
|
||||||
return $column;
|
return $column;
|
||||||
} elseif ($column instanceof Column) {
|
} elseif ($column instanceof Column) {
|
||||||
return $column->getColumn();
|
return $column->getColumn();
|
||||||
} elseif ($column instanceof \Serializable) {
|
|
||||||
return $column->serialize();
|
|
||||||
} elseif ($column instanceof self) {
|
} elseif ($column instanceof self) {
|
||||||
return \md5($column->toSql());
|
return \md5($column->toSql());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -359,8 +359,6 @@ class Grammar extends GrammarAbstract
|
||||||
$encoded = \json_encode($value);
|
$encoded = \json_encode($value);
|
||||||
|
|
||||||
return $encoded ? $encoded : 'NULL';
|
return $encoded ? $encoded : 'NULL';
|
||||||
} elseif ($value instanceof \Serializable) {
|
|
||||||
return $value->serialize();
|
|
||||||
} elseif ($value instanceof Parameter) {
|
} elseif ($value instanceof Parameter) {
|
||||||
return $value->__toString();
|
return $value->__toString();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -736,7 +736,7 @@ class Matrix implements \ArrayAccess, \Iterator
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function offsetExists($offset) : bool
|
public function offsetExists(mixed $offset) : bool
|
||||||
{
|
{
|
||||||
$row = (int) ($offset / $this->m);
|
$row = (int) ($offset / $this->m);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ use phpOMS\Message\HeaderAbstract;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class SocketHeader extends HeaderAbstract implements \Serializable
|
class SocketHeader extends HeaderAbstract
|
||||||
{
|
{
|
||||||
private $sendFrom = null;
|
private $sendFrom = null;
|
||||||
|
|
||||||
|
|
@ -199,9 +199,9 @@ class SocketHeader extends HeaderAbstract implements \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return $this->__toString();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -225,7 +225,7 @@ class SocketHeader extends HeaderAbstract implements \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function unserialize($string) : void
|
public function __unserialize($string) : void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use phpOMS\Contract\ArrayableInterface;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
final class Dom implements \Serializable, ArrayableInterface
|
final class Dom implements ArrayableInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Message type.
|
* Message type.
|
||||||
|
|
@ -125,13 +125,13 @@ final class Dom implements \Serializable, ArrayableInterface
|
||||||
/**
|
/**
|
||||||
* Render message.
|
* Render message.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return $this->__toString();
|
return $this->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -145,7 +145,7 @@ final class Dom implements \Serializable, ArrayableInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function unserialize($raw) : void
|
public function __unserialize($raw) : void
|
||||||
{
|
{
|
||||||
$unserialized = \json_decode($raw, true);
|
$unserialized = \json_decode($raw, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use phpOMS\Contract\ArrayableInterface;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
final class FormValidation implements \JsonSerializable, \Serializable, ArrayableInterface
|
final class FormValidation implements \JsonSerializable, ArrayableInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Message type.
|
* Message type.
|
||||||
|
|
@ -57,13 +57,13 @@ final class FormValidation implements \JsonSerializable, \Serializable, Arrayabl
|
||||||
/**
|
/**
|
||||||
* Render message.
|
* Render message.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return $this->__toString();
|
return $this->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,7 +77,7 @@ final class FormValidation implements \JsonSerializable, \Serializable, Arrayabl
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function unserialize($raw) : void
|
public function __unserialize($raw) : void
|
||||||
{
|
{
|
||||||
$unserialized = \json_decode($raw, true);
|
$unserialized = \json_decode($raw, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use phpOMS\Contract\ArrayableInterface;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
final class Notify implements \JsonSerializable, \Serializable, ArrayableInterface
|
final class Notify implements \JsonSerializable, ArrayableInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Message type.
|
* Message type.
|
||||||
|
|
@ -161,13 +161,13 @@ final class Notify implements \JsonSerializable, \Serializable, ArrayableInterfa
|
||||||
/**
|
/**
|
||||||
* Render message.
|
* Render message.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return $this->__toString();
|
return $this->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -181,7 +181,7 @@ final class Notify implements \JsonSerializable, \Serializable, ArrayableInterfa
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function unserialize($raw) : void
|
public function __unserialize($raw) : void
|
||||||
{
|
{
|
||||||
$unserialized = \json_decode($raw, true);
|
$unserialized = \json_decode($raw, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use phpOMS\Contract\ArrayableInterface;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
final class Redirect implements \JsonSerializable, \Serializable, ArrayableInterface
|
final class Redirect implements \JsonSerializable, ArrayableInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Message type.
|
* Message type.
|
||||||
|
|
@ -103,13 +103,13 @@ final class Redirect implements \JsonSerializable, \Serializable, ArrayableInter
|
||||||
/**
|
/**
|
||||||
* Render message.
|
* Render message.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return $this->__toString();
|
return $this->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -123,7 +123,7 @@ final class Redirect implements \JsonSerializable, \Serializable, ArrayableInter
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function unserialize($raw) : void
|
public function __unserialize($raw) : void
|
||||||
{
|
{
|
||||||
$unserialized = \json_decode($raw, true);
|
$unserialized = \json_decode($raw, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use phpOMS\Contract\ArrayableInterface;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
final class Reload implements \JsonSerializable, \Serializable, ArrayableInterface
|
final class Reload implements \JsonSerializable, ArrayableInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Message type.
|
* Message type.
|
||||||
|
|
@ -71,19 +71,19 @@ final class Reload implements \JsonSerializable, \Serializable, ArrayableInterfa
|
||||||
/**
|
/**
|
||||||
* Render message.
|
* Render message.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return $this->__toString();
|
return $this->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function unserialize($raw) : void
|
public function __unserialize($raw) : void
|
||||||
{
|
{
|
||||||
$unserialized = \json_decode($raw, true);
|
$unserialized = \json_decode($raw, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace phpOMS\Stdlib\Base;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class FloatInt implements \Serializable
|
class FloatInt
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Max amount of decimals.
|
* Max amount of decimals.
|
||||||
|
|
@ -306,9 +306,9 @@ class FloatInt implements \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return (string) $this->getInt();
|
return [$this->getInt()];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -320,7 +320,7 @@ class FloatInt implements \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function unserialize($value) : void
|
public function __unserialize($value) : void
|
||||||
{
|
{
|
||||||
$this->setInt((int) $value);
|
$this->setInt((int) $value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use phpOMS\Validation\Finance\IbanEnum;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Iban implements \Serializable
|
class Iban
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Iban.
|
* Iban.
|
||||||
|
|
@ -254,9 +254,9 @@ class Iban implements \Serializable
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return $this->prettyPrint();
|
return [$this->prettyPrint()];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -280,7 +280,7 @@ class Iban implements \Serializable
|
||||||
* @return void
|
* @return void
|
||||||
* @since 5.1.0
|
* @since 5.1.0
|
||||||
*/
|
*/
|
||||||
public function unserialize($serialized) : void
|
public function __unserialize($serialized) : void
|
||||||
{
|
{
|
||||||
$this->parse($serialized);
|
$this->parse($serialized);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use phpOMS\Localization\ISO3166TwoEnum;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Location implements \JsonSerializable, \Serializable
|
class Location implements \JsonSerializable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Location id
|
* Location id
|
||||||
|
|
@ -183,9 +183,9 @@ class Location implements \JsonSerializable, \Serializable
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return (string) \json_encode($this->jsonSerialize());
|
return $this->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -214,7 +214,7 @@ class Location implements \JsonSerializable, \Serializable
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function unserialize($serialized) : void
|
public function __unserialize($serialized) : void
|
||||||
{
|
{
|
||||||
$data = \json_decode($serialized, true);
|
$data = \json_decode($serialized, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ use phpOMS\Stdlib\Base\Exception\InvalidEnumValue;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class PriorityQueue implements \Countable, \Serializable
|
class PriorityQueue implements \Countable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Queue type.
|
* Queue type.
|
||||||
|
|
@ -313,9 +313,9 @@ class PriorityQueue implements \Countable, \Serializable
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
return (string) \json_encode($this->queue);
|
return $this->queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -327,7 +327,7 @@ class PriorityQueue implements \Countable, \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function unserialize($data) : void
|
public function __unserialize($data) : void
|
||||||
{
|
{
|
||||||
$this->queue = \json_decode($data, true);
|
$this->queue = \json_decode($data, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -728,7 +728,7 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function offsetExists($offset) : bool
|
public function offsetExists(mixed $offset) : bool
|
||||||
{
|
{
|
||||||
$offset = isset($this->nodes[$offset]) ? $offset : $this->path . '/' . $offset;
|
$offset = isset($this->nodes[$offset]) ? $offset : $this->path . '/' . $offset;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -551,7 +551,7 @@ final class Directory extends FileAbstract implements DirectoryInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function offsetExists($offset) : bool
|
public function offsetExists(mixed $offset) : bool
|
||||||
{
|
{
|
||||||
$offset = isset($this->nodes[$offset]) ? $offset : $this->path . '/' . $offset;
|
$offset = isset($this->nodes[$offset]) ? $offset : $this->path . '/' . $offset;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,6 @@ class ArrayParser
|
||||||
return \rtrim(\rtrim(\number_format($value, 5, '.', ''), '0'), '.');
|
return \rtrim(\rtrim(\number_format($value, 5, '.', ''), '0'), '.');
|
||||||
} elseif (\is_scalar($value)) {
|
} elseif (\is_scalar($value)) {
|
||||||
return (string) $value;
|
return (string) $value;
|
||||||
} elseif ($value instanceof \Serializable) {
|
|
||||||
return self::parseVariable($value->serialize());
|
|
||||||
} elseif ($value instanceof \JsonSerializable) {
|
} elseif ($value instanceof \JsonSerializable) {
|
||||||
return self::parseVariable($value->jsonSerialize());
|
return self::parseVariable($value->jsonSerialize());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -200,8 +200,6 @@ final class StringUtils
|
||||||
$encoded = \json_encode($element, $option !== null ? $option : 0);
|
$encoded = \json_encode($element, $option !== null ? $option : 0);
|
||||||
|
|
||||||
return $encoded ? $encoded : null;
|
return $encoded ? $encoded : null;
|
||||||
} elseif ($element instanceof \Serializable) {
|
|
||||||
return $element->serialize();
|
|
||||||
} elseif (\is_string($element)) {
|
} elseif (\is_string($element)) {
|
||||||
return $element;
|
return $element;
|
||||||
} elseif (\is_int($element) || \is_float($element)) {
|
} elseif (\is_int($element) || \is_float($element)) {
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace phpOMS\Utils\TaskSchedule;
|
||||||
* @link https://karaka.app
|
* @link https://karaka.app
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
class Interval implements \Serializable
|
class Interval
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Start of the task.
|
* Start of the task.
|
||||||
|
|
@ -520,13 +520,13 @@ class Interval implements \Serializable
|
||||||
/**
|
/**
|
||||||
* Create string representation.
|
* Create string representation.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function serialize() : string
|
public function __serialize() : array
|
||||||
{
|
{
|
||||||
$serialized = \json_encode([
|
return [
|
||||||
'start' => $this->start->format('Y-m-d H:i:s'),
|
'start' => $this->start->format('Y-m-d H:i:s'),
|
||||||
'end' => $this->end === null ? null : $this->end->format('Y-m-d H:i:s'),
|
'end' => $this->end === null ? null : $this->end->format('Y-m-d H:i:s'),
|
||||||
'maxDuration' => $this->maxDuration,
|
'maxDuration' => $this->maxDuration,
|
||||||
|
|
@ -535,9 +535,7 @@ class Interval implements \Serializable
|
||||||
'dayOfMonth' => $this->dayOfMonth,
|
'dayOfMonth' => $this->dayOfMonth,
|
||||||
'dayOfWeek' => $this->dayOfWeek,
|
'dayOfWeek' => $this->dayOfWeek,
|
||||||
'year' => $this->year,
|
'year' => $this->year,
|
||||||
]);
|
];
|
||||||
|
|
||||||
return $serialized === false ? '{}' : $serialized;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -549,7 +547,7 @@ class Interval implements \Serializable
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function unserialize($serialized) : void
|
public function __unserialize($serialized) : void
|
||||||
{
|
{
|
||||||
$data = \json_decode($serialized, true);
|
$data = \json_decode($serialized, true);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,16 +14,16 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace phpOMS\tests\DataStorage\Cache\Connection;
|
namespace phpOMS\tests\DataStorage\Cache\Connection;
|
||||||
|
|
||||||
class FileCacheSerializable implements \Serializable
|
class FileCacheSerializable
|
||||||
{
|
{
|
||||||
public $val = 'asdf';
|
public $val = 'asdf';
|
||||||
|
|
||||||
public function serialize()
|
public function __serialize()
|
||||||
{
|
{
|
||||||
return 'abc';
|
return ['abc'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unserialize($val) : void
|
public function __unserialize($val) : void
|
||||||
{
|
{
|
||||||
$this->val = $val;
|
$this->val = $val;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,15 +65,15 @@ class BaseModel
|
||||||
$this->ownsOneSelf = new OwnsOneModel();
|
$this->ownsOneSelf = new OwnsOneModel();
|
||||||
$this->belongsToOne = new BelongsToModel();
|
$this->belongsToOne = new BelongsToModel();
|
||||||
|
|
||||||
$this->serializable = new class() implements \Serializable {
|
$this->serializable = new class() {
|
||||||
public $value = '';
|
public $value = '';
|
||||||
|
|
||||||
public function serialize()
|
public function __serialize()
|
||||||
{
|
{
|
||||||
return '123';
|
return ['123'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unserialize($data) : void
|
public function __unserialize($data) : void
|
||||||
{
|
{
|
||||||
$this->value = $data;
|
$this->value = $data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,6 @@ final class ArrayParserTest extends \PHPUnit\Framework\TestCase
|
||||||
*/
|
*/
|
||||||
public function testParser() : void
|
public function testParser() : void
|
||||||
{
|
{
|
||||||
$serializable = new class() implements \Serializable {
|
|
||||||
public function serialize() { return 2; }
|
|
||||||
|
|
||||||
public function unserialize($raw) : void {}
|
|
||||||
};
|
|
||||||
|
|
||||||
$jsonSerialize = new class() implements \JsonSerializable {
|
$jsonSerialize = new class() implements \JsonSerializable {
|
||||||
public function jsonSerialize() { return [6, 7]; }
|
public function jsonSerialize() { return [6, 7]; }
|
||||||
};
|
};
|
||||||
|
|
@ -50,7 +44,6 @@ final class ArrayParserTest extends \PHPUnit\Framework\TestCase
|
||||||
0 => 'a',
|
0 => 'a',
|
||||||
1 => 'b',
|
1 => 'b',
|
||||||
],
|
],
|
||||||
5 => $serializable,
|
|
||||||
6 => $jsonSerialize,
|
6 => $jsonSerialize,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -64,7 +57,6 @@ final class ArrayParserTest extends \PHPUnit\Framework\TestCase
|
||||||
0 => 'a',
|
0 => 'a',
|
||||||
1 => 'b',
|
1 => 'b',
|
||||||
],
|
],
|
||||||
5 => $serializable->serialize(),
|
|
||||||
6 => $jsonSerialize->jsonSerialize(),
|
6 => $jsonSerialize->jsonSerialize(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -130,17 +130,6 @@ final class StringUtilsTest extends \PHPUnit\Framework\TestCase
|
||||||
|
|
||||||
self::assertEquals('["abc"]', StringUtils::stringify(['abc']));
|
self::assertEquals('["abc"]', StringUtils::stringify(['abc']));
|
||||||
|
|
||||||
self::assertEquals('abc', StringUtils::stringify(new class() implements \Serializable {
|
|
||||||
public function serialize()
|
|
||||||
{
|
|
||||||
return 'abc';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unserialize($val) : void
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
self::assertEquals('abc', StringUtils::stringify('abc'));
|
self::assertEquals('abc', StringUtils::stringify('abc'));
|
||||||
self::assertEquals('1', StringUtils::stringify(1));
|
self::assertEquals('1', StringUtils::stringify(1));
|
||||||
self::assertEquals('1.1', StringUtils::stringify(1.1));
|
self::assertEquals('1.1', StringUtils::stringify(1.1));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user