call callbacks after running the stream operation

This commit is contained in:
Robin Appelman 2014-07-24 00:45:45 +02:00
commit acb8b69108

View file

@ -20,7 +20,7 @@ namespace Icewind\Streams;
* ] * ]
* ] * ]
* *
* All callbacks are called before the operation is executed on the source stream * All callbacks are called after the operation is executed on the source stream
*/ */
class CallBackWrapper extends Wrapper { class CallBackWrapper extends Wrapper {
/** /**
@ -54,23 +54,26 @@ class CallBackWrapper extends Wrapper {
} }
public function stream_read($count) { public function stream_read($count) {
$result = parent::stream_read($count);
if ($this->readCallback) { if ($this->readCallback) {
call_user_func($this->readCallback, $count); call_user_func($this->readCallback, $count);
} }
return parent::stream_read($count); return $result;
} }
public function stream_write($data) { public function stream_write($data) {
$result = parent::stream_write($data);
if ($this->writeCallback) { if ($this->writeCallback) {
call_user_func($this->writeCallback, $data); call_user_func($this->writeCallback, $data);
} }
return parent::stream_write($data); return $result;
} }
public function stream_close() { public function stream_close() {
$result = parent::stream_close();
if ($this->closeCallback) { if ($this->closeCallback) {
call_user_func($this->closeCallback); call_user_func($this->closeCallback);
} }
return parent::stream_close(); return $result;
} }
} }