Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace magic __toString method with toString #93

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/PSR7-Interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Same methods as `Psr\Http\Message\MessageInterface` + the following methods:

| Method Name | Description | Notes |
|------------------------------------| ----------- | ----- |
| `__toString()` | Reads all data from the stream into a string, from the beginning to end. | |
| `toString()` | Reads all data from the stream into a string, from the beginning to end. | |
| `close()` | Closes the stream and any underlying resources. | |
| `detach()` | Separates any underlying resources from the stream. | |
| `getSize()` | Get the size of the stream if known. | |
Expand Down Expand Up @@ -112,7 +112,7 @@ Same methods as `Psr\Http\Message\MessageInterface` + the following methods:
| `withPath($path)` | Return an instance with the specified path. | |
| `withQuery($query)` | Return an instance with the specified query string. | |
| `withFragment($fragment)` | Return an instance with the specified URI fragment. | |
| `__toString()` | Return the string representation as a URI reference. | |
| `toString()` | Return the string representation as a URI reference. | |

## `Psr\Http\Message\UploadedFileInterface` Methods

Expand Down
2 changes: 1 addition & 1 deletion src/StreamInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface StreamInterface
* @see http://php.net/manual/en/language.oop5.magic.php#object.tostring
* @return string
*/
public function __toString();
public function toString();

/**
* Closes the stream and any underlying resources.
Expand Down
4 changes: 2 additions & 2 deletions src/UriInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public function withFragment($fragment);
* - If an authority is present, it MUST be prefixed by "//".
* - The path can be concatenated without delimiters. But there are two
* cases where the path has to be adjusted to make the URI reference
* valid as PHP does not allow to throw an exception in __toString():
* valid:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if throwing exceptions for these cases would be an option now..

* - If the path is rootless and an authority is present, the path MUST
* be prefixed by "/".
* - If the path is starting with more than one "/" and no authority is
Expand All @@ -319,5 +319,5 @@ public function withFragment($fragment);
* @see http://tools.ietf.org/html/rfc3986#section-4.1
* @return string
*/
public function __toString();
public function toString();
}