mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Implement updated Serializable API
This commit is contained in:
parent
bccbeedfdc
commit
0318372641
16
.travis.yml
16
.travis.yml
@ -8,7 +8,7 @@ import:
|
||||
jobs:
|
||||
fast_finish: true
|
||||
include:
|
||||
- php: 7.3
|
||||
- php: 7.4
|
||||
env:
|
||||
- DB=MYSQL
|
||||
- REQUIRE_INSTALLER="$REQUIRE_RECIPE"
|
||||
@ -28,15 +28,17 @@ jobs:
|
||||
- REQUIRE_INSTALLER="$REQUIRE_RECIPE"
|
||||
- PHPUNIT_TEST=1
|
||||
- PHPUNIT_SUITE="cms"
|
||||
- php: 7.4
|
||||
env:
|
||||
- DB=MYSQL
|
||||
- REQUIRE_INSTALLER="$REQUIRE_RECIPE"
|
||||
- PHPUNIT_TEST=1
|
||||
- PHPUNIT_SUITE="framework"
|
||||
- php: 8.0
|
||||
env:
|
||||
- DB=MYSQL
|
||||
- REQUIRE_INSTALLER="$REQUIRE_RECIPE"
|
||||
- PHPUNIT_TEST=1
|
||||
- PHPUNIT_SUITE="framework"
|
||||
- php: 8.1.0
|
||||
env:
|
||||
- DB=MYSQL
|
||||
- REQUIRE_INSTALLER="$REQUIRE_RECIPE"
|
||||
- PHPUNIT_TEST=1
|
||||
- PHPUNIT_SUITE="framework"
|
||||
allow_failures:
|
||||
- php: 8.1.0
|
||||
|
@ -40,7 +40,7 @@
|
||||
"symfony/config": "^3.4 || ^4.0",
|
||||
"symfony/translation": "^3.4 || ^4.0",
|
||||
"symfony/yaml": "^3.4 || ^4.0",
|
||||
"php": "^7.3 || ^8.0",
|
||||
"php": "^7.4 || ^8.0",
|
||||
"ext-ctype": "*",
|
||||
"ext-dom": "*",
|
||||
"ext-hash": "*",
|
||||
@ -58,6 +58,7 @@
|
||||
"squizlabs/php_codesniffer": "^3.5"
|
||||
},
|
||||
"conflict": {
|
||||
"egulias/email-validator": "^2",
|
||||
"phpunit/phpunit": "^6 || ^7 || ^8"
|
||||
},
|
||||
"provide": {
|
||||
|
@ -185,11 +185,42 @@ class Module implements Serializable
|
||||
return substr($this->path, strlen($this->basePath) + 1);
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
return [
|
||||
'path' => $this->path,
|
||||
'basePath' => $this->basePath,
|
||||
'composerData' => $this->composerData
|
||||
];
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
$this->path = $data['path'];
|
||||
$this->basePath = $data['basePath'];
|
||||
$this->composerData = $data['composerData'];
|
||||
$this->resources = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* The __serialize() magic method will be automatically used instead of this
|
||||
*
|
||||
* @return string
|
||||
* @deprecated will be removed in 5.0
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return json_encode([$this->path, $this->basePath, $this->composerData]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The __unserialize() magic method will be automatically used instead of this almost all the time
|
||||
* This method will be automatically used if existing serialized data was not saved as an associative array
|
||||
* and the PHP version used in less than PHP 9.0
|
||||
*
|
||||
* @param string $serialized
|
||||
* @deprecated will be removed in 5.0
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
list($this->path, $this->basePath, $this->composerData) = json_decode($serialized, true);
|
||||
|
@ -214,10 +214,25 @@ class ValidationResult implements Serializable
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
return [
|
||||
'messages' => $this->messages,
|
||||
'isValid' => $this->isValid()
|
||||
];
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
$this->messages = $data['messages'];
|
||||
$this->isValid = $data['isValid'];
|
||||
}
|
||||
|
||||
/**
|
||||
* String representation of object
|
||||
* The __serialize() magic method will be automatically used instead of this
|
||||
*
|
||||
* @return string the string representation of the object or null
|
||||
* @return string
|
||||
* @deprecated will be removed in 5.0
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
@ -225,9 +240,12 @@ class ValidationResult implements Serializable
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the object
|
||||
* The __unserialize() magic method will be automatically used instead of this almost all the time
|
||||
* This method will be automatically used if existing serialized data was not saved as an associative array
|
||||
* and the PHP version used in less than PHP 9.0
|
||||
*
|
||||
* @param string $serialized
|
||||
* @deprecated will be removed in 5.0
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
|
@ -40,11 +40,35 @@ class FlushInvalidatedResource implements SelfCheckingResourceInterface, \Serial
|
||||
return false;
|
||||
}
|
||||
|
||||
public function __serialize(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
// no-op
|
||||
}
|
||||
|
||||
/**
|
||||
* The __serialize() magic method will be automatically used instead of this
|
||||
*
|
||||
* @return string
|
||||
* @deprecated will be removed in 5.0
|
||||
*/
|
||||
public function serialize()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* The __unserialize() magic method will be automatically used instead of this almost all the time
|
||||
* This method will be automatically used if existing serialized data was not saved as an associative array
|
||||
* and the PHP version used in less than PHP 9.0
|
||||
*
|
||||
* @param string $serialized
|
||||
* @deprecated will be removed in 5.0
|
||||
*/
|
||||
public function unserialize($serialized)
|
||||
{
|
||||
// no-op
|
||||
|
Loading…
Reference in New Issue
Block a user