1 | <?php |
||
17 | abstract class Socket implements SocketStream |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * The socket handle |
||
22 | * |
||
23 | * @var resource |
||
24 | */ |
||
25 | protected $handle; |
||
26 | |||
27 | /** |
||
28 | * The socket endpoint |
||
29 | * |
||
30 | * @var Endpoint |
||
31 | */ |
||
32 | protected $endpoint; |
||
33 | |||
34 | /** |
||
35 | * Create a new socket |
||
36 | * |
||
37 | * @param Endpoint $endpoint |
||
38 | * The endpoint for the socket |
||
39 | */ |
||
40 | 11 | public function __construct(Endpoint $endpoint) |
|
41 | { |
||
42 | 11 | $this->endpoint = $endpoint; |
|
43 | 11 | $this->handle = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); |
|
44 | |||
45 | 11 | if (! is_resource($this->handle)) { |
|
46 | $code = socket_last_error(); |
||
47 | throw new SocketException(socket_strerror($code), $code); |
||
48 | } |
||
49 | 11 | } |
|
50 | |||
51 | /** |
||
52 | * Clean up |
||
53 | */ |
||
54 | 11 | public function __destruct() |
|
58 | |||
59 | /** |
||
60 | * {@inheritDoc} |
||
61 | * @see \Generics\Streams\Stream::close() |
||
62 | */ |
||
63 | public function close() |
||
70 | 6 | ||
71 | /** |
||
72 | * {@inheritDoc} |
||
73 | * @see \Generics\Streams\Stream::ready() |
||
74 | */ |
||
75 | public function ready() |
||
104 | 6 | ||
105 | /** |
||
106 | * {@inheritDoc} |
||
107 | * @see \Generics\Streams\OutputStream::isWriteable() |
||
108 | */ |
||
109 | public function isWriteable() |
||
138 | |||
139 | 1 | /** |
|
140 | * {@inheritDoc} |
||
141 | * @see \Countable::count() |
||
142 | */ |
||
143 | public function count() |
||
147 | |||
148 | /** |
||
149 | * {@inheritDoc} |
||
150 | * @see \Generics\Streams\InputStream::read() |
||
151 | */ |
||
152 | public function read($length = 1, $offset = null) |
||
168 | |||
169 | /** |
||
170 | * {@inheritDoc} |
||
171 | 6 | * @see \Generics\Streams\OutputStream::write() |
|
172 | */ |
||
173 | public function write($buffer) |
||
187 | |||
188 | /** |
||
189 | * Get the socket endpoint |
||
190 | * |
||
191 | * @return \Generics\Socket\Endpoint |
||
192 | 7 | */ |
|
193 | public function getEndpoint() |
||
197 | |||
198 | /** |
||
199 | 7 | * {@inheritDoc} |
|
200 | * @see \Generics\Streams\OutputStream::flush() |
||
201 | 7 | */ |
|
202 | public function flush() |
||
206 | |||
207 | /** |
||
208 | * {@inheritDoc} |
||
209 | * @see \Generics\Streams\Stream::isOpen() |
||
210 | */ |
||
211 | public function isOpen() |
||
215 | } |
||
216 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: