Problem

  1. PHP core does not provide an actual StreamWrapperInterface.

  2. PHP core only defines a prototype/example StreamWrapper class implementation.

  3. This prototype/example implementation can change with newer PHP versions — e.g. in terms of available methods, expected parameters, or return values.

Task

  1. All of the methods on the PhpStreamWrapperInterface should have a copy of the phpDoc (docblock) of the prototype/example class that is currently implemented.

Comments

fietserwin’s picture

sun’s picture

fietserwin’s picture

Let's extend this issue to correct/improve/unify/deduplicate documentation on classes that implement this interface, see #2213241-35: Fully conform to PHP5.4 streamwrapper class.

fietserwin’s picture

The parent is in. Can we get this in as well? I have not much time this month, but if no one else steps in, I will try to come up with a patch.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone credited jungle.

quietone credited phayes.

quietone’s picture

Version: 8.9.x-dev » 9.3.x-dev
StatusFileSize
new14.42 KB

Closed #2902424: Completing PhpStreamWrapperInterface inline documentation as a duplicate. Uploading the latest patch from there to here, adding credit.
Then review that patch based on the comment from Kirsten Pol in 2902424#16.

quietone’s picture

Issue tags: +Bug Smash Initiative

The patch in #17 does address the issues raised in the duplicate in comment #16. That means that this is ready for review.

I do have a question. Why are we duplicating documentation that is the Php docs?

quietone’s picture

Status: Active » Needs review
kristen pol’s picture

@quietone asked:

Why are we duplicating documentation that is the Php docs?

That's an excellent question :) I'm not sure. But, since that's what was being done, I reviewed based on that. Maybe it shouldn't have been done in the first place? Not sure what the protocol is for such things or who we should ask.

amber himes matz’s picture

Title: PhpStreamWrapperInterface lacks phpDoc » PhpStreamWrapperInterface lacks docblocks
Issue summary: View changes

phpDoc is a API documenting standard and does not refer to a specific set of documentation, such as PHP core API documentation. We tend to see the more commonly used term "docblock".

I don't believe it's accurate to say we're duplicating documentation in PHP's docs in this patch. They are only referenced in @see lines. This patch is rectifying the lack of any docblocks for the methods in PhpStreamWrapperInterface.

I've updated the title and issue summary to use the word "docblock" in place of "phpdoc" to try and clarify this.

longwave’s picture

Status: Needs review » Needs work

I agree this is necessary because PHP doesn't provide an interface itself here, although end users of this subsystem are expected to conform to the interface all the same. If we document them then IDE users that are developing stream wrappers will get helpful documentation about these methods,

As part of this patch we can also remove the duplicated (but less detailed) docblocks in LocalStream and replace them with @inheritdoc.

+++ b/core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php
@@ -10,37 +10,142 @@
+   * @see streamWrapper::dir_readdir()
...
+   * @see streamwrapper::rmdir()
...
+   * @see streamwrapper::mkdir()
+   * @see streamwrapper::unlink()

@@ -65,21 +170,76 @@ public function stream_cast($cast_as);
+   * @see streamWrapper::dir_closedir()

@@ -183,12 +401,30 @@ public function stream_seek($offset, $whence = SEEK_SET);
+   * @see streamwrapper::url_stat()
...
+   * @see streamWrapper::stream_tell()

@@ -202,21 +438,85 @@ public function stream_tell();
+   * @see streamWrapper::rmdir()
...
+   * @see streamwrapper::stream_stat()

I don't think any of the "@see streamWrapper::" lines are useful as we don't have such a class in core, they seem to be referring to the original PHP example docs. We should either refer to methods on *this* interface or remove these.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new19.77 KB
new23.38 KB

I don't believe it's accurate to say we're duplicating documentation in PHP's docs in this patch.

The task IS does say to copy the docs what is implemented and what is implemented is the PHP Stream Wrapper class. Also this review is clearly referred to the documentation for www.php.net.

I am confused. Maybe if I work on the patch it will make sense.

I have updated the patch with the suggestions in #22. I have also moved comments that were after the @return to the top part of the docblock.

No, still confused. :-)

longwave’s picture

Status: Needs review » Needs work

