mirror of
https://codeberg.org/icewind/streams.git
synced 2026-06-03 16:44:07 +02:00
static::class is only since 5.5 :(
This commit is contained in:
parent
f47297b76a
commit
2e2fe951e9
3 changed files with 16 additions and 5 deletions
|
|
@ -55,6 +55,6 @@ class DirectoryFilter extends DirectoryWrapper {
|
||||||
'filter' => $filter
|
'filter' => $filter
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return self::wrapWithOptions($options);
|
return self::wrapWithOptions($options, '\Icewind\Streams\DirectoryFilter');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,11 +75,12 @@ class DirectoryWrapper implements Directory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $options the options for the context to wrap the stream with
|
* @param string $options the options for the context to wrap the stream with
|
||||||
|
* @param string $class
|
||||||
* @return resource
|
* @return resource
|
||||||
*/
|
*/
|
||||||
protected static function wrapWithOptions($options) {
|
protected static function wrapWithOptions($options, $class) {
|
||||||
$context = stream_context_create($options);
|
$context = stream_context_create($options);
|
||||||
stream_wrapper_register('dirwrapper', static::class);
|
stream_wrapper_register('dirwrapper', $class);
|
||||||
$wrapped = opendir('dirwrapper://', $context);
|
$wrapped = opendir('dirwrapper://', $context);
|
||||||
stream_wrapper_unregister('dirwrapper');
|
stream_wrapper_unregister('dirwrapper');
|
||||||
return $wrapped;
|
return $wrapped;
|
||||||
|
|
|
||||||
|
|
@ -7,13 +7,23 @@
|
||||||
|
|
||||||
namespace Icewind\Streams\Tests;
|
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, '\Icewind\Streams\Tests\DirectoryWrapperNull');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DirectoryWrapperDummy extends \Icewind\Streams\DirectoryWrapper {
|
class DirectoryWrapperDummy extends \Icewind\Streams\DirectoryWrapper {
|
||||||
public static function wrap($source) {
|
public static function wrap($source) {
|
||||||
$options = array(
|
$options = array(
|
||||||
'dir' => array(
|
'dir' => array(
|
||||||
'source' => $source)
|
'source' => $source)
|
||||||
);
|
);
|
||||||
return self::wrapWithOptions($options);
|
return self::wrapWithOptions($options, '\Icewind\Streams\Tests\DirectoryWrapperDummy');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dir_readdir() {
|
public function dir_readdir() {
|
||||||
|
|
@ -33,7 +43,7 @@ class DirectoryWrapper extends IteratorDirectory {
|
||||||
*/
|
*/
|
||||||
protected function wrapSource($source) {
|
protected function wrapSource($source) {
|
||||||
$dir = \Icewind\Streams\IteratorDirectory::wrap($source);
|
$dir = \Icewind\Streams\IteratorDirectory::wrap($source);
|
||||||
return \Icewind\Streams\DirectoryWrapper::wrap($dir);
|
return DirectoryWrapperNull::wrap($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testManipulateContent() {
|
public function testManipulateContent() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue