cleanup context handling for wrappers

This commit is contained in:
Robin Appelman 2019-03-11 16:52:13 +01:00
commit 2c8ae56d02
16 changed files with 182 additions and 258 deletions

View file

@ -9,21 +9,13 @@ namespace Icewind\Streams\Tests;
class DirectoryWrapperNull extends \Icewind\Streams\DirectoryWrapper {
public static function wrap($source) {
$options = array(
'dir' => array(
'source' => $source)
);
return self::wrapWithOptions($options);
return self::wrapSource($source);
}
}
class DirectoryWrapperDummy extends \Icewind\Streams\DirectoryWrapper {
public static function wrap($source) {
$options = array(
'dir' => array(
'source' => $source)
);
return self::wrapWithOptions($options);
return self::wrapSource($source);
}
public function dir_readdir() {

View file

@ -8,20 +8,8 @@
namespace Icewind\Streams\Tests;
class PartialWrapper extends \Icewind\Streams\NullWrapper {
/**
* Wraps a stream with the provided callbacks
*
* @param resource $source
* @return resource
*
* @throws \BadMethodCallException
*/
public static function wrap($source) {
$context = stream_context_create(array(
'null' => array(
'source' => $source)
));
return self::wrapSource($source, $context);
return self::wrapSource($source);
}
public function stream_read($count) {
@ -36,20 +24,8 @@ class PartialWrapper extends \Icewind\Streams\NullWrapper {
}
class FailWrapper extends \Icewind\Streams\NullWrapper {
/**
* Wraps a stream with the provided callbacks
*
* @param resource $source
* @return resource
*
* @throws \BadMethodCallException
*/
public static function wrap($source) {
$context = stream_context_create(array(
'null' => array(
'source' => $source)
));
return self::wrapSource($source, $context);
return self::wrapSource($source);
}
public function stream_read($count) {