From b4705c5f5cec0282549549d745f6266fd71bca3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=A9rub=C3=A9?= Date: Sun, 5 May 2019 13:26:38 -0600 Subject: [PATCH 1/4] rename LICENSE to LICENSE.md --- LICENSE => LICENSE.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LICENSE => LICENSE.md (100%) diff --git a/LICENSE b/LICENSE.md similarity index 100% rename from LICENSE rename to LICENSE.md From 4cbc928badf54f528b2b1447360c1f8aa8780ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=A9rub=C3=A9?= Date: Sun, 5 May 2019 13:48:46 -0600 Subject: [PATCH 2/4] fix all docblocks and file headers --- src/Factory/DecoratedResponseFactory.php | 12 +- src/Factory/DecoratedServerRequestFactory.php | 15 +- src/Factory/DecoratedUriFactory.php | 12 +- src/Response.php | 191 +------- src/ServerRequest.php | 415 ++---------------- src/Uri.php | 265 +---------- .../Providers/NyholmPsr17FactoryProvider.php | 11 +- tests/Providers/Psr17FactoryProvider.php | 11 +- .../ZendDiactorosPsr17FactoryProvider.php | 14 +- tests/Psr7Integration/Nyholm/ResponseTest.php | 8 +- .../Nyholm/ServerRequestTest.php | 9 +- tests/Psr7Integration/Nyholm/UriTest.php | 10 +- tests/Psr7Integration/Zend/ResponseTest.php | 8 +- .../Zend/ServerRequestTest.php | 10 +- tests/Psr7Integration/Zend/UriTest.php | 10 +- tests/ResponseTest.php | 12 +- tests/ServerRequestTest.php | 17 +- tests/TestCase.php | 13 +- tests/UriTest.php | 16 +- tests/bootstrap.php | 8 + 20 files changed, 170 insertions(+), 897 deletions(-) diff --git a/src/Factory/DecoratedResponseFactory.php b/src/Factory/DecoratedResponseFactory.php index fe598b2..2d63053 100644 --- a/src/Factory/DecoratedResponseFactory.php +++ b/src/Factory/DecoratedResponseFactory.php @@ -2,10 +2,11 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Http\Factory; use Psr\Http\Message\ResponseFactoryInterface; @@ -13,10 +14,6 @@ use Psr\Http\Message\StreamFactoryInterface; use Slim\Http\Response; -/** - * Class DecoratedResponseFactory - * @package Slim\Http\Factory - */ class DecoratedResponseFactory implements ResponseFactoryInterface { /** @@ -30,7 +27,6 @@ class DecoratedResponseFactory implements ResponseFactoryInterface private $streamFactory; /** - * DecoratedResponseFactory constructor. * @param ResponseFactoryInterface $responseFactory * @param StreamFactoryInterface $streamFactory */ diff --git a/src/Factory/DecoratedServerRequestFactory.php b/src/Factory/DecoratedServerRequestFactory.php index 6335e9d..7a9b65b 100644 --- a/src/Factory/DecoratedServerRequestFactory.php +++ b/src/Factory/DecoratedServerRequestFactory.php @@ -2,20 +2,18 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Http\Factory; use Psr\Http\Message\ServerRequestFactoryInterface; use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\UriInterface; use Slim\Http\ServerRequest; -/** - * Class DecoratedServerRequestFactory - * @package Slim\Http\Factory - */ class DecoratedServerRequestFactory implements ServerRequestFactoryInterface { /** @@ -24,7 +22,6 @@ class DecoratedServerRequestFactory implements ServerRequestFactoryInterface private $serverRequestFactory; /** - * DecoratedServerRequestFactory constructor. * @param ServerRequestFactoryInterface $serverRequestFactory */ public function __construct(ServerRequestFactoryInterface $serverRequestFactory) @@ -34,7 +31,7 @@ public function __construct(ServerRequestFactoryInterface $serverRequestFactory) /** * @param string $method - * @param \Psr\Http\Message\UriInterface|string $uri + * @param UriInterface|string $uri * @param array $serverParams * @return ServerRequest */ diff --git a/src/Factory/DecoratedUriFactory.php b/src/Factory/DecoratedUriFactory.php index 4b54eac..5d27523 100644 --- a/src/Factory/DecoratedUriFactory.php +++ b/src/Factory/DecoratedUriFactory.php @@ -2,20 +2,17 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Http\Factory; use Psr\Http\Message\UriFactoryInterface; use Psr\Http\Message\UriInterface; use Slim\Http\Uri; -/** - * Class DecoratedUriFactory - * @package Slim\Http\Factory - */ class DecoratedUriFactory implements UriFactoryInterface { /** @@ -24,7 +21,6 @@ class DecoratedUriFactory implements UriFactoryInterface private $uriFactory; /** - * DecoratedUriFactory constructor. * @param UriFactoryInterface $uriFactory */ public function __construct(UriFactoryInterface $uriFactory) diff --git a/src/Response.php b/src/Response.php index b4c2672..a73d0f2 100644 --- a/src/Response.php +++ b/src/Response.php @@ -2,22 +2,18 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Http; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; -use InvalidArgumentException; use RuntimeException; -/** - * Class Response - * @package Slim\Http - */ class Response implements ResponseInterface { /** @@ -38,7 +34,6 @@ class Response implements ResponseInterface const EOL = "\r\n"; /** - * Response constructor. * @param ResponseInterface $response * @param StreamFactoryInterface $streamFactory */ @@ -58,9 +53,7 @@ public function __set($name, $value) } /** - * Gets the body of the message. - * - * @return StreamInterface Returns the body as a stream. + * {@inheritdoc} */ public function getBody() { @@ -68,18 +61,7 @@ public function getBody() } /** - * Retrieves a message header value by the given case-insensitive name. - * - * This method returns an array of all the header values of the given - * case-insensitive header name. - * - * If the header does not appear in the message, this method MUST return an - * empty array. - * - * @param string $name Case-insensitive header field name. - * @return string[] An array of string values as provided for the given - * header. If the header does not appear in the message, this method MUST - * return an empty array. + * {@inheritdoc} */ public function getHeader($name) { @@ -87,23 +69,7 @@ public function getHeader($name) } /** - * Retrieves a comma-separated string of the values for a single header. - * - * This method returns all of the header values of the given - * case-insensitive header name as a string concatenated together using - * a comma. - * - * NOTE: Not all header values may be appropriately represented using - * comma concatenation. For such headers, use getHeader() instead - * and supply your own delimiter when concatenating. - * - * If the header does not appear in the message, this method MUST return - * an empty string. - * - * @param string $name Case-insensitive header field name. - * @return string A string of values as provided for the given header - * concatenated together using a comma. If the header does not appear in - * the message, this method MUST return an empty string. + * {@inheritdoc} */ public function getHeaderLine($name) { @@ -111,29 +77,7 @@ public function getHeaderLine($name) } /** - * Retrieves all message header values. - * - * The keys represent the header name as it will be sent over the wire, and - * each value is an array of strings associated with the header. - * - * // Represent the headers as a string - * foreach ($message->getHeaders() as $name => $values) { - * echo $name . ": " . implode(", ", $values); - * } - * - * // Emit headers iteratively: - * foreach ($message->getHeaders() as $name => $values) { - * foreach ($values as $value) { - * header(sprintf('%s: %s', $name, $value), false); - * } - * } - * - * While header names are not case-sensitive, getHeaders() will preserve the - * exact case in which headers were originally specified. - * - * @return string[][] Returns an associative array of the message's headers. Each - * key MUST be a header name, and each value MUST be an array of strings - * for that header. + * {@inheritdoc} */ public function getHeaders() { @@ -141,11 +85,7 @@ public function getHeaders() } /** - * Retrieves the HTTP protocol version as a string. - * - * The string MUST contain only the HTTP version number (e.g., "1.1", "1.0"). - * - * @return string HTTP protocol version. + * {@inheritdoc} */ public function getProtocolVersion() { @@ -153,17 +93,7 @@ public function getProtocolVersion() } /** - * Gets the response reason phrase associated with the status code. - * - * Because a reason phrase is not a required element in a response - * status line, the reason phrase value MAY be null. Implementations MAY - * choose to return the default RFC 7231 recommended reason phrase (or those - * listed in the IANA HTTP Status Code Registry) for the response's - * status code. - * - * @link http://tools.ietf.org/html/rfc7231#section-6 - * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml - * @return string Reason phrase; must return an empty string if none present. + * {@inheritdoc} */ public function getReasonPhrase() { @@ -171,12 +101,7 @@ public function getReasonPhrase() } /** - * Gets the response status code. - * - * The status code is a 3-digit integer result code of the server's attempt - * to understand and satisfy the request. - * - * @return int Status code. + * {@inheritdoc} */ public function getStatusCode() { @@ -184,12 +109,7 @@ public function getStatusCode() } /** - * Checks if a header exists by the given case-insensitive name. - * - * @param string $name Case-insensitive header field name. - * @return bool Returns true if any header names match the given header - * name using a case-insensitive string comparison. Returns false if - * no matching header name is found in the message. + * {@inheritdoc} */ public function hasHeader($name) { @@ -197,20 +117,7 @@ public function hasHeader($name) } /** - * Return an instance with the specified header appended with the given value. - * - * Existing values for the specified header will be maintained. The new - * value(s) will be appended to the existing list. If the header did not - * exist previously, it will be added. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new header and/or value. - * - * @param string $name Case-insensitive header field name to add. - * @param string|string[] $value Header value(s). - * @return static - * @throws InvalidArgumentException for invalid header names or values. + * {@inheritdoc} */ public function withAddedHeader($name, $value) { @@ -219,17 +126,7 @@ public function withAddedHeader($name, $value) } /** - * Return an instance with the specified message body. - * - * The body MUST be a StreamInterface object. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return a new instance that has the - * new body stream. - * - * @param StreamInterface $body Body. - * @return static - * @throws InvalidArgumentException When the body is not valid. + * {@inheritdoc} */ public function withBody(StreamInterface $body) { @@ -238,19 +135,7 @@ public function withBody(StreamInterface $body) } /** - * Return an instance with the provided value replacing the specified header. - * - * While header names are case-insensitive, the casing of the header will - * be preserved by this function, and returned from getHeaders(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new and/or updated header and value. - * - * @param string $name Case-insensitive header field name. - * @param string|string[] $value Header value(s). - * @return static - * @throws InvalidArgumentException for invalid header names or values. + * {@inheritdoc} */ public function withHeader($name, $value) { @@ -259,16 +144,7 @@ public function withHeader($name, $value) } /** - * Return an instance without the specified header. - * - * Header resolution MUST be done without case-sensitivity. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that removes - * the named header. - * - * @param string $name Case-insensitive header field name to remove. - * @return static + * {@inheritdoc} */ public function withoutHeader($name) { @@ -277,17 +153,7 @@ public function withoutHeader($name) } /** - * Return an instance with the specified HTTP protocol version. - * - * The version string MUST contain only the HTTP version number (e.g., - * "1.1", "1.0"). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new protocol version. - * - * @param string $version HTTP protocol version - * @return static + * {@inheritdoc} */ public function withProtocolVersion($version) { @@ -296,24 +162,7 @@ public function withProtocolVersion($version) } /** - * Return an instance with the specified status code and, optionally, reason phrase. - * - * If no reason phrase is specified, implementations MAY choose to default - * to the RFC 7231 or IANA recommended reason phrase for the response's - * status code. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated status and reason phrase. - * - * @link http://tools.ietf.org/html/rfc7231#section-6 - * @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml - * @param int $code The 3-digit integer result code to set. - * @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 static - * @throws InvalidArgumentException For invalid status code arguments. + * {@inheritdoc} */ public function withStatus($code, $reasonPhrase = '') { @@ -322,7 +171,7 @@ public function withStatus($code, $reasonPhrase = '') } /** - * Json. + * Write JSON to Response Body. * * Note: This method is not part of the PSR-7 standard. * @@ -355,7 +204,7 @@ public function withJson($data, int $status = null, int $options = 0, int $depth } /** - * Redirect. + * Redirect to specified location * * Note: This method is not part of the PSR-7 standard. * diff --git a/src/ServerRequest.php b/src/ServerRequest.php index 2193111..badca40 100644 --- a/src/ServerRequest.php +++ b/src/ServerRequest.php @@ -2,23 +2,19 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Http; +use Closure; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; -use Closure; -use InvalidArgumentException; use RuntimeException; -/** - * Class ServerRequest - * @package Slim\Http - */ class ServerRequest implements ServerRequestInterface { /** @@ -32,7 +28,6 @@ class ServerRequest implements ServerRequestInterface private $bodyParsers; /** - * ServerRequest constructor. * @param ServerRequestInterface $serverRequest */ public function __construct(ServerRequestInterface $serverRequest) @@ -97,19 +92,7 @@ public function __set($name, $value) } /** - * Retrieve a single derived request attribute. - * - * Retrieves a single derived request attribute as described in - * getAttributes(). If the attribute has not been previously set, returns - * the default value as provided. - * - * This method obviates the need for a hasAttribute() method, as it allows - * specifying a default value to return if the attribute is not found. - * - * @see getAttributes() - * @param string $name The attribute name. - * @param mixed $default Default value to return if the attribute does not exist. - * @return mixed + * {@inheritdoc} */ public function getAttribute($name, $default = null) { @@ -117,15 +100,7 @@ public function getAttribute($name, $default = null) } /** - * Retrieve attributes derived from the request. - * - * The request "attributes" may be used to allow injection of any - * parameters derived from the request: e.g., the results of path - * match operations; the results of decrypting cookies; the results of - * deserializing non-form-encoded message bodies; etc. Attributes - * will be application and request specific, and CAN be mutable. - * - * @return array Attributes derived from the request. + * {@inheritdoc} */ public function getAttributes() { @@ -133,9 +108,7 @@ public function getAttributes() } /** - * Gets the body of the message. - * - * @return StreamInterface Returns the body as a stream. + * {@inheritdoc} */ public function getBody() { @@ -143,14 +116,7 @@ public function getBody() } /** - * Retrieve cookies. - * - * Retrieves cookies sent by the client to the server. - * - * The data MUST be compatible with the structure of the $_COOKIE - * superglobal. - * - * @return array + * {@inheritdoc} */ public function getCookieParams() { @@ -158,18 +124,7 @@ public function getCookieParams() } /** - * Retrieves a message header value by the given case-insensitive name. - * - * This method returns an array of all the header values of the given - * case-insensitive header name. - * - * If the header does not appear in the message, this method MUST return an - * empty array. - * - * @param string $name Case-insensitive header field name. - * @return string[] An array of string values as provided for the given - * header. If the header does not appear in the message, this method MUST - * return an empty array. + * {@inheritdoc} */ public function getHeader($name) { @@ -177,23 +132,7 @@ public function getHeader($name) } /** - * Retrieves a comma-separated string of the values for a single header. - * - * This method returns all of the header values of the given - * case-insensitive header name as a string concatenated together using - * a comma. - * - * NOTE: Not all header values may be appropriately represented using - * comma concatenation. For such headers, use getHeader() instead - * and supply your own delimiter when concatenating. - * - * If the header does not appear in the message, this method MUST return - * an empty string. - * - * @param string $name Case-insensitive header field name. - * @return string A string of values as provided for the given header - * concatenated together using a comma. If the header does not appear in - * the message, this method MUST return an empty string. + * {@inheritdoc} */ public function getHeaderLine($name) { @@ -201,29 +140,7 @@ public function getHeaderLine($name) } /** - * Retrieves all message header values. - * - * The keys represent the header name as it will be sent over the wire, and - * each value is an array of strings associated with the header. - * - * // Represent the headers as a string - * foreach ($message->getHeaders() as $name => $values) { - * echo $name . ": " . implode(", ", $values); - * } - * - * // Emit headers iteratively: - * foreach ($message->getHeaders() as $name => $values) { - * foreach ($values as $value) { - * header(sprintf('%s: %s', $name, $value), false); - * } - * } - * - * While header names are not case-sensitive, getHeaders() will preserve the - * exact case in which headers were originally specified. - * - * @return string[][] Returns an associative array of the message's headers. Each - * key MUST be a header name, and each value MUST be an array of strings - * for that header. + * {@inheritdoc} */ public function getHeaders() { @@ -231,9 +148,7 @@ public function getHeaders() } /** - * Retrieves the HTTP method of the request. - * - * @return string Returns the request method. + * {@inheritdoc} */ public function getMethod() { @@ -241,19 +156,7 @@ public function getMethod() } /** - * Retrieve any parameters provided in the request body. - * - * If the request Content-Type is either application/x-www-form-urlencoded - * or multipart/form-data, and the request method is POST, this method MUST - * return the contents of $_POST. - * - * Otherwise, this method may return any results of deserializing - * the request body content; as parsing returns structured content, the - * potential types MUST be arrays or objects only. A null value indicates - * the absence of body content. - * - * @return null|array|object The deserialized body parameters, if any. - * These will typically be an array or object. + * {@inheritdoc} */ public function getParsedBody() { @@ -294,11 +197,7 @@ public function getParsedBody() } /** - * Retrieves the HTTP protocol version as a string. - * - * The string MUST contain only the HTTP version number (e.g., "1.1", "1.0"). - * - * @return string HTTP protocol version. + * {@inheritdoc} */ public function getProtocolVersion() { @@ -306,16 +205,7 @@ public function getProtocolVersion() } /** - * Retrieve query string arguments. - * - * Retrieves the deserialized query string arguments, if any. - * - * Note: the query params might not be in sync with the URI or server - * params. If you need to ensure you are only getting the original - * values, you may need to parse the query string from `getUri()->getQuery()` - * or from the `QUERY_STRING` server param. - * - * @return array + * {@inheritdoc} */ public function getQueryParams() { @@ -332,20 +222,7 @@ public function getQueryParams() } /** - * Retrieves the message's request target. - * - * Retrieves the message's request-target either as it will appear (for - * clients), as it appeared at request (for servers), or as it was - * specified for the instance (see withRequestTarget()). - * - * In most cases, this will be the origin-form of the composed URI, - * unless a value was provided to the concrete implementation (see - * withRequestTarget() below). - * - * If no URI is available, and no request-target has been specifically - * provided, this method MUST return the string "/". - * - * @return string + * {@inheritdoc} */ public function getRequestTarget() { @@ -353,13 +230,7 @@ public function getRequestTarget() } /** - * Retrieve server parameters. - * - * Retrieves data related to the incoming request environment, - * typically derived from PHP's $_SERVER superglobal. The data IS NOT - * REQUIRED to originate from $_SERVER. - * - * @return array + * {@inheritdoc} */ public function getServerParams() { @@ -367,16 +238,7 @@ public function getServerParams() } /** - * Retrieve normalized file upload data. - * - * This method returns upload metadata in a normalized tree, with each leaf - * an instance of Psr\Http\Message\UploadedFileInterface. - * - * These values MAY be prepared from $_FILES or the message body during - * instantiation, or MAY be injected via withUploadedFiles(). - * - * @return array An array tree of UploadedFileInterface instances; an empty - * array MUST be returned if no data is present. + * {@inheritdoc} */ public function getUploadedFiles() { @@ -384,13 +246,7 @@ public function getUploadedFiles() } /** - * Retrieves the URI instance. - * - * This method MUST return a UriInterface instance. - * - * @link http://tools.ietf.org/html/rfc3986#section-4.3 - * @return UriInterface Returns a UriInterface instance - * representing the URI of the request. + * {@inheritdoc} */ public function getUri() { @@ -398,12 +254,7 @@ public function getUri() } /** - * Checks if a header exists by the given case-insensitive name. - * - * @param string $name Case-insensitive header field name. - * @return bool Returns true if any header names match the given header - * name using a case-insensitive string comparison. Returns false if - * no matching header name is found in the message. + * {@inheritdoc} */ public function hasHeader($name) { @@ -411,20 +262,7 @@ public function hasHeader($name) } /** - * Return an instance with the specified header appended with the given value. - * - * Existing values for the specified header will be maintained. The new - * value(s) will be appended to the existing list. If the header did not - * exist previously, it will be added. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new header and/or value. - * - * @param string $name Case-insensitive header field name to add. - * @param string|string[] $value Header value(s). - * @return static - * @throws InvalidArgumentException for invalid header names or values. + * {@inheritdoc} */ public function withAddedHeader($name, $value) { @@ -433,19 +271,7 @@ public function withAddedHeader($name, $value) } /** - * Return an instance with the specified derived request attribute. - * - * This method allows setting a single derived request attribute as - * described in getAttributes(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated attribute. - * - * @see getAttributes() - * @param string $name The attribute name. - * @param mixed $value The value of the attribute. - * @return static + * {@inheritdoc} */ public function withAttribute($name, $value) { @@ -480,18 +306,7 @@ public function withAttributes(array $attributes) } /** - * Return an instance that removes the specified derived request attribute. - * - * This method allows removing a single derived request attribute as - * described in getAttributes(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that removes - * the attribute. - * - * @see getAttributes() - * @param string $name The attribute name. - * @return static + * {@inheritdoc} */ public function withoutAttribute($name) { @@ -500,17 +315,7 @@ public function withoutAttribute($name) } /** - * Return an instance with the specified message body. - * - * The body MUST be a StreamInterface object. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return a new instance that has the - * new body stream. - * - * @param StreamInterface $body Body. - * @return static - * @throws InvalidArgumentException When the body is not valid. + * {@inheritdoc} */ public function withBody(StreamInterface $body) { @@ -519,21 +324,7 @@ public function withBody(StreamInterface $body) } /** - * Return an instance with the specified cookies. - * - * The data IS NOT REQUIRED to come from the $_COOKIE superglobal, but MUST - * be compatible with the structure of $_COOKIE. Typically, this data will - * be injected at instantiation. - * - * This method MUST NOT update the related Cookie header of the request - * instance, nor related values in the server params. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated cookie values. - * - * @param array $cookies Array of key/value pairs representing cookies. - * @return static + * {@inheritdoc} */ public function withCookieParams(array $cookies) { @@ -542,19 +333,7 @@ public function withCookieParams(array $cookies) } /** - * Return an instance with the provided value replacing the specified header. - * - * While header names are case-insensitive, the casing of the header will - * be preserved by this function, and returned from getHeaders(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new and/or updated header and value. - * - * @param string $name Case-insensitive header field name. - * @param string|string[] $value Header value(s). - * @return static - * @throws InvalidArgumentException for invalid header names or values. + * {@inheritdoc} */ public function withHeader($name, $value) { @@ -563,16 +342,7 @@ public function withHeader($name, $value) } /** - * Return an instance without the specified header. - * - * Header resolution MUST be done without case-sensitivity. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that removes - * the named header. - * - * @param string $name Case-insensitive header field name to remove. - * @return static + * {@inheritdoc} */ public function withoutHeader($name) { @@ -581,19 +351,7 @@ public function withoutHeader($name) } /** - * Return an instance with the provided HTTP method. - * - * While HTTP method names are typically all uppercase characters, HTTP - * method names are case-sensitive and thus implementations SHOULD NOT - * modify the given string. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * changed request method. - * - * @param string $method Case-sensitive method. - * @return static - * @throws InvalidArgumentException for invalid HTTP methods. + * {@inheritdoc} */ public function withMethod($method) { @@ -602,32 +360,7 @@ public function withMethod($method) } /** - * Return an instance with the specified body parameters. - * - * These MAY be injected during instantiation. - * - * If the request Content-Type is either application/x-www-form-urlencoded - * or multipart/form-data, and the request method is POST, use this method - * ONLY to inject the contents of $_POST. - * - * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of - * deserializing the request body content. Deserialization/parsing returns - * structured data, and, as such, this method ONLY accepts arrays or objects, - * or a null value if nothing was available to parse. - * - * As an example, if content negotiation determines that the request data - * is a JSON payload, this method could be used to create a request - * instance with the deserialized parameters. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated body parameters. - * - * @param null|array|object $data The deserialized body data. This will - * typically be in an array or object. - * @return static - * @throws InvalidArgumentException if an unsupported argument type is - * provided. + * {@inheritdoc} */ public function withParsedBody($data) { @@ -636,17 +369,7 @@ public function withParsedBody($data) } /** - * Return an instance with the specified HTTP protocol version. - * - * The version string MUST contain only the HTTP version number (e.g., - * "1.1", "1.0"). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new protocol version. - * - * @param string $version HTTP protocol version - * @return static + * {@inheritdoc} */ public function withProtocolVersion($version) { @@ -655,26 +378,7 @@ public function withProtocolVersion($version) } /** - * Return an instance with the specified query string arguments. - * - * These values SHOULD remain immutable over the course of the incoming - * request. They MAY be injected during instantiation, such as from PHP's - * $_GET superglobal, or MAY be derived from some other value such as the - * URI. In cases where the arguments are parsed from the URI, the data - * MUST be compatible with what PHP's parse_str() would return for - * purposes of how duplicate query parameters are handled, and how nested - * sets are handled. - * - * Setting query string arguments MUST NOT change the URI stored by the - * request, nor the values in the server params. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated query string arguments. - * - * @param array $query Array of query string arguments, typically from - * $_GET. - * @return static + * {@inheritdoc} */ public function withQueryParams(array $query) { @@ -683,21 +387,7 @@ public function withQueryParams(array $query) } /** - * Return an instance with the specific request-target. - * - * If the request needs a non-origin-form request-target — e.g., for - * specifying an absolute-form, authority-form, or asterisk-form — - * this method may be used to create an instance with the specified - * request-target, verbatim. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * changed request target. - * - * @link http://tools.ietf.org/html/rfc7230#section-5.3 (for the various - * request-target forms allowed in request messages) - * @param mixed $requestTarget - * @return static + * {@inheritdoc} */ public function withRequestTarget($requestTarget) { @@ -706,15 +396,7 @@ public function withRequestTarget($requestTarget) } /** - * Create a new instance with the specified uploaded files. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated body parameters. - * - * @param array $uploadedFiles An array tree of UploadedFileInterface instances. - * @return static - * @throws InvalidArgumentException if an invalid structure is provided. + * {@inheritdoc} */ public function withUploadedFiles(array $uploadedFiles) { @@ -723,34 +405,7 @@ public function withUploadedFiles(array $uploadedFiles) } /** - * Returns an instance with the provided URI. - * - * This method MUST update the Host header of the returned request by - * default if the URI contains a host component. If the URI does not - * contain a host component, any pre-existing Host header MUST be carried - * over to the returned request. - * - * You can opt-in to preserving the original state of the Host header by - * setting `$preserveHost` to `true`. When `$preserveHost` is set to - * `true`, this method interacts with the Host header in the following ways: - * - * - If the Host header is missing or empty, and the new URI contains - * a host component, this method MUST update the Host header in the returned - * request. - * - If the Host header is missing or empty, and the new URI does not contain a - * host component, this method MUST NOT update the Host header in the returned - * request. - * - If a Host header is present and non-empty, this method MUST NOT update - * the Host header in the returned request. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new UriInterface instance. - * - * @link 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 static + * {@inheritdoc} */ public function withUri(UriInterface $uri, $preserveHost = false) { diff --git a/src/Uri.php b/src/Uri.php index c32ccb5..1e3e0a1 100644 --- a/src/Uri.php +++ b/src/Uri.php @@ -2,19 +2,15 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Http; use Psr\Http\Message\UriInterface; -use InvalidArgumentException; -/** - * Class Uri - * @package Slim\Http - */ class Uri implements UriInterface { /** @@ -23,7 +19,6 @@ class Uri implements UriInterface private $uri; /** - * Uri constructor. * @param UriInterface $uri */ public function __construct(UriInterface $uri) @@ -41,22 +36,7 @@ public function __set($name, $value) } /** - * Retrieve the authority component of the URI. - * - * If no authority information is present, this method MUST return an empty - * string. - * - * The authority syntax of the URI is: - * - *
-     * [user-info@]host[:port]
-     * 
- * - * If the port component is not set or is the standard port for the current - * scheme, it SHOULD NOT be included. - * - * @see https://tools.ietf.org/html/rfc3986#section-3.2 - * @return string The URI authority, in "[user-info@]host[:port]" format. + * {@inheritdoc} */ public function getAuthority() { @@ -64,20 +44,7 @@ public function getAuthority() } /** - * Retrieve the fragment component of the URI. - * - * If no fragment is present, this method MUST return an empty string. - * - * The leading "#" character is not part of the fragment and MUST NOT be - * added. - * - * The value returned MUST be percent-encoded, but MUST NOT double-encode - * any characters. To determine what characters to encode, please refer to - * RFC 3986, Sections 2 and 3.5. - * - * @see https://tools.ietf.org/html/rfc3986#section-2 - * @see https://tools.ietf.org/html/rfc3986#section-3.5 - * @return string The URI fragment. + * {@inheritdoc} */ public function getFragment() { @@ -85,15 +52,7 @@ public function getFragment() } /** - * Retrieve the host component of the URI. - * - * If no host is present, this method MUST return an empty string. - * - * The value returned MUST be normalized to lowercase, per RFC 3986 - * Section 3.2.2. - * - * @see http://tools.ietf.org/html/rfc3986#section-3.2.2 - * @return string The URI host. + * {@inheritdoc} */ public function getHost() { @@ -101,29 +60,7 @@ public function getHost() } /** - * Retrieve the path component of the URI. - * - * The path can either be empty or absolute (starting with a slash) or - * rootless (not starting with a slash). Implementations MUST support all - * three syntaxes. - * - * Normally, the empty path "" and absolute path "/" are considered equal as - * defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically - * do this normalization because in contexts with a trimmed base path, e.g. - * the front controller, this difference becomes significant. It's the task - * of the user to handle both "" and "/". - * - * The value returned MUST be percent-encoded, but MUST NOT double-encode - * any characters. To determine what characters to encode, please refer to - * RFC 3986, Sections 2 and 3.3. - * - * As an example, if the value should include a slash ("/") not intended as - * delimiter between path segments, that value MUST be passed in encoded - * form (e.g., "%2F") to the instance. - * - * @see https://tools.ietf.org/html/rfc3986#section-2 - * @see https://tools.ietf.org/html/rfc3986#section-3.3 - * @return string The URI path. + * {@inheritdoc} */ public function getPath() { @@ -131,19 +68,7 @@ public function getPath() } /** - * Retrieve the port component of the URI. - * - * If a port is present, and it is non-standard for the current scheme, - * this method MUST return it as an integer. If the port is the standard port - * used with the current scheme, this method SHOULD return null. - * - * If no port is present, and no scheme is present, this method MUST return - * a null value. - * - * If no port is present, but a scheme is present, this method MAY return - * the standard port for that scheme, but SHOULD return null. - * - * @return null|int The URI port. + * {@inheritdoc} */ public function getPort() { @@ -151,24 +76,7 @@ public function getPort() } /** - * Retrieve the query string of the URI. - * - * If no query string is present, this method MUST return an empty string. - * - * The leading "?" character is not part of the query and MUST NOT be - * added. - * - * The value returned MUST be percent-encoded, but MUST NOT double-encode - * any characters. To determine what characters to encode, please refer to - * RFC 3986, Sections 2 and 3.4. - * - * As an example, if a value in a key/value pair of the query string should - * include an ampersand ("&") not intended as a delimiter between values, - * that value MUST be passed in encoded form (e.g., "%26") to the instance. - * - * @see https://tools.ietf.org/html/rfc3986#section-2 - * @see https://tools.ietf.org/html/rfc3986#section-3.4 - * @return string The URI query string. + * {@inheritdoc} */ public function getQuery() { @@ -176,18 +84,7 @@ public function getQuery() } /** - * Retrieve the scheme component of the URI. - * - * If no scheme is present, this method MUST return an empty string. - * - * The value returned MUST be normalized to lowercase, per RFC 3986 - * Section 3.1. - * - * The trailing ":" character is not part of the scheme and MUST NOT be - * added. - * - * @see https://tools.ietf.org/html/rfc3986#section-3.1 - * @return string The URI scheme. + * {@inheritdoc} */ public function getScheme() { @@ -195,19 +92,7 @@ public function getScheme() } /** - * Retrieve the user information component of the URI. - * - * If no user information is present, this method MUST return an empty - * string. - * - * If a user is present in the URI, this will return that value; - * additionally, if the password is also present, it will be appended to the - * user value, with a colon (":") separating the values. - * - * The trailing "@" character is not part of the user information and MUST - * NOT be added. - * - * @return string The URI user information, in "username[:password]" format. + * {@inheritdoc} */ public function getUserInfo() { @@ -215,18 +100,7 @@ public function getUserInfo() } /** - * Return an instance with the specified URI fragment. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified URI fragment. - * - * Users can provide both encoded and decoded fragment characters. - * Implementations ensure the correct encoding as outlined in getFragment(). - * - * An empty fragment value is equivalent to removing the fragment. - * - * @param string $fragment The fragment to use with the new instance. - * @return static A new instance with the specified fragment. + * {@inheritdoc} */ public function withFragment($fragment) { @@ -235,16 +109,7 @@ public function withFragment($fragment) } /** - * Return an instance with the specified host. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified host. - * - * An empty host value is equivalent to removing the host. - * - * @param string $host The hostname to use with the new instance. - * @return static A new instance with the specified host. - * @throws InvalidArgumentException for invalid hostnames. + * {@inheritdoc} */ public function withHost($host) { @@ -253,26 +118,7 @@ public function withHost($host) } /** - * Return an instance with the specified path. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified path. - * - * The path can either be empty or absolute (starting with a slash) or - * rootless (not starting with a slash). Implementations MUST support all - * three syntaxes. - * - * If the path is intended to be domain-relative rather than path relative then - * it must begin with a slash ("/"). Paths not starting with a slash ("/") - * are assumed to be relative to some base path known to the application or - * consumer. - * - * Users can provide both encoded and decoded path characters. - * Implementations ensure the correct encoding as outlined in getPath(). - * - * @param string $path The path to use with the new instance. - * @return static A new instance with the specified path. - * @throws InvalidArgumentException for invalid paths. + * {@inheritdoc} */ public function withPath($path) { @@ -281,21 +127,7 @@ public function withPath($path) } /** - * Return an instance with the specified port. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified port. - * - * Implementations MUST raise an exception for ports outside the - * established TCP and UDP port ranges. - * - * A null value provided for the port is equivalent to removing the port - * information. - * - * @param null|int $port The port to use with the new instance; a null value - * removes the port information. - * @return static A new instance with the specified port. - * @throws InvalidArgumentException for invalid ports. + * {@inheritdoc} */ public function withPort($port) { @@ -304,19 +136,7 @@ public function withPort($port) } /** - * Return an instance with the specified query string. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified query string. - * - * Users can provide both encoded and decoded query characters. - * Implementations ensure the correct encoding as outlined in getQuery(). - * - * 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 static A new instance with the specified query string. - * @throws InvalidArgumentException for invalid query strings. + * {@inheritdoc} */ public function withQuery($query) { @@ -325,19 +145,7 @@ public function withQuery($query) } /** - * Return an instance with the specified scheme. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified scheme. - * - * Implementations MUST support the schemes "http" and "https" case - * insensitively, and MAY accommodate other schemes if required. - * - * An empty scheme is equivalent to removing the scheme. - * - * @param string $scheme The scheme to use with the new instance. - * @return static A new instance with the specified scheme. - * @throws InvalidArgumentException for invalid or unsupported schemes. + * {@inheritdoc} */ public function withScheme($scheme) { @@ -346,18 +154,7 @@ public function withScheme($scheme) } /** - * Return an instance with the specified user information. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified user information. - * - * Password is optional, but the user information MUST include the - * user; an empty string for the user is equivalent to removing user - * information. - * - * @param string $user The user name to use for authority. - * @param null|string $password The password associated with $user. - * @return static A new instance with the specified user information. + * {@inheritdoc} */ public function withUserInfo($user, $password = null) { @@ -366,27 +163,7 @@ public function withUserInfo($user, $password = null) } /** - * Return the string representation as a URI reference. - * - * Depending on which components of the URI are present, the resulting - * string is either a full URI or relative reference according to RFC 3986, - * Section 4.1. The method concatenates the various components of the URI, - * using the appropriate delimiters: - * - * - If a scheme is present, it MUST be suffixed by ":". - * - 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(): - * - 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 - * present, the starting slashes MUST be reduced to one. - * - If a query is present, it MUST be prefixed by "?". - * - If a fragment is present, it MUST be prefixed by "#". - * - * @see http://tools.ietf.org/html/rfc3986#section-4.1 - * @return string + * {@inheritdoc} */ public function __toString() { @@ -396,7 +173,7 @@ public function __toString() /** * Return the fully qualified base URL. * - * Note that this method never includes a trailing / + * Note that this method never includes a trailing slash * * This method is not part of PSR-7. * diff --git a/tests/Providers/NyholmPsr17FactoryProvider.php b/tests/Providers/NyholmPsr17FactoryProvider.php index ced687a..e235b69 100644 --- a/tests/Providers/NyholmPsr17FactoryProvider.php +++ b/tests/Providers/NyholmPsr17FactoryProvider.php @@ -2,18 +2,15 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http\Providers; use Nyholm\Psr7\Factory\Psr17Factory; -/** - * Class NyholmPsr17FactoryProvider - * @package Slim\Tests\Http - */ class NyholmPsr17FactoryProvider extends Psr17FactoryProvider { public function __construct() diff --git a/tests/Providers/Psr17FactoryProvider.php b/tests/Providers/Psr17FactoryProvider.php index fd47e84..d1f0cee 100644 --- a/tests/Providers/Psr17FactoryProvider.php +++ b/tests/Providers/Psr17FactoryProvider.php @@ -2,10 +2,11 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http\Providers; use Psr\Http\Message\ResponseFactoryInterface; @@ -14,10 +15,6 @@ use Psr\Http\Message\UploadedFileFactoryInterface; use Psr\Http\Message\UriFactoryInterface; -/** - * Interface Psr17FactoryProvider - * @package Slim\Tests\Http - */ abstract class Psr17FactoryProvider { /** diff --git a/tests/Providers/ZendDiactorosPsr17FactoryProvider.php b/tests/Providers/ZendDiactorosPsr17FactoryProvider.php index 93baec1..7855038 100644 --- a/tests/Providers/ZendDiactorosPsr17FactoryProvider.php +++ b/tests/Providers/ZendDiactorosPsr17FactoryProvider.php @@ -2,10 +2,11 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http\Providers; use Zend\Diactoros\ResponseFactory; @@ -14,15 +15,8 @@ use Zend\Diactoros\UploadedFileFactory; use Zend\Diactoros\UriFactory; -/** - * Class ZendDiactorosPsr17FactoryProvider - * @package Slim\Tests\Http - */ class ZendDiactorosPsr17FactoryProvider extends Psr17FactoryProvider { - /** - * @inheritdoc - */ public function __construct() { $this->responseFactory = new ResponseFactory(); diff --git a/tests/Psr7Integration/Nyholm/ResponseTest.php b/tests/Psr7Integration/Nyholm/ResponseTest.php index 6dc9665..e973bce 100644 --- a/tests/Psr7Integration/Nyholm/ResponseTest.php +++ b/tests/Psr7Integration/Nyholm/ResponseTest.php @@ -2,10 +2,11 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http\Psr7Integration\Nyholm; use Http\Psr7Test\ResponseIntegrationTest; @@ -21,6 +22,7 @@ public static function setUpBeforeClass() define('STREAM_FACTORY', Psr17Factory::class); } } + public function createSubject() { $provider = new NyholmPsr17FactoryProvider(); diff --git a/tests/Psr7Integration/Nyholm/ServerRequestTest.php b/tests/Psr7Integration/Nyholm/ServerRequestTest.php index 9a2089d..5f5af92 100644 --- a/tests/Psr7Integration/Nyholm/ServerRequestTest.php +++ b/tests/Psr7Integration/Nyholm/ServerRequestTest.php @@ -2,10 +2,11 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http\Psr7Integration\Nyholm; use Http\Psr7Test\ServerRequestIntegrationTest; @@ -23,7 +24,7 @@ public static function setUpBeforeClass() } public function createSubject() { - $provider = new NyholmPsr17FactoryProvider; + $provider = new NyholmPsr17FactoryProvider(); $decoratedServerRequestFactory = new DecoratedServerRequestFactory($provider->getServerRequestFactory()); return $decoratedServerRequestFactory->createServerRequest('GET', 'http://foo.com', $_SERVER); diff --git a/tests/Psr7Integration/Nyholm/UriTest.php b/tests/Psr7Integration/Nyholm/UriTest.php index b0a4cc2..e45d998 100644 --- a/tests/Psr7Integration/Nyholm/UriTest.php +++ b/tests/Psr7Integration/Nyholm/UriTest.php @@ -2,10 +2,11 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http\Psr7Integration\Nyholm; use Http\Psr7Test\UriIntegrationTest; @@ -21,9 +22,10 @@ public static function setUpBeforeClass() define('STREAM_FACTORY', Psr17Factory::class); } } + public function createUri($uri) { - $provider = new NyholmPsr17FactoryProvider; + $provider = new NyholmPsr17FactoryProvider(); $decoratedUriFactory = new DecoratedUriFactory($provider->getUriFactory()); return $decoratedUriFactory->createUri($uri); diff --git a/tests/Psr7Integration/Zend/ResponseTest.php b/tests/Psr7Integration/Zend/ResponseTest.php index 265446d..d268b4e 100644 --- a/tests/Psr7Integration/Zend/ResponseTest.php +++ b/tests/Psr7Integration/Zend/ResponseTest.php @@ -2,10 +2,11 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http\Psr7Integration\Zend; use Http\Psr7Test\ResponseIntegrationTest; @@ -21,6 +22,7 @@ public static function setUpBeforeClass() define('STREAM_FACTORY', StreamFactory::class); } } + public function createSubject() { $provider = new ZendDiactorosPsr17FactoryProvider(); diff --git a/tests/Psr7Integration/Zend/ServerRequestTest.php b/tests/Psr7Integration/Zend/ServerRequestTest.php index 0027529..4798ba5 100644 --- a/tests/Psr7Integration/Zend/ServerRequestTest.php +++ b/tests/Psr7Integration/Zend/ServerRequestTest.php @@ -2,10 +2,11 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http\Psr7Integration\Zend; use Http\Psr7Test\ServerRequestIntegrationTest; @@ -21,9 +22,10 @@ public static function setUpBeforeClass() define('STREAM_FACTORY', StreamFactory::class); } } + public function createSubject() { - $provider = new ZendDiactorosPsr17FactoryProvider; + $provider = new ZendDiactorosPsr17FactoryProvider(); $decoratedServerRequestFactory = new DecoratedServerRequestFactory($provider->getServerRequestFactory()); return $decoratedServerRequestFactory->createServerRequest('GET', 'http://foo.com', $_SERVER); diff --git a/tests/Psr7Integration/Zend/UriTest.php b/tests/Psr7Integration/Zend/UriTest.php index f5fa18b..2034b8e 100644 --- a/tests/Psr7Integration/Zend/UriTest.php +++ b/tests/Psr7Integration/Zend/UriTest.php @@ -2,10 +2,11 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http\Psr7Integration\Zend; use Http\Psr7Test\UriIntegrationTest; @@ -21,9 +22,10 @@ public static function setUpBeforeClass() define('STREAM_FACTORY', StreamFactory::class); } } + public function createUri($uri) { - $provider = new ZendDiactorosPsr17FactoryProvider; + $provider = new ZendDiactorosPsr17FactoryProvider(); $decoratedUriFactory = new DecoratedUriFactory($provider->getUriFactory()); return $decoratedUriFactory->createUri($uri); diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index efb20b5..75cfa26 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -2,14 +2,16 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http; -use Slim\Http\Response; +use RuntimeException; use Slim\Http\Factory\DecoratedResponseFactory; +use Slim\Http\Response; use Slim\Tests\Http\Providers\Psr17FactoryProvider; class ResponseTest extends TestCase @@ -426,7 +428,7 @@ public function testWithJson() } /** - * @expectedException \RuntimeException + * @expectedException RuntimeException */ public function testWithInvalidJsonThrowsException() { diff --git a/tests/ServerRequestTest.php b/tests/ServerRequestTest.php index 6e33cc1..a70a654 100644 --- a/tests/ServerRequestTest.php +++ b/tests/ServerRequestTest.php @@ -2,19 +2,18 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http; +use InvalidArgumentException; +use RuntimeException; use Slim\Http\Factory\DecoratedServerRequestFactory; use Slim\Tests\Http\Providers\Psr17FactoryProvider; -/** - * Class ServerRequestTest - * @package Slim\Tests\Http - */ class ServerRequestTest extends TestCase { public function testDisableSetter() @@ -95,7 +94,7 @@ public function testWithAllAllowedCharactersMethod() } /** - * @expectedException \InvalidArgumentException + * @expectedException InvalidArgumentException */ public function testWithMethodInvalid() { @@ -927,7 +926,7 @@ public function testGetParameterFromBody() } /** - * @expectedException \RuntimeException + * @expectedException RuntimeException */ public function testGetParsedBodyThrowsRuntimeExceptionWhenInvalidTypeReturned() { diff --git a/tests/TestCase.php b/tests/TestCase.php index 828b20e..a817109 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,20 +2,17 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http; +use PHPUnit\Framework\TestCase as PHPUnitTestCase; use Slim\Tests\Http\Providers\NyholmPsr17FactoryProvider; use Slim\Tests\Http\Providers\ZendDiactorosPsr17FactoryProvider; -use PHPUnit\Framework\TestCase as PHPUnitTestCase; -/** - * Class TestCase - * @package Tests\SlimPsr7Decorators - */ abstract class TestCase extends PHPUnitTestCase { /** diff --git a/tests/UriTest.php b/tests/UriTest.php index d9d4cb5..82647f3 100644 --- a/tests/UriTest.php +++ b/tests/UriTest.php @@ -2,19 +2,17 @@ /** * Slim Framework (https://slimframework.com) * - * @link https://github.com/slimphp/Slim-Http - * @copyright Copyright (c) 2011-2018 Josh Lockhart - * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE (MIT License) + * @license https://github.com/slimphp/Slim-Http/blob/master/LICENSE.md (MIT License) */ + +declare(strict_types=1); + namespace Slim\Tests\Http; +use InvalidArgumentException; use Slim\Http\Factory\DecoratedUriFactory; use Slim\Tests\Http\Providers\Psr17FactoryProvider; -/** - * Class UriTest - * @package Slim\Tests\Http - */ class UriTest extends TestCase { public function testDisableSetter() @@ -228,7 +226,7 @@ public function testWithPortNull() } /** - * @expectedException \InvalidArgumentException + * @expectedException InvalidArgumentException */ public function testWithPortInvalidInt() { @@ -243,7 +241,7 @@ public function testWithPortInvalidInt() } /** - * @expectedException \InvalidArgumentException + * @expectedException InvalidArgumentException */ public function testWithPortInvalidString() { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 26a796a..c8b27a6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,2 +1,10 @@ Date: Sun, 5 May 2019 13:49:02 -0600 Subject: [PATCH 3/4] re-order dependencies in composer.json --- composer.json | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index e3cfc80..eff9261 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,11 @@ "name": "Rob Allen", "email": "rob@akrabat.com", "homepage": "http://akrabat.com" + }, + { + "name": "Pierre Berube", + "email": "pierre@lgse.com", + "homepage": "http://www.lgse.com" } ], "require": { @@ -32,11 +37,11 @@ }, "require-dev": { "nyholm/psr7": "^1.0", - "phpunit/phpunit": "^7.0", "phpstan/phpstan": "^0.10.3", + "phpunit/phpunit": "^7.0", + "php-http/psr7-integration-tests": "dev-master", "squizlabs/php_codesniffer": "^3.3.2", - "zendframework/zend-diactoros": "^2.0", - "php-http/psr7-integration-tests": "dev-master" + "zendframework/zend-diactoros": "^2.0" }, "provide": { "psr/http-factory": "^1.0" From c27e94af7e5a7af3e613ffd9f725345ef00fa893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=83=C2=A9rub=C3=83=C2=A9?= Date: Sun, 5 May 2019 13:49:02 -0600 Subject: [PATCH 4/4] refactor phpunit config --- phpunit.xml => phpunit.xml.dist | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename phpunit.xml => phpunit.xml.dist (84%) diff --git a/phpunit.xml b/phpunit.xml.dist similarity index 84% rename from phpunit.xml rename to phpunit.xml.dist index 3b0dc77..d8dcc8f 100644 --- a/phpunit.xml +++ b/phpunit.xml.dist @@ -2,13 +2,13 @@ + bootstrap="tests/bootstrap.php" +> - + tests/ - src/