Skip to content

Commit

Permalink
Continue fixing stream wrapper-related regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
antecedent committed Feb 19, 2023
1 parent e792b06 commit 17314e0
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/CodeManipulation/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,15 @@ public static function getOtherWrapper($context)
}
}

public static function alternate(callable $internal, $resource, $wrapped, array $args = [], $context = null, $shouldReturnResource = false)
public static function alternate(callable $internal, $resource, $wrapped, array $args = [], array $extraArgs = [], $context = null, $shouldReturnResource = false)
{
$shouldAddResourceArg = true;
if ($resource === null) {
$resource = static::getOtherWrapper($context);
$shouldAddResourceArg = false;
}
if (is_object($resource)) {
$args = array_merge($args, $extraArgs);
$ladder = function() use ($resource, $wrapped, $args) {
switch (count($args)) {
case 0:
Expand Down Expand Up @@ -245,7 +246,7 @@ public function url_stat($path, $flags)
}
return $result;
};
return static::alternate($internal, null, __FUNCTION__, [$path, $flags], $this->context);
return static::alternate($internal, null, __FUNCTION__, [$path, $flags], [], $this->context);
}

public function dir_closedir()
Expand All @@ -255,7 +256,7 @@ public function dir_closedir()

public function dir_opendir($path, $options)
{
$this->resource = static::alternate('opendir', null, __FUNCTION__, [$path], $this->context);
$this->resource = static::alternate('opendir', null, __FUNCTION__, [$path], [$options], $this->context);
return $this->resource !== false;
}

Expand All @@ -271,17 +272,17 @@ public function dir_rewinddir()

public function mkdir($path, $mode, $options)
{
return static::alternate('mkdir', null, __FUNCTION__, [$path, $mode, $options]);
return static::alternate('mkdir', null, __FUNCTION__, [$path, $mode, $options], [], $this->context);
}

public function rename($pathFrom, $pathTo)
{
return static::alternate('rename', null, __FUNCTION__, [$pathFrom, $pathTo]);
return static::alternate('rename', null, __FUNCTION__, [$pathFrom, $pathTo], [], $this->context);
}

public function rmdir($path, $options)
{
return static::alternate('rmdir', null, __FUNCTION__, [$path, $options]);
return static::alternate('rmdir', null, __FUNCTION__, [$path], [$options], $this->context);
}

public function stream_cast($castAs)
Expand Down Expand Up @@ -328,7 +329,7 @@ public static function fwrite($resource, $data)

public function unlink($path)
{
return static::alternate('unlink', $this->resource, __FUNCTION__, [$path], $this->context);
return static::alternate('unlink', $this->resource, __FUNCTION__, [$path], [], $this->context);
}

public function stream_metadata($path, $option, $value)
Expand Down

0 comments on commit 17314e0

Please sign in to comment.