Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
This patch updates PSR-7 to always use `@return static` instead of `@return self`
within method annotations, as done in php-fig/http-message#50. Per the
discussion on that issue, `static` is interpreted by phpDoc and most IDEs in
such a way that it always resolves to the class against which it was invoked,
and not the defining class, unlike `self`, which always resolves to the class in
which it was originally defined. Additionally, `static` has the *connotation*
that a new instance, not the same instance, will be returned — which is the
intention as outlined already in each method providing such a return value.
  • Loading branch information
weierophinney committed Aug 3, 2016
1 parent f8a76eb commit 2b845a6
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions accepted/PSR-7-http-message.md
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ interface MessageInterface
* new protocol version.
*
* @param string $version HTTP protocol version
* @return self
* @return static
*/
public function withProtocolVersion($version);

Expand Down Expand Up @@ -721,7 +721,7 @@ interface MessageInterface
*
* @param string $name Case-insensitive header field name.
* @param string|string[] $value Header value(s).
* @return self
* @return static
* @throws \InvalidArgumentException for invalid header names or values.
*/
public function withHeader($name, $value);
Expand All @@ -739,7 +739,7 @@ interface MessageInterface
*
* @param string $name Case-insensitive header field name to add.
* @param string|string[] $value Header value(s).
* @return self
* @return static
* @throws \InvalidArgumentException for invalid header names.
* @throws \InvalidArgumentException for invalid header values.
*/
Expand All @@ -755,7 +755,7 @@ interface MessageInterface
* the named header.
*
* @param string $name Case-insensitive header field name to remove.
* @return self
* @return static
*/
public function withoutHeader($name);

Expand All @@ -776,7 +776,7 @@ interface MessageInterface
* new body stream.
*
* @param StreamInterface $body Body.
* @return self
* @return static
* @throws \InvalidArgumentException When the body is not valid.
*/
public function withBody(StreamInterface $body);
Expand Down Expand Up @@ -843,7 +843,7 @@ interface RequestInterface extends MessageInterface
* @see http://tools.ietf.org/html/rfc7230#section-5.3 (for the various
* request-target forms allowed in request messages)
* @param mixed $requestTarget
* @return self
* @return static
*/
public function withRequestTarget($requestTarget);

Expand All @@ -866,7 +866,7 @@ interface RequestInterface extends MessageInterface
* changed request method.
*
* @param string $method Case-sensitive method.
* @return self
* @return static
* @throws \InvalidArgumentException for invalid HTTP methods.
*/
public function withMethod($method);
Expand Down Expand Up @@ -910,7 +910,7 @@ interface RequestInterface extends MessageInterface
* @see http://tools.ietf.org/html/rfc3986#section-4.3
* @param UriInterface $uri New request URI to use.
* @param bool $preserveHost Preserve the original state of the Host header.
* @return self
* @return static
*/
public function withUri(UriInterface $uri, $preserveHost = false);
}
Expand Down Expand Up @@ -1000,7 +1000,7 @@ interface ServerRequestInterface extends RequestInterface
* updated cookie values.
*
* @param array $cookies Array of key/value pairs representing cookies.
* @return self
* @return static
*/
public function withCookieParams(array $cookies);

Expand Down Expand Up @@ -1038,7 +1038,7 @@ interface ServerRequestInterface extends RequestInterface
*
* @param array $query Array of query string arguments, typically from
* $_GET.
* @return self
* @return static
*/
public function withQueryParams(array $query);

Expand All @@ -1064,7 +1064,7 @@ interface ServerRequestInterface extends RequestInterface
* updated body parameters.
*
* @param array $uploadedFiles An array tree of UploadedFileInterface instances.
* @return self
* @return static
* @throws \InvalidArgumentException if an invalid structure is provided.
*/
public function withUploadedFiles(array $uploadedFiles);
Expand Down Expand Up @@ -1110,7 +1110,7 @@ interface ServerRequestInterface extends RequestInterface
*
* @param null|array|object $data The deserialized body data. This will
* typically be in an array or object.
* @return self
* @return static
* @throws \InvalidArgumentException if an unsupported argument type is
* provided.
*/
Expand Down Expand Up @@ -1159,7 +1159,7 @@ interface ServerRequestInterface extends RequestInterface
* @see getAttributes()
* @param string $name The attribute name.
* @param mixed $value The value of the attribute.
* @return self
* @return static
*/
public function withAttribute($name, $value);

Expand All @@ -1175,7 +1175,7 @@ interface ServerRequestInterface extends RequestInterface
*
* @see getAttributes()
* @param string $name The attribute name.
* @return self
* @return static
*/
public function withoutAttribute($name);
}
Expand Down Expand Up @@ -1231,7 +1231,7 @@ interface ResponseInterface extends MessageInterface
* @param string $reasonPhrase The reason phrase to use with the
* provided status code; if none is provided, implementations MAY
* use the defaults as suggested in the HTTP specification.
* @return self
* @return static
* @throws \InvalidArgumentException For invalid status code arguments.
*/
public function withStatus($code, $reasonPhrase = '');
Expand Down Expand Up @@ -1605,7 +1605,7 @@ interface UriInterface
* An empty scheme is equivalent to removing the scheme.
*
* @param string $scheme The scheme to use with the new instance.
* @return self A new instance with the specified scheme.
* @return static A new instance with the specified scheme.
* @throws \InvalidArgumentException for invalid schemes.
* @throws \InvalidArgumentException for unsupported schemes.
*/
Expand All @@ -1623,7 +1623,7 @@ interface UriInterface
*
* @param string $user The user name to use for authority.
* @param null|string $password The password associated with $user.
* @return self A new instance with the specified user information.
* @return static A new instance with the specified user information.
*/
public function withUserInfo($user, $password = null);

Expand All @@ -1636,7 +1636,7 @@ interface UriInterface
* An empty host value is equivalent to removing the host.
*
* @param string $host The hostname to use with the new instance.
* @return self A new instance with the specified host.
* @return static A new instance with the specified host.
* @throws \InvalidArgumentException for invalid hostnames.
*/
public function withHost($host);
Expand All @@ -1655,7 +1655,7 @@ interface UriInterface
*
* @param null|int $port The port to use with the new instance; a null value
* removes the port information.
* @return self A new instance with the specified port.
* @return static A new instance with the specified port.
* @throws \InvalidArgumentException for invalid ports.
*/
public function withPort($port);
Expand All @@ -1679,7 +1679,7 @@ interface UriInterface
* Implementations ensure the correct encoding as outlined in getPath().
*
* @param string $path The path to use with the new instance.
* @return self A new instance with the specified path.
* @return static A new instance with the specified path.
* @throws \InvalidArgumentException for invalid paths.
*/
public function withPath($path);
Expand All @@ -1696,7 +1696,7 @@ interface UriInterface
* An empty query string value is equivalent to removing the query string.
*
* @param string $query The query string to use with the new instance.
* @return self A new instance with the specified query string.
* @return static A new instance with the specified query string.
* @throws \InvalidArgumentException for invalid query strings.
*/
public function withQuery($query);
Expand All @@ -1713,7 +1713,7 @@ interface UriInterface
* An empty fragment value is equivalent to removing the fragment.
*
* @param string $fragment The fragment to use with the new instance.
* @return self A new instance with the specified fragment.
* @return static A new instance with the specified fragment.
*/
public function withFragment($fragment);

Expand Down

0 comments on commit 2b845a6

Please sign in to comment.