Skip to content

Commit

Permalink
add a note on how to upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Nov 22, 2021
1 parent 34359df commit 194fa7a
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
From 2.2.3 to 2.3.0
====================

- The `\Serializable` PHP interface is deprecated, the methods of this interface will be removed in 3.0.
This change is done to allow the use of the new `__serialize` and `__unserialize` PHP's strategy.

If you were extending the metadata classes, your custom serialization methods were looking probably as something as this:

```php
class MyMetadata extends PropertyMetadata
{
// ... more code

public function serialize()
{
$data = parent::serialize();

return \serialize([$data, $this->customMetadataProp]);
}

public function unserialize($str)
{
list($str, $this->customMetadataProp) = \unserialize($str);

parent::unserialize($str);
}
}
```

After this change, your code should look like this:

```php
class MyMetadata extends PropertyMetadata
{
// ... more code

protected function serializeToArray(): array
{
$data = parent::serializeToArray();

return [$data, $this->customMetadataProp];
}

protected function unserializeFromArray(array $data): void
{
list($data, $this->customMetadataProp) = $data;

parent::unserializeFromArray($data);
}
}
```

From 1.7.0 to 2.0.0
====================

Expand Down

0 comments on commit 194fa7a

Please sign in to comment.