Merge pull request #15 from juliushaertl/enh/wrapsource-mode

Add mode parameter to wrapSource
This commit is contained in:
Robin Appelman 2021-06-14 14:02:48 +00:00 committed by GitHub
commit 0c6aae16eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,7 +57,7 @@ class WrapperHandler {
* @param string|null $class deprecated, class is now automatically generated
* @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) {
$class = static::class;
}
@ -72,7 +72,7 @@ class WrapperHandler {
if (self::isDirectoryHandle($source)) {
return opendir($protocol . '://', $context);
} else {
return fopen($protocol . '://', 'r+', false, $context);
return fopen($protocol . '://', $mode, false, $context);
}
} finally {
stream_wrapper_unregister($protocol);