Looking good, just a couple of points:

  1. +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
    @@ -384,39 +307,17 @@ public function unlink($uri) {
    +    [$scheme] = explode('://', $uri, 2);
    

    This change is out of scope (PHPStorm likely did this automatically).

  2. +++ b/core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php
    @@ -10,37 +10,144 @@
    +   * generated by streamWrapper::dir_readdir(). The next call to
    +   * streamWrapper::dir_readdir() should return the first entry in the
    +   * location returned by streamWrapper::dir_opendir().
    

    Unsure what we should do to these references to streamWrapper, as they are from the original docs. I suppose we should just replace them with this interface?

  3. +++ b/core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php
    @@ -10,37 +10,144 @@
    +   * Note, the streamWrapper::$context property is updated if a valid context is
    

    This reference is more tricky because $context is expected to exist on the stream wrapper object, but interfaces can't define properties.

quietone’s picture

Status: Needs work » Needs review
StatusFileSize
new4.21 KB
new24.15 KB

1. Fixed
2. Yes, these are from the original docs. I changed them to PhpStreamWrapperInterface::
3. The only idea I had was to add a comment in the class doc bloc but I couldn't think of any text!

kristen pol’s picture

Thanks for the update. I reviewed the interdiff and have some feedback:

  1. The PhpStreamWrapperInterface changes seem okay.
  2. +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
    @@ -2,6 +2,8 @@
    +use org\bovigo\vfs\vfsStreamWrapper;
    +
    

    I'm unclear why this was added.

  3. +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
    @@ -416,6 +418,7 @@ public function dir_rewinddir() {
    +    $a = new vfsStreamWrapper();
    

    Ditto.

  4. +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
    @@ -89,7 +91,7 @@ protected function getTarget($uri = NULL) {
    -    list(, $target) = explode('://', $uri, 2);
    +    [, $target] = explode('://', $uri, 2);
    

    #24.1 is referencing the code below but the interdiff has the above, so this confused me.

    +++ b/core/lib/Drupal/Core/StreamWrapper/LocalStream.php
    @@ -384,39 +309,17 @@ public function unlink($uri) {
       public function dirname($uri = NULL) {
    -    list($scheme) = explode('://', $uri, 2);
    +    [$scheme] = explode('://', $uri, 2);
    
quietone’s picture

StatusFileSize
new1.14 KB
new23.42 KB

@Kristen Pol, thnaks.

1. Yay!
2. I don't remember why I added that, removed now.
3. This time I really have removed all accidental format changes.
4. Ah, I must have been playing around with a test. It is removed.

quietone’s picture

StatusFileSize
new1.8 KB
new23.42 KB

Yes, I forgot to run commit-code-check.

kristen pol’s picture

Thanks for the update.

  1. Looks like everything from #26 is covered by #27
  2. "Spelling" changes seem okay in #28
  3. Tests pass
  4. Manual testing is not needed as this is documentation
  5. The only thing I'm unclear about is #24.3 so leaving open for review
longwave’s picture

Status: Needs review » Needs work

I don't have any better suggestions about the $context property, as this is copied from the PHP docs I don't think there is much else we can say or do. Other than the nits below this looks ready to go to me.

  1. +++ b/core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php
    @@ -116,12 +279,73 @@ public function stream_lock($operation);
    +   * Note the `streamWrapper::$context` property is updated if a valid context
    

    We don't usually use Markdown-style backticks in core, this is slightly different from the other instances of this note.

  2. +++ b/core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php
    @@ -116,12 +279,73 @@ public function stream_lock($operation);
    +   *   delimited by `://` are supported. `:` and `:/` while technically valid
    

    Same here, we should use double quotes probably.

  3. +++ b/core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php
    @@ -202,21 +444,86 @@ public function stream_tell();
    +   *   a `://` delimited URL. Other URL forms are not supported.
    

    And here

quietone’s picture

StatusFileSize
new1.61 KB
new23.42 KB

1. Wasn't sure if you wanted double quotes here. I have just removed the back ticks.
2 and 3. Now use doube quotes..

quietone’s picture

Status: Needs work » Needs review
longwave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, this looks good to go.

alexpott’s picture

Version: 9.3.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: +Documentation

Backported to 9.2.x as this only changes documentation.

Committed and pushed ca2c3d48a3 to 9.3.x and 5831c967c7 to 9.2.x. Thanks!

  • alexpott committed ca2c3d4 on 9.3.x
    Issue #2228087 by quietone, longwave, Kristen Pol, jungle, VladimirAus,...

  • alexpott committed 5831c96 on 9.2.x
    Issue #2228087 by quietone, longwave, Kristen Pol, jungle, VladimirAus,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.