Hi,
As Internal Class doesn't support newInstanceWithoutConstructor, some
user code use the above hack (ex phpunit-mock-object)
$object = unserialize(
sprintf('%s:%d:"%s":0:{}',
(version_compare(PHP_VERSION, '5.4', '>')
&& $class->implementsInterface("Serializable") ? "C" : "O"),
strlen($className),
$className
)
);
Of course, this is already a hack.
Of course, better solution will be to support
newInstanceWithoutConstructor for all internals classes, but this is
another story
Problem, Serializable internal class raised the
'Empty serialized string cannot be empty' exception.
I don't really see any reason to make serialized string mandatory, as
those classes can be create (constructor) without any mandatory option.
The trivial attached patch could make everyone life easier.
The new test serialize again the result object to ensure all internal
structures are properly initialized, and no segfault.
Feedback welcome.
Remi.