@Crell yes regarding if it's a Collection<Foo>, then thou shalt not put something into it that is not a Foo. and basically I would envision explicit type boundaries to fixate types
Right, including unmangled private properties is useless, since you can't know what classes they belong to. I just stumbled across this when thinking about how this should behave for property hooks.
Apart from the fact that including two private properties with the same name causes loss of information.
Unfortunately, there's not an obvious migration path, apart from introducing a new parameter or a completely new function.
Mangling might also be necessary if the private property belongs to some parent class, unless we expect the __set_state implementation to traverse parents to find the right property via reflection.
And various bugs have been found with various implementations of it for specific classes, especially internals.
In my head I would try to deprecate and remove it. Would have to figure out what code actually uses this pattern to see what alternative APIs might need to be introduced first.
I think it's mostly used as a potentially faster alternative to serialize, as opcache can cache the file to avoid parsing it every time it is read. According to Larrys benchmark this isn't actually faster, although it seems like it should be.
@IluTov It definitely seems like it should be faster than parsing/unserializing each request. We use var_export to write the results of a build step to cache files. These are mostly simple associative arrays.
Constant values should definitely be faster. With opcache, they can be moved to shm, while with unserialize they would need to be reconstructed in memory every time. For objects, the difference in performance might be significantly smaller.