Is it possible to run unserialization logic code before the default __unserialize
behavior (in which each variable in $data
is assigned to its respective instance variable)?
I am looking to do something like this:
public function __unserialize(array $data): void
{
// do some clean up here
$data['changeMe'] = func($data['changeMe'])
// then call the default behavior
parent::__unserialize($data);
}
However when I define my own __unserialize
it seems to then prevent the standard unserialization behavior from occurring.
I could use __wakeup
to run after the fact, but I may run into type errors if func
is needed for type cleanups.
Ideally I can avoid having to rewrite the default logic of iterating over the items in $data
and binding them to instance vars.