Re: [PATCH] Make var_export() output "(object)array(..." instead of "stdClass::__set_state(..." for stdClass

From: Date: Tue, 14 Mar 2017 19:26:42 +0000
Subject: Re: [PATCH] Make var_export() output "(object)array(..." instead of "stdClass::__set_state(..." for stdClass
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-98522@lists.php.net to get a copy of this message
On 3/14/2017 7:57 PM, Andrea Faulds wrote: > Hi everyone, > > Since stdClass has no __set_state method, var_export() produces unusable > output if given an object of that class. I wrote a patch that would make > var_export() produce a cast to object instead, which could be evaluated > to get back a stdClass: > > https://github.com/php/php-src/pull/2420 > > Any thoughts/comments? > > If you're wondering about whether a __set_state method should be added > to stdClass, I posted some thoughts in the pull request discussion already. > > Thanks! I actually already used __set_state occasionally for userland classes. Adding __set_state to stdClass seems to be more consistent with the rest of PHP, rather than special casing it in one method. I cannot see any issues with this to be honest. -- Richard "Fleshgrinder" Fussenegger

« previous php.internals (#98522) next »