<?php
$foo = new class {
public function Bar () {
echo 'bar';
}
};
// This succeeds. I'd argue an error should be generated at this point
echo $serFoo = serialize($foo);
// Unserialize fails and a notice is generated
$unFoo = unserialize($serFoo);
// Error generated on call
$unFoo->Bar();
Fatal error: Uncaught Exception: Serialization of 'class@anonymous' is not allowed in /in/AJY6d:10
Stack trace:
#0 /in/AJY6d(10): serialize(Object(class@anonymous))
#1 {main}
thrown in /in/AJY6d on line 10
Process exited with code 255.