rfc:ommit-double-slash-in-user-stream-wrapper-uri

PHP RFC: Remove requirement for authority portion of user stream wrapper URIs

Introduction

According to RFC 2396 defining URI Generic Syntax which specifies URI Syntactic Components:

The URI syntax is dependent upon the scheme.
The URI syntax does not require that the scheme-specific-part have
any general structure or set of semantics which is common among all
URI.

However it is not currently possible to declare user-defined Stream Wrapper and register valid protocol which could handle generic URI's. Currently there is requirement for authority portion :// after protocol name when protocol name from URL detection is called.

Proposal

This RFC proposes to add a new flag STREAM_IS_URI to use with stream_wrapper_register in a third parameter.

Passing the new flag allows a user defined Stream Wrapper class based on streamWrapper prototype to handle URI in their general syntax consisting of <scheme> and <scheme-specific-part> whose interpretation depends on the scheme.

Examples

class MyStreamWrapper {
  public function url_stat(string $path, int $flags) : array {
    print "Stating file: $path\n";
    return array('dev'=>1, 'ino'=>2, 'mode'=>0644, 'nlink'=>3,
        'uid'=>100, 'gid'=>1000, 'rdev'=>-1, 'size'=>31337,
        'atime'=>1234567890, 'mtime'=>1231231231, 'ctime'=>1234564564,
        'blksize'=>-1, 'blocks'=>-1);
  }
}
 
stream_wrapper_register('test', MyStreamWrapper::class, STREAM_IS_URI);
file_exists('test:file.txt');

Output:

Stating file: test:file.txt

Backward Incompatible Changes

No backward incompatible changes, when the additional flag is missing all handled paths are checked in case of double slash existence after the colon which behaves exactly the same way as currently.

Proposed PHP Version(s)

next PHP 7.x or PHP 8.0

RFC Impact

To SAPIs

No impact.

To Existing Extensions

No.

To Opcache

No.

New Constants

STREAM_IS_URI = 2 - allows user Stream Wrapper to handle all variety of URI's without double-slash after colon

Proposed Voting Choices

This project requires a 2/3 majority. The vote is a straight Yes/No vote for accepting the RFC and merging the patch.

Patches and Tests

rfc/ommit-double-slash-in-user-stream-wrapper-uri.txt · Last modified: 2017/09/22 13:28 (external edit)