some extra type checks

This commit is contained in:
Robin Appelman 2019-03-11 17:16:21 +01:00
commit 782e09ec62
8 changed files with 24 additions and 13 deletions

View file

@ -47,7 +47,6 @@ class UrlCallback extends Wrapper implements Url {
* @return \Icewind\Streams\Path
*
* @throws \BadMethodCallException
* @throws \Exception
*/
public static function wrap($source, $fopen = null, $opendir = null, $mkdir = null, $rename = null, $rmdir = null,
$unlink = null, $stat = null) {
@ -78,21 +77,29 @@ class UrlCallback extends Wrapper implements Url {
public function stream_open($path, $mode, $options, &$opened_path) {
$context = $this->loadUrlContext($path);
$this->callCallBack($context, 'fopen');
$this->setSourceStream(fopen($context['source'], $mode));
$source = fopen($context['source'], $mode);
if ($source === false) {
return false;
}
$this->setSourceStream($source);
return true;
}
public function dir_opendir($path, $options) {
$context = $this->loadUrlContext($path);
$this->callCallBack($context, 'opendir');
$this->setSourceStream(opendir($context['source']));
$source = opendir($context['source']);
if ($source === false) {
return false;
}
$this->setSourceStream($source);
return true;
}
public function mkdir($path, $mode, $options) {
$context = $this->loadUrlContext($path);
$this->callCallBack($context, 'mkdir');
return mkdir($context['source'], $mode, $options & STREAM_MKDIR_RECURSIVE);
return mkdir($context['source'], $mode, ($options & STREAM_MKDIR_RECURSIVE) > 0);
}
public function rmdir($path, $options) {