1 | <?php |
||
7 | class GeneratorContainer |
||
8 | { |
||
9 | /** |
||
10 | * Generator. |
||
11 | * @var Generator |
||
12 | */ |
||
13 | private $g; |
||
14 | |||
15 | /** |
||
16 | * Generator object hash. |
||
17 | * @var string |
||
18 | */ |
||
19 | private $h; |
||
20 | |||
21 | /** |
||
22 | * Thrown exception. |
||
23 | * @var Throwable|Exception |
||
24 | */ |
||
25 | private $e; |
||
26 | |||
27 | /** |
||
28 | * Default options. |
||
29 | * @var CoOption |
||
30 | */ |
||
31 | private $options; |
||
32 | |||
33 | /** |
||
34 | * Constructor. |
||
35 | * @param Generator $g |
||
36 | * @param CoOption $options |
||
37 | * @param mixed $yield_key |
||
38 | */ |
||
39 | 15 | public function __construct(\Generator $g, CoOption $options = null, $yield_key = null) |
|
55 | |||
56 | /** |
||
57 | * Return options. |
||
58 | * @return CoOption |
||
59 | */ |
||
60 | 4 | public function getOptions() |
|
64 | |||
65 | /** |
||
66 | * Return generator hash. |
||
67 | * @return string |
||
68 | */ |
||
69 | 3 | public function __toString() |
|
73 | |||
74 | /** |
||
75 | * Return whether generator is actually working. |
||
76 | * @return bool |
||
77 | */ |
||
78 | 15 | public function valid() |
|
88 | |||
89 | /** |
||
90 | * Return current key. |
||
91 | * @return mixed |
||
92 | */ |
||
93 | 3 | public function key() |
|
98 | |||
99 | /** |
||
100 | * Return current value. |
||
101 | * @return mixed |
||
102 | */ |
||
103 | 6 | public function current() |
|
108 | |||
109 | /** |
||
110 | * Send value into generator. |
||
111 | * @param mixed $value |
||
112 | * @NOTE: This method returns nothing, |
||
113 | * while original generator returns something. |
||
114 | */ |
||
115 | 7 | public function send($value) |
|
124 | |||
125 | /** |
||
126 | * Throw exception into generator. |
||
127 | * @param RuntimeException $e |
||
128 | * @NOTE: This method returns nothing, |
||
129 | * while original generator returns something. |
||
130 | */ |
||
131 | 2 | public function throw_(\RuntimeException $e) |
|
140 | |||
141 | 3 | public function throwAcceptable() |
|
147 | |||
148 | /** |
||
149 | * Return whether exception is thrown. |
||
150 | * @return bool |
||
151 | */ |
||
152 | 6 | public function thrown() |
|
156 | |||
157 | /** |
||
158 | * Return value that generator has returned or thrown. |
||
159 | * @return mixed |
||
160 | */ |
||
161 | 8 | public function getReturnOrThrown() |
|
172 | |||
173 | /** |
||
174 | * Validate that generator has finished running. |
||
175 | * @throws LogicException |
||
176 | */ |
||
177 | 7 | private function validateValidity() |
|
183 | |||
184 | /** |
||
185 | * Validate that generator is still running. |
||
186 | * @throws LogicException |
||
187 | */ |
||
188 | 8 | private function validateInvalidity() |
|
194 | } |
||
195 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..