Issue #3316950 by mondrake: Fix StreamWrapper\ReadOnlyStream PHPStan-0 issues

(cherry picked from commit 4c187847dc)
merge-requests/2710/merge
catch 2022-10-24 15:57:12 +01:00
parent 32de7d7428
commit eeaaccc17e
2 changed files with 30 additions and 5 deletions

View File

@ -68,6 +68,9 @@ abstract class ReadOnlyStream implements StreamWrapperInterface {
* TRUE if $mode denotes a readonly mode and the file was opened
* successfully, FALSE otherwise.
*
* @throws \BadMethodCallException
* When ::getLocalPath() is not implemented in the concrete driver class.
*
* @see http://php.net/manual/streamwrapper.stream-open.php
*/
public function stream_open($uri, $mode, $options, &$opened_path) {
@ -89,6 +92,33 @@ abstract class ReadOnlyStream implements StreamWrapperInterface {
return (bool) $this->handle;
}
/**
* Returns the canonical absolute path of the URI, if possible.
*
* @param string $uri
* (optional) The stream wrapper URI to be converted to a canonical
* absolute path. This may point to a directory or another type of file.
*
* @return string|bool
* If $uri is not set, returns the canonical absolute path of the URI
* previously set by the
* Drupal\Core\StreamWrapper\StreamWrapperInterface::setUri() function.
* If $uri is set and valid for this class, returns its canonical absolute
* path, as determined by the realpath() function. If $uri is set but not
* valid, returns FALSE.
*
* @throws \BadMethodCallException
* If the method is not implemented in the concrete driver class.
*
* @todo This method is called by ReadOnlyStream::stream_open on the abstract
* class, and therefore should be defined as well on the abstract class to
* prevent static analysis errors. In D11, consider changing it to an
* abstract method.
*/
protected function getLocalPath($uri = NULL) {
throw new \BadMethodCallException(get_class($this) . '::getLocalPath() not implemented.');
}
/**
* Support for flock().
*

View File

@ -365,11 +365,6 @@ parameters:
count: 1
path: lib/Drupal/Core/Session/SessionManager.php
-
message: "#^Call to an undefined method Drupal\\\\Core\\\\StreamWrapper\\\\ReadOnlyStream\\:\\:getLocalPath\\(\\)\\.$#"
count: 1
path: lib/Drupal/Core/StreamWrapper/ReadOnlyStream.php
-
message: "#^Method Drupal\\\\Core\\\\Template\\\\AttributeValueBase\\:\\:render\\(\\) should return string but return statement is missing\\.$#"
count: 1