Add mode parameter to wrapSource

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2021-05-25 09:14:38 +02:00
commit c492db92a2
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF

View file

@ -57,7 +57,7 @@ class WrapperHandler {
* @param string|null $class deprecated, class is now automatically generated * @param string|null $class deprecated, class is now automatically generated
* @return bool|resource * @return bool|resource
*/ */
protected static function wrapSource($source, $context = [], $protocol = null, $class = null) { protected static function wrapSource($source, $context = [], $protocol = null, $class = null, $mode = 'r+') {
if ($class === null) { if ($class === null) {
$class = static::class; $class = static::class;
} }
@ -72,7 +72,7 @@ class WrapperHandler {
if (self::isDirectoryHandle($source)) { if (self::isDirectoryHandle($source)) {
return opendir($protocol . '://', $context); return opendir($protocol . '://', $context);
} else { } else {
return fopen($protocol . '://', 'r+', false, $context); return fopen($protocol . '://', $mode, false, $context);
} }
} finally { } finally {
stream_wrapper_unregister($protocol); stream_wrapper_unregister($protocol);