Bug->Doc #62200 [Opn]: __set_state() not implemented

From: Date: Mon, 04 Jun 2012 23:54:00 +0000
Subject: Bug->Doc #62200 [Opn]: __set_state() not implemented
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-8427@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62200&edit=1 ID: 62200 Updated by: johannes@php.net Reported by: bkam at citiesunlimited dot com Summary: __set_state() not implemented Status: Open -Type: Bug +Type: Documentation Problem Package: SPL related Operating System: All PHP Version: 5.4.3 Block user comment: N Private report: N New Comment: This should be cleared in the documentation. The code returned is valid PHP code, while it won't necessarily run successful. var_export() assumes a __set_state() exists, but there are cases where it doesn't and there are cases where for different reasons it never can in a sufficient way. Especially for internal classes where we can't export the full state. Previous Comments: ------------------------------------------------------------------------ [2012-05-31 23:50:43] bkam at citiesunlimited dot com Description: ------------ Pretty simple, var_export of SPL traversibles shows Class::__set_state([]) but actually calling that function throws an undefined method error. This is specifically true for ArrayObject, but generally true for all the traversibles with inaccessible internal structures. Test script: --------------- //first $a = new ArrayObject(); $a['key'] = 'value'; var_export($a); // returns //"ArrayObject::__set_state(array( 'key' => 'value', ))" $ao = ArrayObject::__set_state(['thing' => 'value']); //returns //"Fatal error: Call to undefined method ArrayObject::__set_state()" Expected result: ---------------- "ArrayObject::__set_state(array( 'key' => 'value', ))" "" Actual result: -------------- "Fatal error: Call to undefined method ArrayObject::__set_state()" ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62200&edit=1

« previous php.doc.bugs (#8427) next »