Bug #54290 [Opn->Nab]: Class which extends from \SplFileObject is not serializable

From: Date: Mon, 20 Apr 2020 15:16:07 +0000
Subject: Bug #54290 [Opn->Nab]: Class which extends from \SplFileObject is not serializable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-226692@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=54290&edit=1 ID: 54290 Updated by: cmb@php.net Reported by: frederic dot hardy at mageekbox dot net Summary: Class which extends from \SplFileObject is not serializable -Status: Open +Status: Not a bug Type: Bug Package: SPL related PHP Version: 5.3.5 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Indeed, serialization of SplFileObjects is deliberately unsupported, and due to inherent issues with the Serializable interface, at least this serialization mechanism will not be supported. Previous Comments: ------------------------------------------------------------------------ [2013-05-07 09:47:17] hanskrentel at yahoo dot de According to the code it is intended that you can not serialize it. Which can make sense as the file itself already is a serialized form of the object it represents. However different to DOMDocument where serialization wouldn't make much sense (XML is a serialization already), in the SplFileObject case, Serialization is *explicitly* forbidden. The internal state of the object can not be preserved by serialization, therefore it is just not possible. This ticket can be closed as a duplicate of #46646 in my eyes or it needs to be turned into a feature-request, so that implementing Serializable might become possible - like it is with DOMDocument. ------------------------------------------------------------------------ [2011-03-21 19:01:41] jinmoku at hotmail dot com see bug : http://bugs.php.net/bug.php?id=46646 http://svn.php.net/viewvc/php/php-src/trunk/ext/spl/spl_directory.c?r1=271751&r2=271752 ;) ------------------------------------------------------------------------ [2011-03-17 11:04:21] frederic dot hardy at mageekbox dot net Description: ------------ It's impossible to implements \Serializable interface on a class which extends from \SplFileObject. Test script: --------------- <?php namespace php\bugs\splFileObject; class SerializableFileObject extends \SplFileObject implements \Serializable { public function serialize() { } public function unserialize($serialized) { } } ?> Expected result: ---------------- Nothing. Actual result: -------------- PHP Fatal error: Class php\bugs\splFileObject\Serializable could not implement interface Serializable in Unknown on line 0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=54290&edit=1

« previous php.bugs (#226692) next »