-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: try using __serialize when obj implements \Serializable
The Serializable interface is now being deprecated in favour of using the magic methods __serialize() and __unserialize(). Some packages decided to start throwing exceptions on their Serializable implementations if the interface methods were called. This commit tries to check if the classes that implement Serializable are already using __serialize() and if they are, it calls that method, instead of the interface one serialize(). If this is the case, we also hide the deprecation notice, since it seems the client code is already preparing to drop \Serializable when the time comes. This should fix issue #136 on rollbar/rollbar-php-laravel
- Loading branch information
Pedro Coutinho
committed
Apr 20, 2022
1 parent
2086428
commit 259c34e
Showing
6 changed files
with
136 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php namespace Rollbar\TestHelpers; | ||
|
||
class DeprecatedSerializable implements \Serializable | ||
{ | ||
public $data; | ||
|
||
public function __construct($data) | ||
{ | ||
$this->data = $data; | ||
} | ||
|
||
public function serialize() | ||
{ | ||
return $this->data; | ||
} | ||
|
||
public function unserialize(string $data) | ||
{ | ||
throw new \Exception("Not implemented"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters