1--TEST--
2Generators can't be serialized or unserialized
3--FILE--
4<?php
5
6function gen() { yield; }
7
8$gen = gen();
9
10try {
11    serialize($gen);
12} catch (Exception $e) {
13    echo $e, "\n\n";
14}
15
16try {
17    var_dump(unserialize('O:9:"Generator":0:{}'));
18} catch (Exception $e) {
19    echo $e, "\n\n";
20}
21
22try {
23    var_dump(unserialize('C:9:"Generator":0:{}'));
24} catch (Exception $e) {
25    echo $e;
26}
27
28?>
29--EXPECTF--
30Exception: Serialization of 'Generator' is not allowed in %s:%d
31Stack trace:
32#0 %s(%d): serialize(Object(Generator))
33#1 {main}
34
35
36Warning: Erroneous data format for unserializing 'Generator' in %sserialize_unserialize_error.php on line %d
37
38Notice: unserialize(): Error at offset 19 of 20 bytes in %sserialize_unserialize_error.php on line %d
39bool(false)
40Exception: Unserialization of 'Generator' is not allowed in %s:%d
41Stack trace:
42#0 %s(%d): unserialize('C:9:"Generator"...')
43#1 {main}
44