1 | <?php |
||
13 | class StreamRenderer implements RenderInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var RenderInterface |
||
17 | */ |
||
18 | private $renderer; |
||
19 | |||
20 | /** |
||
21 | * @var resource |
||
22 | */ |
||
23 | private $stream; |
||
24 | |||
25 | /** |
||
26 | * Pushed stream |
||
27 | * |
||
28 | * @var resource[] |
||
29 | */ |
||
30 | private $streams; |
||
31 | |||
32 | /** |
||
33 | * @var array |
||
34 | */ |
||
35 | private $hash = []; |
||
36 | |||
37 | /** |
||
38 | * @param RenderInterface $renderer |
||
39 | * |
||
40 | * @Named("renderer=original,stream=BEAR\Middleware\Annotation\Stream") |
||
41 | */ |
||
42 | 6 | public function __construct(RenderInterface $renderer, $stream) |
|
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | 5 | public function render(ResourceObject $ro) |
|
61 | |||
62 | /** |
||
63 | * Covert string + stream holder to stream |
||
64 | * |
||
65 | * @param string $string |
||
66 | * |
||
67 | * @return resource |
||
68 | */ |
||
69 | 5 | public function toStream($string) |
|
79 | |||
80 | /** |
||
81 | * @param resource $item |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | 3 | private function pushStream($item) |
|
94 | |||
95 | /** |
||
96 | * @param string $string |
||
97 | * @param resource $stream |
||
98 | * |
||
99 | * @return resource |
||
100 | */ |
||
101 | 3 | private function mergeStream($string, $stream) |
|
120 | |||
121 | /** |
||
122 | * @param array $match |
||
123 | * |
||
124 | * @return array |
||
125 | */ |
||
126 | 3 | private function collect(array $match) |
|
135 | |||
136 | /** |
||
137 | * @param ResourceObject $ro |
||
138 | * |
||
139 | * @return string |
||
140 | */ |
||
141 | 2 | private function pushScalarBody(ResourceObject $ro) |
|
149 | |||
150 | /** |
||
151 | * @param ResourceObject $ro |
||
152 | */ |
||
153 | 3 | private function pushArrayBody(ResourceObject $ro) |
|
161 | } |
||
162 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.