1 | <?php |
||
16 | class Swift_ByteStream_ArrayByteStream implements Swift_InputByteStream, Swift_OutputByteStream |
||
|
|||
17 | { |
||
18 | /** |
||
19 | * The internal stack of bytes. |
||
20 | * |
||
21 | * @var string[] |
||
22 | */ |
||
23 | private $_array = array(); |
||
24 | |||
25 | /** |
||
26 | * The size of the stack. |
||
27 | * |
||
28 | * @var int |
||
29 | */ |
||
30 | private $_arraySize = 0; |
||
31 | |||
32 | /** |
||
33 | * The internal pointer offset. |
||
34 | * |
||
35 | * @var int |
||
36 | */ |
||
37 | private $_offset = 0; |
||
38 | |||
39 | /** |
||
40 | * Bound streams. |
||
41 | * |
||
42 | * @var Swift_InputByteStream[] |
||
43 | */ |
||
44 | private $_mirrors = array(); |
||
45 | |||
46 | /** |
||
47 | * Create a new ArrayByteStream. |
||
48 | * |
||
49 | * If $stack is given the stream will be populated with the bytes it contains. |
||
50 | * |
||
51 | * @param mixed $stack of bytes in string or array form, optional |
||
52 | */ |
||
53 | 32 | public function __construct($stack = null) |
|
64 | |||
65 | /** |
||
66 | * Reads $length bytes from the stream into a string and moves the pointer |
||
67 | * through the stream by $length. |
||
68 | * |
||
69 | * If less bytes exist than are requested the |
||
70 | * remaining bytes are given instead. If no bytes are remaining at all, boolean |
||
71 | * false is returned. |
||
72 | * |
||
73 | * @param int $length |
||
74 | * |
||
75 | * @return string |
||
76 | */ |
||
77 | 29 | public function read($length) |
|
93 | |||
94 | /** |
||
95 | * Writes $bytes to the end of the stream. |
||
96 | * |
||
97 | * @param string $bytes |
||
98 | */ |
||
99 | 24 | public function write($bytes) |
|
111 | |||
112 | /** |
||
113 | * Not used. |
||
114 | */ |
||
115 | 4 | public function commit() |
|
118 | |||
119 | /** |
||
120 | * Attach $is to this stream. |
||
121 | * |
||
122 | * The stream acts as an observer, receiving all data that is written. |
||
123 | * All {@link write()} and {@link flushBuffers()} operations will be mirrored. |
||
124 | * |
||
125 | * @param Swift_InputByteStream $is |
||
126 | */ |
||
127 | 7 | public function bind(Swift_InputByteStream $is) |
|
131 | |||
132 | /** |
||
133 | * Remove an already bound stream. |
||
134 | * |
||
135 | * If $is is not bound, no errors will be raised. |
||
136 | * If the stream currently has any buffered data it will be written to $is |
||
137 | * before unbinding occurs. |
||
138 | * |
||
139 | * @param Swift_InputByteStream $is |
||
140 | */ |
||
141 | 5 | public function unbind(Swift_InputByteStream $is) |
|
149 | |||
150 | /** |
||
151 | * Move the internal read pointer to $byteOffset in the stream. |
||
152 | * |
||
153 | * @param int $byteOffset |
||
154 | * |
||
155 | * @return bool |
||
156 | */ |
||
157 | 8 | public function setReadPointer($byteOffset) |
|
167 | |||
168 | /** |
||
169 | * Flush the contents of the stream (empty it) and set the internal pointer |
||
170 | * to the beginning. |
||
171 | */ |
||
172 | 2 | public function flushBuffers() |
|
182 | } |
||
183 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.