Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Remove Serializable implementations #41299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove Serializable implementations
  • Loading branch information
derrabus authored and nicolas-grekas committed May 27, 2021
commit 33969158d0758f517a743a2b48211ab6b89e2bea
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* This class is a hand written simplified version of PHP native `ArrayObject`
* class, to show that it behaves differently than the PHP native implementation.
*/
class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable
class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable
{
private $array;

Expand Down Expand Up @@ -63,18 +63,8 @@ public function __serialize(): array
return $this->array;
}

public function serialize(): string
{
return serialize($this->__serialize());
}

public function __unserialize(array $data): void
{
$this->array = $data;
}

public function unserialize($serialized)
{
$this->__unserialize((array) unserialize((string) $serialized));
}
}
1 change: 1 addition & 0 deletions 1 src/Symfony/Component/Mime/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
---

* Remove `Address::fromString()`, use `Address::create()` instead
* Remove `Serializable` interface from `RawMessage`

5.2.0
-----
Expand Down
18 changes: 1 addition & 17 deletions 18 src/Symfony/Component/Mime/RawMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
/**
* @author Fabien Potencier <fabien@symfony.com>
*/
class RawMessage implements \Serializable
class RawMessage
{
private $message;

Expand Down Expand Up @@ -60,22 +60,6 @@ public function ensureValidity()
{
}

/**
* @internal
*/
final public function serialize(): string
{
return serialize($this->__serialize());
}

/**
* @internal
*/
final public function unserialize($serialized)
{
$this->__unserialize(unserialize($serialized));
}

public function __serialize(): array
{
return [$this->toString()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* This class is a hand written simplified version of PHP native `ArrayObject`
* class, to show that it behaves differently than the PHP native implementation.
*/
class NonTraversableArrayObject implements \ArrayAccess, \Countable, \Serializable
class NonTraversableArrayObject implements \ArrayAccess, \Countable
{
private $array;

Expand Down Expand Up @@ -58,18 +58,8 @@ public function __serialize(): array
return $this->array;
}

public function serialize(): string
{
return serialize($this->__serialize());
}

public function __unserialize(array $data): void
{
$this->array = $data;
}

public function unserialize($serialized)
{
$this->__unserialize((array) unserialize((string) $serialized));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* This class is a hand written simplified version of PHP native `ArrayObject`
* class, to show that it behaves differently than the PHP native implementation.
*/
class TraversableArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable
class TraversableArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable
{
private $array;

Expand Down Expand Up @@ -63,18 +63,8 @@ public function __serialize(): array
return $this->array;
}

public function serialize(): string
{
return serialize($this->__serialize());
}

public function __unserialize(array $data): void
{
$this->array = $data;
}

public function unserialize($serialized)
{
$this->__unserialize((array) unserialize((string) $serialized));
}
}
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Routing/CompiledRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __serialize(): array
*/
final public function serialize(): string
{
return serialize($this->__serialize());
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __unserialize(array $data): void
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function __serialize(): array
*/
final public function serialize(): string
{
return serialize($this->__serialize());
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

public function __unserialize(array $data): void
Expand Down
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/Routing/Tests/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public function testSerializeWhenCompiledWithClass()
*/
public function testSerializedRepresentationKeepsWorking()
{
$serialized = 'C:31:"Symfony\Component\Routing\Route":936:{a:8:{s:4:"path";s:13:"/prefix/{foo}";s:4:"host";s:20:"{locale}.example.net";s:8:"defaults";a:1:{s:3:"foo";s:7:"default";}s:12:"requirements";a:1:{s:3:"foo";s:3:"\d+";}s:7:"options";a:1:{s:14:"compiler_class";s:39:"Symfony\Component\Routing\RouteCompiler";}s:7:"schemes";a:0:{}s:7:"methods";a:0:{}s:8:"compiled";C:39:"Symfony\Component\Routing\CompiledRoute":571:{a:8:{s:4:"vars";a:2:{i:0;s:6:"locale";i:1;s:3:"foo";}s:11:"path_prefix";s:7:"/prefix";s:10:"path_regex";s:31:"{^/prefix(?:/(?P<foo>\d+))?$}sD";s:11:"path_tokens";a:2:{i:0;a:4:{i:0;s:8:"variable";i:1;s:1:"/";i:2;s:3:"\d+";i:3;s:3:"foo";}i:1;a:2:{i:0;s:4:"text";i:1;s:7:"/prefix";}}s:9:"path_vars";a:1:{i:0;s:3:"foo";}s:10:"host_regex";s:40:"{^(?P<locale>[^\.]++)\.example\.net$}sDi";s:11:"host_tokens";a:2:{i:0;a:2:{i:0;s:4:"text";i:1;s:12:".example.net";}i:1;a:4:{i:0;s:8:"variable";i:1;s:0:"";i:2;s:7:"[^\.]++";i:3;s:6:"locale";}}s:9:"host_vars";a:1:{i:0;s:6:"locale";}}}}}';
$serialized = 'O:31:"Symfony\Component\Routing\Route":9:{s:4:"path";s:13:"/prefix/{foo}";s:4:"host";s:20:"{locale}.example.net";s:8:"defaults";a:1:{s:3:"foo";s:7:"default";}s:12:"requirements";a:1:{s:3:"foo";s:3:"\d+";}s:7:"options";a:1:{s:14:"compiler_class";s:39:"Symfony\Component\Routing\RouteCompiler";}s:7:"schemes";a:0:{}s:7:"methods";a:0:{}s:9:"condition";s:0:"";s:8:"compiled";O:39:"Symfony\Component\Routing\CompiledRoute":8:{s:4:"vars";a:2:{i:0;s:6:"locale";i:1;s:3:"foo";}s:11:"path_prefix";s:7:"/prefix";s:10:"path_regex";s:31:"{^/prefix(?:/(?P<foo>\d+))?$}sD";s:11:"path_tokens";a:2:{i:0;a:4:{i:0;s:8:"variable";i:1;s:1:"/";i:2;s:3:"\d+";i:3;s:3:"foo";}i:1;a:2:{i:0;s:4:"text";i:1;s:7:"/prefix";}}s:9:"path_vars";a:1:{i:0;s:3:"foo";}s:10:"host_regex";s:40:"{^(?P<locale>[^\.]++)\.example\.net$}sDi";s:11:"host_tokens";a:2:{i:0;a:2:{i:0;s:4:"text";i:1;s:12:".example.net";}i:1;a:4:{i:0;s:8:"variable";i:1;s:0:"";i:2;s:7:"[^\.]++";i:3;s:6:"locale";}}s:9:"host_vars";a:1:{i:0;s:6:"locale";}}}';
$unserialized = unserialize($serialized);

$route = new Route('/prefix/{foo}', ['foo' => 'default'], ['foo' => '\d+']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
abstract class AbstractToken implements TokenInterface
abstract class AbstractToken implements TokenInterface, \Serializable
{
private $user;
private $roleNames = [];
Expand Down Expand Up @@ -264,7 +264,7 @@ public function __toString()
*/
final public function serialize(): string
{
return serialize($this->__serialize());
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,4 @@ public function __serialize(): array
public function __unserialize(array $data): void
{
}

/**
* @return string
*
* @internal in 5.3
* @final in 5.3
*/
public function serialize()
{
return '';
}

/**
* @return void
*
* @internal in 5.3
* @final in 5.3
*/
public function unserialize($serialized)
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* @author Fabien Potencier <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface TokenInterface extends \Serializable
interface TokenInterface
{
/**
* Returns a string representation of the Token.
Expand Down
5 changes: 5 additions & 0 deletions 5 src/Symfony/Component/Security/Core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

6.0
---

* `TokenInterface` does not extend `Serializable` anymore

5.3
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public function __toString(): string
}
}

class SerializableUser implements UserInterface, \Serializable
class SerializableUser implements UserInterface
{
private $roles;
private $name;
Expand Down Expand Up @@ -275,16 +275,6 @@ public function getSalt()
{
return null;
}

public function serialize(): string
{
return serialize($this->name);
}

public function unserialize($serialized): void
{
$this->name = unserialize($serialized);
}
}

class ConcreteToken extends AbstractToken
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testSerializeNullImpersonateUrl()
/**
* Tests if an old version of SwitchUserToken can still be unserialized.
*
* The fixture was generated by running the following code with Symfony 4.4 and PHP 7.2.
* The fixture was generated by running the following code with Symfony 4.4 and PHP 8.0.
*
* serialize(
* new SwitchUserToken(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* This class is a hand written simplified version of PHP native `ArrayObject`
* class, to show that it behaves differently than the PHP native implementation.
*/
class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable
class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable
{
private $array;

Expand Down Expand Up @@ -63,18 +63,8 @@ public function __serialize(): array
return $this->array;
}

public function serialize(): string
{
return serialize($this->__serialize());
}

public function __unserialize(array $data): void
{
$this->array = $data;
}

public function unserialize($serialized)
{
$this->__unserialize((array) unserialize((string) $serialized));
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.