|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-03-07 09:48 UTC] nikic@php.net
-Type: Bug
+Type: Documentation Problem
[2020-03-07 09:48 UTC] nikic@php.net
[2020-03-07 11:06 UTC] tarasov dot igor at gmail dot com
[2020-03-07 17:59 UTC] nikic@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 17 20:00:01 2025 UTC |
Description: ------------ If you inherit from ArrayObject and then try to override serialize and unserialize methods, you'll notice that starting with PHP 7.4 these are not executed at all. There are no mentions in the documentation describing this change. Sure, there are new __serialize and __unserialize, but this backward-incompatible change and is not described anywhere. If you create a custom class implementing Serializable interface, you can still override these methods in child classes, no problem there. Not sure if this change affects only ArrayObject, I suspect there might be other built-in classes that were changed the same way. Test script: --------------- class Foo extends \ArrayObject { public function serialize() { return 'test'; } } echo serialize(new Foo); Expected result: ---------------- C:3:"Foo":4:{test} Actual result: -------------- O:3:"Foo":3:{i:0;i:0;i:1;a:0:{}i:2;a:0:{}} So, Foo::serialize is never executed. And it's not like the results are ignored, you can even change it's body to die statement and it won't stop there.