"ezyang/htmlpurifier": "^4.16",
"guzzlehttp/guzzle": "^7.5.1",
"guzzlehttp/psr7": "^2.5.0",
- "laminas/laminas-diactoros": "^2.25.2",
+ "laminas/laminas-diactoros": "^3.0.0",
"laminas/laminas-httphandlerrunner": "^2.6",
"laminas/laminas-progressbar": "^2.11",
"paragonie/constant_time_encoding": "^2.6.3",
"pelago/emogrifier": "^7.0.0",
"psr/clock": "^1.0",
"psr/event-dispatcher": "^1.0",
- "psr/http-message": "^1.1.0",
+ "psr/http-message": "^2.0",
"psr/http-server-handler": "^1.0.2",
"psr/http-server-middleware": "^1.0.2",
"psr/log": "^3.0",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "2983948012af211bf635948ccf965b06",
+ "content-hash": "84250bc88acacd285d9605a8b2ef00c7",
"packages": [
{
"name": "cuyz/valinor",
},
{
"name": "laminas/laminas-diactoros",
- "version": "2.25.2",
+ "version": "3.0.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-diactoros.git",
- "reference": "9f3f4bf5b99c9538b6f1dbcc20f6fec357914f9e"
+ "reference": "2515f4134258b1b418c23cb86606b8a09dd01aea"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/9f3f4bf5b99c9538b6f1dbcc20f6fec357914f9e",
- "reference": "9f3f4bf5b99c9538b6f1dbcc20f6fec357914f9e",
+ "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/2515f4134258b1b418c23cb86606b8a09dd01aea",
+ "reference": "2515f4134258b1b418c23cb86606b8a09dd01aea",
"shasum": ""
},
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
- "psr/http-factory": "^1.0",
- "psr/http-message": "^1.1"
- },
- "conflict": {
- "zendframework/zend-diactoros": "*"
+ "psr/http-factory": "^1.0.2",
+ "psr/http-message": "^1.1 || ^2.0"
},
"provide": {
- "psr/http-factory-implementation": "1.0",
- "psr/http-message-implementation": "1.0"
+ "psr/http-factory-implementation": "^1.1 || ^2.0",
+ "psr/http-message-implementation": "^1.1 || ^2.0"
},
"require-dev": {
"ext-curl": "*",
"ext-gd": "*",
"ext-libxml": "*",
"http-interop/http-factory-tests": "^0.9.0",
- "laminas/laminas-coding-standard": "^2.5",
- "php-http/psr7-integration-tests": "^1.2",
+ "laminas/laminas-coding-standard": "~2.5.0",
+ "php-http/psr7-integration-tests": "^1.3",
"phpunit/phpunit": "^9.5.28",
"psalm/plugin-phpunit": "^0.18.4",
- "vimeo/psalm": "^5.6"
+ "vimeo/psalm": "^5.9"
},
"type": "library",
"extra": {
"src/functions/marshal_headers_from_sapi.php",
"src/functions/marshal_method_from_sapi.php",
"src/functions/marshal_protocol_version_from_sapi.php",
- "src/functions/marshal_uri_from_sapi.php",
"src/functions/normalize_server.php",
"src/functions/normalize_uploaded_files.php",
- "src/functions/parse_cookie_header.php",
- "src/functions/create_uploaded_file.legacy.php",
- "src/functions/marshal_headers_from_sapi.legacy.php",
- "src/functions/marshal_method_from_sapi.legacy.php",
- "src/functions/marshal_protocol_version_from_sapi.legacy.php",
- "src/functions/marshal_uri_from_sapi.legacy.php",
- "src/functions/normalize_server.legacy.php",
- "src/functions/normalize_uploaded_files.legacy.php",
- "src/functions/parse_cookie_header.legacy.php"
+ "src/functions/parse_cookie_header.php"
],
"psr-4": {
"Laminas\\Diactoros\\": "src/"
"type": "community_bridge"
}
],
- "time": "2023-04-17T15:44:17+00:00"
+ "time": "2023-05-04T21:18:23+00:00"
},
{
"name": "laminas/laminas-httphandlerrunner",
},
{
"name": "psr/http-message",
- "version": "1.1",
+ "version": "2.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
- "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
+ "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
- "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
+ "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.1.x-dev"
+ "dev-master": "2.0.x-dev"
}
},
"autoload": {
"authors": [
{
"name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
+ "homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"response"
],
"support": {
- "source": "https://github.com/php-fig/http-message/tree/1.1"
+ "source": "https://github.com/php-fig/http-message/tree/2.0"
},
- "time": "2023-04-04T09:50:52+00:00"
+ "time": "2023-04-04T09:54:51+00:00"
},
{
"name": "psr/http-server-handler",
'Laminas\\Diactoros\\HeaderSecurity' => $vendorDir . '/laminas/laminas-diactoros/src/HeaderSecurity.php',
'Laminas\\Diactoros\\MessageTrait' => $vendorDir . '/laminas/laminas-diactoros/src/MessageTrait.php',
'Laminas\\Diactoros\\Module' => $vendorDir . '/laminas/laminas-diactoros/src/Module.php',
- 'Laminas\\Diactoros\\PhpInputStream' => $vendorDir . '/laminas/laminas-diactoros/src/PhpInputStream.php',
'Laminas\\Diactoros\\RelativeStream' => $vendorDir . '/laminas/laminas-diactoros/src/RelativeStream.php',
'Laminas\\Diactoros\\Request' => $vendorDir . '/laminas/laminas-diactoros/src/Request.php',
'Laminas\\Diactoros\\RequestFactory' => $vendorDir . '/laminas/laminas-diactoros/src/RequestFactory.php',
'da94ac5d3ca7d2dbab84ce561ce72bfd' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_headers_from_sapi.php',
'3d97c8dcdfba8cb85d3b34f116bb248b' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_method_from_sapi.php',
'e6f3bc6883e449ab367280b34158c05b' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_protocol_version_from_sapi.php',
- 'd59fbae42019aedf227094ac49a46f50' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_uri_from_sapi.php',
'de95e0ac670b27c84ef8c5ac41fc1b34' => $vendorDir . '/laminas/laminas-diactoros/src/functions/normalize_server.php',
'b6c2870932b0250c10334a86dcb33c7f' => $vendorDir . '/laminas/laminas-diactoros/src/functions/normalize_uploaded_files.php',
'd02cf21124526632320d6f20b1bbf905' => $vendorDir . '/laminas/laminas-diactoros/src/functions/parse_cookie_header.php',
- 'd919fc9d5ad52cfb7f322f7fe36458ab' => $vendorDir . '/laminas/laminas-diactoros/src/functions/create_uploaded_file.legacy.php',
- 'e397f74f8af3b1e56166a6e99f216ee7' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_headers_from_sapi.legacy.php',
- 'd154b49fab8e4da34fb553a2d644918c' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_method_from_sapi.legacy.php',
- '9d3db23ca418094bcf0b641a0c9559ed' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_protocol_version_from_sapi.legacy.php',
- 'b0b88a3b89caae681462c58ff19a7059' => $vendorDir . '/laminas/laminas-diactoros/src/functions/marshal_uri_from_sapi.legacy.php',
- 'cc8e14526dc240491e17a838cb78508c' => $vendorDir . '/laminas/laminas-diactoros/src/functions/normalize_server.legacy.php',
- '786bf90caabc9e09b6ad4cc5ca8f0e30' => $vendorDir . '/laminas/laminas-diactoros/src/functions/normalize_uploaded_files.legacy.php',
- '751a5a3f463e4be759be31748b61737c' => $vendorDir . '/laminas/laminas-diactoros/src/functions/parse_cookie_header.legacy.php',
'5897ea0ac4cccf14d323035e65887801' => $vendorDir . '/symfony/polyfill-php82/bootstrap.php',
);
'da94ac5d3ca7d2dbab84ce561ce72bfd' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_headers_from_sapi.php',
'3d97c8dcdfba8cb85d3b34f116bb248b' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_method_from_sapi.php',
'e6f3bc6883e449ab367280b34158c05b' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_protocol_version_from_sapi.php',
- 'd59fbae42019aedf227094ac49a46f50' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_uri_from_sapi.php',
'de95e0ac670b27c84ef8c5ac41fc1b34' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/normalize_server.php',
'b6c2870932b0250c10334a86dcb33c7f' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/normalize_uploaded_files.php',
'd02cf21124526632320d6f20b1bbf905' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/parse_cookie_header.php',
- 'd919fc9d5ad52cfb7f322f7fe36458ab' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/create_uploaded_file.legacy.php',
- 'e397f74f8af3b1e56166a6e99f216ee7' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_headers_from_sapi.legacy.php',
- 'd154b49fab8e4da34fb553a2d644918c' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_method_from_sapi.legacy.php',
- '9d3db23ca418094bcf0b641a0c9559ed' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_protocol_version_from_sapi.legacy.php',
- 'b0b88a3b89caae681462c58ff19a7059' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/marshal_uri_from_sapi.legacy.php',
- 'cc8e14526dc240491e17a838cb78508c' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/normalize_server.legacy.php',
- '786bf90caabc9e09b6ad4cc5ca8f0e30' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/normalize_uploaded_files.legacy.php',
- '751a5a3f463e4be759be31748b61737c' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/functions/parse_cookie_header.legacy.php',
'5897ea0ac4cccf14d323035e65887801' => __DIR__ . '/..' . '/symfony/polyfill-php82/bootstrap.php',
);
'Laminas\\Diactoros\\HeaderSecurity' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/HeaderSecurity.php',
'Laminas\\Diactoros\\MessageTrait' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/MessageTrait.php',
'Laminas\\Diactoros\\Module' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/Module.php',
- 'Laminas\\Diactoros\\PhpInputStream' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/PhpInputStream.php',
'Laminas\\Diactoros\\RelativeStream' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/RelativeStream.php',
'Laminas\\Diactoros\\Request' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/Request.php',
'Laminas\\Diactoros\\RequestFactory' => __DIR__ . '/..' . '/laminas/laminas-diactoros/src/RequestFactory.php',
},
{
"name": "laminas/laminas-diactoros",
- "version": "2.25.2",
- "version_normalized": "2.25.2.0",
+ "version": "3.0.0",
+ "version_normalized": "3.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/laminas/laminas-diactoros.git",
- "reference": "9f3f4bf5b99c9538b6f1dbcc20f6fec357914f9e"
+ "reference": "2515f4134258b1b418c23cb86606b8a09dd01aea"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/9f3f4bf5b99c9538b6f1dbcc20f6fec357914f9e",
- "reference": "9f3f4bf5b99c9538b6f1dbcc20f6fec357914f9e",
+ "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/2515f4134258b1b418c23cb86606b8a09dd01aea",
+ "reference": "2515f4134258b1b418c23cb86606b8a09dd01aea",
"shasum": ""
},
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
- "psr/http-factory": "^1.0",
- "psr/http-message": "^1.1"
- },
- "conflict": {
- "zendframework/zend-diactoros": "*"
+ "psr/http-factory": "^1.0.2",
+ "psr/http-message": "^1.1 || ^2.0"
},
"provide": {
- "psr/http-factory-implementation": "1.0",
- "psr/http-message-implementation": "1.0"
+ "psr/http-factory-implementation": "^1.1 || ^2.0",
+ "psr/http-message-implementation": "^1.1 || ^2.0"
},
"require-dev": {
"ext-curl": "*",
"ext-gd": "*",
"ext-libxml": "*",
"http-interop/http-factory-tests": "^0.9.0",
- "laminas/laminas-coding-standard": "^2.5",
- "php-http/psr7-integration-tests": "^1.2",
+ "laminas/laminas-coding-standard": "~2.5.0",
+ "php-http/psr7-integration-tests": "^1.3",
"phpunit/phpunit": "^9.5.28",
"psalm/plugin-phpunit": "^0.18.4",
- "vimeo/psalm": "^5.6"
+ "vimeo/psalm": "^5.9"
},
- "time": "2023-04-17T15:44:17+00:00",
+ "time": "2023-05-04T21:18:23+00:00",
"type": "library",
"extra": {
"laminas": {
"src/functions/marshal_headers_from_sapi.php",
"src/functions/marshal_method_from_sapi.php",
"src/functions/marshal_protocol_version_from_sapi.php",
- "src/functions/marshal_uri_from_sapi.php",
"src/functions/normalize_server.php",
"src/functions/normalize_uploaded_files.php",
- "src/functions/parse_cookie_header.php",
- "src/functions/create_uploaded_file.legacy.php",
- "src/functions/marshal_headers_from_sapi.legacy.php",
- "src/functions/marshal_method_from_sapi.legacy.php",
- "src/functions/marshal_protocol_version_from_sapi.legacy.php",
- "src/functions/marshal_uri_from_sapi.legacy.php",
- "src/functions/normalize_server.legacy.php",
- "src/functions/normalize_uploaded_files.legacy.php",
- "src/functions/parse_cookie_header.legacy.php"
+ "src/functions/parse_cookie_header.php"
],
"psr-4": {
"Laminas\\Diactoros\\": "src/"
},
{
"name": "psr/http-message",
- "version": "1.1",
- "version_normalized": "1.1.0.0",
+ "version": "2.0",
+ "version_normalized": "2.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
- "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
+ "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
- "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
+ "url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
+ "reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
- "time": "2023-04-04T09:50:52+00:00",
+ "time": "2023-04-04T09:54:51+00:00",
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.1.x-dev"
+ "dev-master": "2.0.x-dev"
}
},
"installation-source": "dist",
"authors": [
{
"name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
+ "homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"response"
],
"support": {
- "source": "https://github.com/php-fig/http-message/tree/1.1"
+ "source": "https://github.com/php-fig/http-message/tree/2.0"
},
"install-path": "../psr/http-message"
},
'dev_requirement' => false,
),
'laminas/laminas-diactoros' => array(
- 'pretty_version' => '2.25.2',
- 'version' => '2.25.2.0',
- 'reference' => '9f3f4bf5b99c9538b6f1dbcc20f6fec357914f9e',
+ 'pretty_version' => '3.0.0',
+ 'version' => '3.0.0.0',
+ 'reference' => '2515f4134258b1b418c23cb86606b8a09dd01aea',
'type' => 'library',
'install_path' => __DIR__ . '/../laminas/laminas-diactoros',
'aliases' => array(),
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
+ 1 => '^1.1 || ^2.0',
),
),
'psr/http-message' => array(
- 'pretty_version' => '1.1',
- 'version' => '1.1.0.0',
- 'reference' => 'cb6ce4845ce34a8ad9e68117c10ee90a29919eba',
+ 'pretty_version' => '2.0',
+ 'version' => '2.0.0.0',
+ 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-message',
'aliases' => array(),
'dev_requirement' => false,
'provided' => array(
0 => '1.0',
+ 1 => '^1.1 || ^2.0',
),
),
'psr/http-server-handler' => array(
},
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
- "psr/http-factory": "^1.0",
- "psr/http-message": "^1.1"
+ "psr/http-factory": "^1.0.2",
+ "psr/http-message": "^1.1 || ^2.0"
},
"require-dev": {
"ext-curl": "*",
"ext-gd": "*",
"ext-libxml": "*",
"http-interop/http-factory-tests": "^0.9.0",
- "laminas/laminas-coding-standard": "^2.5",
- "php-http/psr7-integration-tests": "^1.2",
+ "laminas/laminas-coding-standard": "~2.5.0",
+ "php-http/psr7-integration-tests": "^1.3",
"phpunit/phpunit": "^9.5.28",
"psalm/plugin-phpunit": "^0.18.4",
- "vimeo/psalm": "^5.6"
+ "vimeo/psalm": "^5.9"
},
"provide": {
- "psr/http-factory-implementation": "1.0",
- "psr/http-message-implementation": "1.0"
- },
- "conflict": {
- "zendframework/zend-diactoros": "*"
+ "psr/http-factory-implementation": "^1.1 || ^2.0",
+ "psr/http-message-implementation": "^1.1 || ^2.0"
},
"autoload": {
"files": [
"src/functions/marshal_headers_from_sapi.php",
"src/functions/marshal_method_from_sapi.php",
"src/functions/marshal_protocol_version_from_sapi.php",
- "src/functions/marshal_uri_from_sapi.php",
"src/functions/normalize_server.php",
"src/functions/normalize_uploaded_files.php",
- "src/functions/parse_cookie_header.php",
- "src/functions/create_uploaded_file.legacy.php",
- "src/functions/marshal_headers_from_sapi.legacy.php",
- "src/functions/marshal_method_from_sapi.legacy.php",
- "src/functions/marshal_protocol_version_from_sapi.legacy.php",
- "src/functions/marshal_uri_from_sapi.legacy.php",
- "src/functions/normalize_server.legacy.php",
- "src/functions/normalize_uploaded_files.legacy.php",
- "src/functions/parse_cookie_header.legacy.php"
+ "src/functions/parse_cookie_header.php"
],
"psr-4": {
"Laminas\\Diactoros\\": "src/"
/**
* {@inheritdoc}
- *
- * @param int $offset
- * @param int $whence
- * @return void
*/
- public function seek($offset, $whence = SEEK_SET)
+ public function seek(int $offset, int $whence = SEEK_SET): void
{
throw Exception\UnseekableStreamException::forCallbackStream();
}
/**
* {@inheritdoc}
*/
- public function write($string): void
+ public function write(string $string): int
{
throw Exception\UnwritableStreamException::forCallbackStream();
}
/**
* {@inheritdoc}
*/
- public function read($length): string
+ public function read(int $length): string
{
throw Exception\UnreadableStreamException::forCallbackStream();
}
/**
* {@inheritdoc}
*/
- public function getMetadata($key = null)
+ public function getMetadata(?string $key = null)
{
$metadata = [
'eof' => $this->eof(),
use function array_map;
use function array_merge;
use function array_values;
-use function gettype;
use function implode;
use function is_array;
-use function is_object;
use function is_resource;
use function is_string;
use function preg_match;
* @param string $version HTTP protocol version
* @return static
*/
- public function withProtocolVersion($version): MessageInterface
+ public function withProtocolVersion(string $version): MessageInterface
{
$this->validateProtocolVersion($version);
$new = clone $this;
* name using a case-insensitive string comparison. Returns false if
* no matching header name is found in the message.
*/
- public function hasHeader($header): bool
+ public function hasHeader(string $header): bool
{
return isset($this->headerNames[strtolower($header)]);
}
* header. If the header does not appear in the message, this method MUST
* return an empty array.
*/
- public function getHeader($header): array
+ public function getHeader(string $header): array
{
if (! $this->hasHeader($header)) {
return [];
* concatenated together using a comma. If the header does not appear in
* the message, this method MUST return an empty string.
*/
- public function getHeaderLine($name): string
+ public function getHeaderLine(string $name): string
{
$value = $this->getHeader($name);
if (empty($value)) {
* @return static
* @throws Exception\InvalidArgumentException For invalid header names or values.
*/
- public function withHeader($name, $value): MessageInterface
+ public function withHeader(string $name, $value): MessageInterface
{
$this->assertHeader($name);
* @return static
* @throws Exception\InvalidArgumentException For invalid header names or values.
*/
- public function withAddedHeader($name, $value): MessageInterface
+ public function withAddedHeader(string $name, $value): MessageInterface
{
$this->assertHeader($name);
* @param string $name Case-insensitive header field name to remove.
* @return static
*/
- public function withoutHeader($name): MessageInterface
+ public function withoutHeader(string $name): MessageInterface
{
- if (! is_string($name) || $name === '' || ! $this->hasHeader($name)) {
+ if ($name === '' || ! $this->hasHeader($name)) {
return clone $this;
}
/**
* Validate the HTTP protocol version
*
- * @param string $version
* @throws Exception\InvalidArgumentException On invalid HTTP protocol version.
*/
- private function validateProtocolVersion($version): void
+ private function validateProtocolVersion(string $version): void
{
if (empty($version)) {
throw new Exception\InvalidArgumentException(
'HTTP protocol version can not be empty'
);
}
- if (! is_string($version)) {
- throw new Exception\InvalidArgumentException(sprintf(
- 'Unsupported HTTP protocol version; must be a string, received %s',
- is_object($version) ? $version::class : gettype($version)
- ));
- }
// HTTP/1 uses a "<major>.<minor>" numbering scheme to indicate
// versions of the protocol, while HTTP/2 does not.
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Laminas\Diactoros;
-
-use Stringable;
-
-use function stream_get_contents;
-
-/**
- * Caching version of php://input
- */
-class PhpInputStream extends Stream implements Stringable
-{
- private string $cache = '';
-
- private bool $reachedEof = false;
-
- /**
- * @param string|resource $stream
- */
- public function __construct($stream = 'php://input')
- {
- parent::__construct($stream, 'r');
- }
-
- /**
- * {@inheritdoc}
- */
- public function __toString(): string
- {
- if ($this->reachedEof) {
- return $this->cache;
- }
-
- $this->getContents();
- return $this->cache;
- }
-
- /**
- * {@inheritdoc}
- */
- public function isWritable(): bool
- {
- return false;
- }
-
- /**
- * {@inheritdoc}
- */
- public function read($length): string
- {
- $content = parent::read($length);
- if (! $this->reachedEof) {
- $this->cache .= $content;
- }
-
- if ($this->eof()) {
- $this->reachedEof = true;
- }
-
- return $content;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getContents($maxLength = -1): string
- {
- if ($this->reachedEof) {
- return $this->cache;
- }
-
- $contents = stream_get_contents($this->resource, $maxLength);
- $this->cache .= $contents;
-
- if ($maxLength === -1 || $this->eof()) {
- $this->reachedEof = true;
- }
-
- return $contents;
- }
-}
/**
* {@inheritdoc}
*/
- public function seek($offset, $whence = SEEK_SET): void
+ public function seek(int $offset, int $whence = SEEK_SET): void
{
if ($whence === SEEK_SET) {
$this->decoratedStream->seek($offset + $this->offset, $whence);
/**
* {@inheritdoc}
*/
- public function write($string): int
+ public function write(string $string): int
{
if ($this->tell() < 0) {
throw new Exception\InvalidStreamPointerPositionException();
/**
* {@inheritdoc}
*/
- public function read($length): string
+ public function read(int $length): string
{
if ($this->tell() < 0) {
throw new Exception\InvalidStreamPointerPositionException();
/**
* {@inheritdoc}
*/
- public function getMetadata($key = null)
+ public function getMetadata(?string $key = null)
{
return $this->decoratedStream->getMetadata($key);
}
/**
* {@inheritdoc}
*/
- public function getHeader($name): array
+ public function getHeader(string $name): array
{
if (empty($name) || ! $this->hasHeader($name)) {
if (
use Psr\Http\Message\UriInterface;
use function array_keys;
-use function gettype;
-use function is_object;
use function is_string;
use function preg_match;
use function sprintf;
*
* Otherwise, it raises an exception.
*
- * @param null|string|UriInterface $uri
* @throws Exception\InvalidArgumentException
*/
- private function createUri($uri): UriInterface
+ private function createUri(null|string|UriInterface $uri): UriInterface
{
if ($uri instanceof UriInterface) {
return $uri;
}
+
if (is_string($uri)) {
return new Uri($uri);
}
- if ($uri === null) {
- return new Uri();
- }
- throw new Exception\InvalidArgumentException(
- 'Invalid URI provided; must be null, a string, or a Psr\Http\Message\UriInterface instance'
- );
+
+ return new Uri();
}
/**
* @link http://tools.ietf.org/html/rfc7230#section-2.7 (for the various
* request-target forms allowed in request messages)
*
- * @param string $requestTarget
* @throws Exception\InvalidArgumentException If the request target is invalid.
* @return static
*/
- public function withRequestTarget($requestTarget): RequestInterface
+ public function withRequestTarget(string $requestTarget): RequestInterface
{
if (preg_match('#\s#', $requestTarget)) {
throw new Exception\InvalidArgumentException(
* @throws Exception\InvalidArgumentException For invalid HTTP methods.
* @return static
*/
- public function withMethod($method): RequestInterface
+ public function withMethod(string $method): RequestInterface
{
$new = clone $this;
$new->setMethod($method);
* @param bool $preserveHost Preserve the original state of the Host header.
* @return static
*/
- public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
+ public function withUri(UriInterface $uri, bool $preserveHost = false): RequestInterface
{
$new = clone $this;
$new->uri = $uri;
/**
* Set and validate the HTTP method
*
- * @param string $method
* @throws Exception\InvalidArgumentException On invalid HTTP method.
*/
- private function setMethod($method): void
+ private function setMethod(string $method): void
{
- if (! is_string($method)) {
- throw new Exception\InvalidArgumentException(sprintf(
- 'Unsupported HTTP method; must be a string, received %s',
- is_object($method) ? $method::class : gettype($method)
- ));
- }
-
if (! preg_match('/^[!#$%&\'*+.^_`\|~0-9a-z-]+$/i', $method)) {
throw new Exception\InvalidArgumentException(sprintf(
'Unsupported HTTP method "%s" provided',
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
-use function gettype;
-use function is_float;
-use function is_numeric;
-use function is_object;
-use function is_scalar;
-use function is_string;
use function sprintf;
/**
/**
* {@inheritdoc}
*/
- public function withStatus($code, $reasonPhrase = ''): Response
+ public function withStatus(int $code, string $reasonPhrase = ''): Response
{
$new = clone $this;
$new->setStatusCode($code, $reasonPhrase);
/**
* Set a valid status code.
*
- * @param int $code
- * @param string $reasonPhrase
* @throws Exception\InvalidArgumentException On an invalid status code.
*/
- private function setStatusCode($code, $reasonPhrase = ''): void
+ private function setStatusCode(int $code, string $reasonPhrase = ''): void
{
if (
- ! is_numeric($code)
- || is_float($code)
- || $code < static::MIN_STATUS_CODE_VALUE
+ $code < static::MIN_STATUS_CODE_VALUE
|| $code > static::MAX_STATUS_CODE_VALUE
) {
throw new Exception\InvalidArgumentException(sprintf(
'Invalid status code "%s"; must be an integer between %d and %d, inclusive',
- is_scalar($code) ? $code : gettype($code),
+ $code,
static::MIN_STATUS_CODE_VALUE,
static::MAX_STATUS_CODE_VALUE
));
}
- if (! is_string($reasonPhrase)) {
- throw new Exception\InvalidArgumentException(sprintf(
- 'Unsupported response reason phrase; must be a string, received %s',
- is_object($reasonPhrase) ? $reasonPhrase::class : gettype($reasonPhrase)
- ));
- }
-
if ($reasonPhrase === '' && isset($this->phrases[$code])) {
$reasonPhrase = $this->phrases[$code];
}
$this->reasonPhrase = $reasonPhrase;
- $this->statusCode = (int) $code;
+ $this->statusCode = $code;
}
}
public function __construct(
private array $serverParams = [],
array $uploadedFiles = [],
- $uri = null,
+ null|string|UriInterface $uri = null,
?string $method = null,
$body = 'php://input',
array $headers = [],
$this->validateUploadedFiles($uploadedFiles);
if ($body === 'php://input') {
- $body = new PhpInputStream();
+ $body = new Stream($body, 'r');
}
$this->initialize($uri, $method, $body, $headers);
/**
* {@inheritdoc}
*/
- public function getAttribute($attribute, $default = null)
+ public function getAttribute(string $name, $default = null)
{
- if (! array_key_exists($attribute, $this->attributes)) {
+ if (! array_key_exists($name, $this->attributes)) {
return $default;
}
- return $this->attributes[$attribute];
+ return $this->attributes[$name];
}
/**
* {@inheritdoc}
*/
- public function withAttribute($attribute, $value): ServerRequest
+ public function withAttribute(string $name, $value): ServerRequest
{
- $new = clone $this;
- $new->attributes[$attribute] = $value;
+ $new = clone $this;
+ $new->attributes[$name] = $value;
return $new;
}
/**
* {@inheritdoc}
*/
- public function withoutAttribute($name): ServerRequest
+ public function withoutAttribute(string $name): ServerRequest
{
$new = clone $this;
unset($new->attributes[$name]);
?array $cookies = null,
?array $files = null,
?FilterServerRequestInterface $requestFilter = null
- ): ServerRequest {
- $requestFilter = $requestFilter ?: FilterUsingXForwardedHeaders::trustReservedSubnets();
+ ): ServerRequestInterface {
+ $requestFilter = $requestFilter ?? FilterUsingXForwardedHeaders::trustReservedSubnets();
$server = normalizeServer(
- $server ?: $_SERVER,
+ $server ?? $_SERVER,
is_callable(self::$apacheRequestHeaders) ? self::$apacheRequestHeaders : null
);
- $files = normalizeUploadedFiles($files ?: $_FILES);
+ $files = normalizeUploadedFiles($files ?? $_FILES);
$headers = marshalHeadersFromSapi($server);
if (null === $cookies && array_key_exists('cookie', $headers)) {
marshalMethodFromSapi($server),
'php://input',
$headers,
- $cookies ?: $_COOKIE,
- $query ?: $_GET,
- $body ?: $_POST,
+ $cookies ?? $_COOKIE,
+ $query ?? $_GET,
+ $body ?? $_POST,
marshalProtocolVersionFromSapi($server)
));
}
namespace Laminas\Diactoros;
-use GdImage;
use Psr\Http\Message\StreamInterface;
use RuntimeException;
use Stringable;
/**
* A list of allowed stream resource types that are allowed to instantiate a Stream
*/
- private const ALLOWED_STREAM_RESOURCE_TYPES = ['gd', 'stream'];
+ private const ALLOWED_STREAM_RESOURCE_TYPES = ['stream'];
/** @var resource|null */
protected $resource;
/**
* {@inheritdoc}
*/
- public function seek($offset, $whence = SEEK_SET): void
+ public function seek(int $offset, int $whence = SEEK_SET): void
{
if (! $this->resource) {
throw Exception\UnseekableStreamException::dueToMissingResource();
/**
* {@inheritdoc}
*/
- public function read($length): string
+ public function read(int $length): string
{
if (! $this->resource) {
throw Exception\UnreadableStreamException::dueToMissingResource();
/**
* {@inheritdoc}
*/
- public function getMetadata($key = null)
+ public function getMetadata(?string $key = null)
{
if (null === $key) {
return stream_get_meta_data($this->resource);
return in_array(get_resource_type($resource), self::ALLOWED_STREAM_RESOURCE_TYPES, true);
}
- if ($resource instanceof GdImage) {
- return true;
- }
-
return false;
}
}
/**
* {@inheritDoc}
*/
- public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
+ public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface
{
- return new Stream($file, $mode);
+ return new Stream($filename, $mode);
}
/**
*/
public function __construct(
$streamOrFile,
- private int $size,
+ private ?int $size,
int $errorStatus,
private ?string $clientFilename = null,
private ?string $clientMediaType = null
* @throws Exception\UploadedFileErrorException On any error during the
* move operation, or on the second or subsequent call to the method.
*/
- public function moveTo($targetPath): void
+ public function moveTo(string $targetPath): void
{
if ($this->moved) {
throw new Exception\UploadedFileAlreadyMovedException('Cannot move file; already moved!');
);
}
- if (! is_string($targetPath) || empty($targetPath)) {
+ if (empty($targetPath)) {
throw new Exception\InvalidArgumentException(
'Invalid path provided for move operation; must be a non-empty string'
);
use function array_keys;
use function explode;
-use function gettype;
use function implode;
-use function is_float;
-use function is_numeric;
-use function is_object;
-use function is_string;
use function ltrim;
use function parse_url;
use function preg_match;
/**
* {@inheritdoc}
*/
- public function withScheme($scheme): UriInterface
+ public function withScheme(string $scheme): UriInterface
{
- if (! is_string($scheme)) {
- throw new Exception\InvalidArgumentException(sprintf(
- '%s expects a string argument; received %s',
- __METHOD__,
- is_object($scheme) ? $scheme::class : gettype($scheme)
- ));
- }
-
$scheme = $this->filterScheme($scheme);
if ($scheme === $this->scheme) {
* {@inheritdoc}
*/
public function withUserInfo(
- $user,
+ string $user,
#[SensitiveParameter]
- $password = null
+ ?string $password = null
): UriInterface {
- if (! is_string($user)) {
- throw new Exception\InvalidArgumentException(sprintf(
- '%s expects a string user argument; received %s',
- __METHOD__,
- is_object($user) ? $user::class : gettype($user)
- ));
- }
- if (null !== $password && ! is_string($password)) {
- throw new Exception\InvalidArgumentException(sprintf(
- '%s expects a string or null password argument; received %s',
- __METHOD__,
- is_object($password) ? $password::class : gettype($password)
- ));
- }
-
$info = $this->filterUserInfoPart($user);
if (null !== $password) {
$info .= ':' . $this->filterUserInfoPart($password);
/**
* {@inheritdoc}
*/
- public function withHost($host): UriInterface
+ public function withHost(string $host): UriInterface
{
- if (! is_string($host)) {
- throw new Exception\InvalidArgumentException(sprintf(
- '%s expects a string argument; received %s',
- __METHOD__,
- is_object($host) ? $host::class : gettype($host)
- ));
- }
-
if ($host === $this->host) {
// Do nothing if no change was made.
return $this;
/**
* {@inheritdoc}
*/
- public function withPort($port): UriInterface
+ public function withPort(?int $port): UriInterface
{
- if ($port !== null) {
- if (! is_numeric($port) || is_float($port)) {
- throw new Exception\InvalidArgumentException(sprintf(
- 'Invalid port "%s" specified; must be an integer, an integer string, or null',
- is_object($port) ? $port::class : gettype($port)
- ));
- }
-
- $port = (int) $port;
- }
-
if ($port === $this->port) {
// Do nothing if no change was made.
return $this;
/**
* {@inheritdoc}
*/
- public function withPath($path): UriInterface
+ public function withPath(string $path): UriInterface
{
- if (! is_string($path)) {
- throw new Exception\InvalidArgumentException(
- 'Invalid path provided; must be a string'
- );
- }
-
if (str_contains($path, '?')) {
throw new Exception\InvalidArgumentException(
'Invalid path provided; must not contain a query string'
/**
* {@inheritdoc}
*/
- public function withQuery($query): UriInterface
+ public function withQuery(string $query): UriInterface
{
- if (! is_string($query)) {
- throw new Exception\InvalidArgumentException(
- 'Query string must be a string'
- );
- }
-
if (str_contains($query, '#')) {
throw new Exception\InvalidArgumentException(
'Query string must not include a URI fragment'
/**
* {@inheritdoc}
*/
- public function withFragment($fragment): UriInterface
+ public function withFragment(string $fragment): UriInterface
{
- if (! is_string($fragment)) {
- throw new Exception\InvalidArgumentException(sprintf(
- '%s expects a string argument; received %s',
- __METHOD__,
- is_object($fragment) ? $fragment::class : gettype($fragment)
- ));
- }
-
$fragment = $this->filterFragment($fragment);
if ($fragment === $this->fragment) {
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Zend\Diactoros;
-
-use Laminas\Diactoros\UploadedFile;
-
-use function func_get_args;
-use function Laminas\Diactoros\createUploadedFile as laminas_createUploadedFile;
-
-/**
- * @deprecated Use Laminas\Diactoros\createUploadedFile instead
- */
-function createUploadedFile(array $spec): UploadedFile
-{
- return laminas_createUploadedFile(...func_get_args());
-}
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Zend\Diactoros;
-
-use function func_get_args;
-use function Laminas\Diactoros\marshalHeadersFromSapi as laminas_marshalHeadersFromSapi;
-
-/**
- * @deprecated Use Laminas\Diactoros\marshalHeadersFromSapi instead
- */
-function marshalHeadersFromSapi(array $server): array
-{
- return laminas_marshalHeadersFromSapi(...func_get_args());
-}
namespace Laminas\Diactoros;
+use function array_filter;
use function array_key_exists;
use function is_string;
use function str_starts_with;
use function strtr;
use function substr;
+use const ARRAY_FILTER_USE_KEY;
+
/**
* @param array $server Values obtained from the SAPI (generally `$_SERVER`).
- * @return array Header/value pairs
+ * @return array<non-empty-string, mixed> Header/value pairs
*/
function marshalHeadersFromSapi(array $server): array
{
$headers = [];
foreach ($server as $key => $value) {
- if (! is_string($key)) {
+ if (! is_string($key) || $key === '') {
continue;
}
}
}
- return $headers;
+ // Filter out integer keys.
+ // These can occur if the translated header name is a string integer.
+ // PHP will cast those to integers when assigned to an array.
+ // This filters them out.
+ return array_filter($headers, fn(string|int $key): bool => is_string($key), ARRAY_FILTER_USE_KEY);
}
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Zend\Diactoros;
-
-use function func_get_args;
-use function Laminas\Diactoros\marshalMethodFromSapi as laminas_marshalMethodFromSapi;
-
-/**
- * @deprecated Use Laminas\Diactoros\marshalMethodFromSapi instead
- */
-function marshalMethodFromSapi(array $server): string
-{
- return laminas_marshalMethodFromSapi(...func_get_args());
-}
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Zend\Diactoros;
-
-use function func_get_args;
-use function Laminas\Diactoros\marshalProtocolVersionFromSapi as laminas_marshalProtocolVersionFromSapi;
-
-/**
- * @deprecated Use Laminas\Diactoros\marshalProtocolVersionFromSapi instead
- */
-function marshalProtocolVersionFromSapi(array $server): string
-{
- return laminas_marshalProtocolVersionFromSapi(...func_get_args());
-}
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Zend\Diactoros;
-
-use Laminas\Diactoros\Uri;
-
-use function func_get_args;
-use function Laminas\Diactoros\marshalUriFromSapi as laminas_marshalUriFromSapi;
-
-/**
- * @deprecated Use Laminas\Diactoros\marshalUriFromSapi instead
- */
-function marshalUriFromSapi(array $server, array $headers): Uri
-{
- return laminas_marshalUriFromSapi(...func_get_args());
-}
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Laminas\Diactoros;
-
-use function array_change_key_case;
-use function array_key_exists;
-use function assert;
-use function count;
-use function explode;
-use function gettype;
-use function implode;
-use function is_array;
-use function is_bool;
-use function is_string;
-use function ltrim;
-use function preg_match;
-use function preg_replace;
-use function sprintf;
-use function str_contains;
-use function strlen;
-use function strrpos;
-use function strtolower;
-use function substr;
-
-use const CASE_LOWER;
-
-/**
- * Marshal a Uri instance based on the values presnt in the $_SERVER array and headers.
- *
- * @deprecated This function is deprecated as of 2.11.1, and will be removed in
- * 3.0.0. As of 2.11.1, it is no longer used internally.
- *
- * @param array $server SAPI parameters
- * @param array $headers HTTP request headers
- */
-function marshalUriFromSapi(array $server, array $headers): Uri
-{
- /**
- * Retrieve a header value from an array of headers using a case-insensitive lookup.
- *
- * @param array $headers Key/value header pairs
- * @param mixed $default Default value to return if header not found
- * @return mixed
- */
- $getHeaderFromArray = static function (string $name, array $headers, $default = null) {
- $header = strtolower($name);
- $headers = array_change_key_case($headers, CASE_LOWER);
- if (array_key_exists($header, $headers)) {
- return is_array($headers[$header]) ? implode(', ', $headers[$header]) : $headers[$header];
- }
-
- return $default;
- };
-
- /**
- * Marshal the host and port from HTTP headers and/or the PHP environment.
- *
- * @return array Array of two items, host and port, in that order (can be
- * passed to a list() operation).
- */
- $marshalHostAndPort = static function (array $headers, array $server) use ($getHeaderFromArray): array {
- /**
- * @param string|array $host
- * @return array Array of two items, host and port, in that order (can be
- * passed to a list() operation).
- */
- $marshalHostAndPortFromHeader = static function ($host) {
- if (is_array($host)) {
- $host = implode(', ', $host);
- }
-
- $port = null;
-
- // works for regname, IPv4 & IPv6
- if (preg_match('|\:(\d+)$|', $host, $matches)) {
- $host = substr($host, 0, -1 * (strlen($matches[1]) + 1));
- $port = (int) $matches[1];
- }
-
- return [$host, $port];
- };
-
- /**
- * @return array Array of two items, host and port, in that order (can be
- * passed to a list() operation).
- */
- $marshalIpv6HostAndPort = static function (array $server, ?int $port): array {
- $host = '[' . $server['SERVER_ADDR'] . ']';
- $port = $port ?: 80;
- if ($port . ']' === substr($host, strrpos($host, ':') + 1)) {
- // The last digit of the IPv6-Address has been taken as port
- // Unset the port so the default port can be used
- $port = null;
- }
- return [$host, $port];
- };
-
- static $defaults = ['', null];
-
- $forwardedHost = $getHeaderFromArray('x-forwarded-host', $headers, false);
- if ($forwardedHost !== false) {
- return $marshalHostAndPortFromHeader($forwardedHost);
- }
-
- $host = $getHeaderFromArray('host', $headers, false);
- if ($host !== false) {
- return $marshalHostAndPortFromHeader($host);
- }
-
- if (! isset($server['SERVER_NAME'])) {
- return $defaults;
- }
-
- $host = $server['SERVER_NAME'];
- $port = isset($server['SERVER_PORT']) ? (int) $server['SERVER_PORT'] : null;
-
- if (
- ! isset($server['SERVER_ADDR'])
- || ! preg_match('/^\[[0-9a-fA-F\:]+\]$/', $host)
- ) {
- return [$host, $port];
- }
-
- // Misinterpreted IPv6-Address
- // Reported for Safari on Windows
- return $marshalIpv6HostAndPort($server, $port);
- };
-
- /**
- * Detect the path for the request
- *
- * Looks at a variety of criteria in order to attempt to autodetect the base
- * request path, including:
- *
- * - IIS7 UrlRewrite environment
- * - REQUEST_URI
- * - ORIG_PATH_INFO
- *
- * From Laminas\Http\PhpEnvironment\Request class
- */
- $marshalRequestPath = static function (array $server): string {
- // IIS7 with URL Rewrite: make sure we get the unencoded url
- // (double slash problem).
- $iisUrlRewritten = $server['IIS_WasUrlRewritten'] ?? null;
- $unencodedUrl = $server['UNENCODED_URL'] ?? '';
- if ('1' === $iisUrlRewritten && ! empty($unencodedUrl)) {
- return $unencodedUrl;
- }
-
- $requestUri = $server['REQUEST_URI'] ?? null;
-
- if ($requestUri !== null) {
- return preg_replace('#^[^/:]+://[^/]+#', '', $requestUri);
- }
-
- $origPathInfo = $server['ORIG_PATH_INFO'] ?? null;
- if (empty($origPathInfo)) {
- return '/';
- }
-
- return $origPathInfo;
- };
-
- $uri = new Uri('');
-
- // URI scheme
- $scheme = 'http';
- $marshalHttpsValue = static function ($https): bool {
- if (is_bool($https)) {
- return $https;
- }
-
- if (! is_string($https)) {
- throw new Exception\InvalidArgumentException(sprintf(
- 'SAPI HTTPS value MUST be a string or boolean; received %s',
- gettype($https)
- ));
- }
-
- return 'on' === strtolower($https);
- };
- if (array_key_exists('HTTPS', $server)) {
- $https = $marshalHttpsValue($server['HTTPS']);
- } elseif (array_key_exists('https', $server)) {
- $https = $marshalHttpsValue($server['https']);
- } else {
- $https = false;
- }
-
- if (
- $https
- || strtolower($getHeaderFromArray('x-forwarded-proto', $headers, '')) === 'https'
- ) {
- $scheme = 'https';
- }
- $uri = $uri->withScheme($scheme);
-
- // Set the host
- [$host, $port] = $marshalHostAndPort($headers, $server);
- if (! empty($host)) {
- $uri = $uri->withHost($host);
- if (! empty($port)) {
- $uri = $uri->withPort($port);
- }
- }
-
- // URI path
- $path = $marshalRequestPath($server);
-
- // Strip query string
- $path = explode('?', $path, 2)[0];
-
- // URI query
- $query = '';
- if (isset($server['QUERY_STRING'])) {
- $query = ltrim($server['QUERY_STRING'], '?');
- }
-
- // URI fragment
- $fragment = '';
- if (str_contains($path, '#')) {
- $parts = explode('#', $path, 2);
- assert(count($parts) >= 2);
- [$path, $fragment] = $parts;
- }
-
- return $uri
- ->withPath($path)
- ->withFragment($fragment)
- ->withQuery($query);
-}
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Zend\Diactoros;
-
-use function func_get_args;
-use function Laminas\Diactoros\normalizeServer as laminas_normalizeServer;
-
-/**
- * @deprecated Use Laminas\Diactoros\normalizeServer instead
- */
-function normalizeServer(array $server, ?callable $apacheRequestHeaderCallback = null): array
-{
- return laminas_normalizeServer(...func_get_args());
-}
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Zend\Diactoros;
-
-use function func_get_args;
-use function Laminas\Diactoros\normalizeUploadedFiles as laminas_normalizeUploadedFiles;
-
-/**
- * @deprecated Use Laminas\Diactoros\normalizeUploadedFiles instead
- */
-function normalizeUploadedFiles(array $files): array
-{
- return laminas_normalizeUploadedFiles(...func_get_args());
-}
+++ /dev/null
-<?php
-
-declare(strict_types=1);
-
-namespace Zend\Diactoros;
-
-use function func_get_args;
-use function Laminas\Diactoros\parseCookieHeader as laminas_parseCookieHeader;
-
-/**
- * @deprecated Use {@see \Laminas\Diactoros\parseCookieHeader} instead
- *
- * @param string $cookieHeader A string cookie header value.
- * @return array<non-empty-string, string> key/value cookie pairs.
- */
-function parseCookieHeader($cookieHeader): array
-{
- return laminas_parseCookieHeader(...func_get_args());
-}
"authors": [
{
"name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
+ "homepage": "https://www.php-fig.org/"
}
],
"require": {
},
"extra": {
"branch-alias": {
- "dev-master": "1.1.x-dev"
+ "dev-master": "2.0.x-dev"
}
}
}
<?php
-declare(strict_types=1);
-
namespace Psr\Http\Message;
/**
*
* @return string HTTP protocol version.
*/
- public function getProtocolVersion();
+ public function getProtocolVersion(): string;
/**
* Return an instance with the specified HTTP protocol version.
* @param string $version HTTP protocol version
* @return static
*/
- public function withProtocolVersion(string $version);
+ public function withProtocolVersion(string $version): MessageInterface;
/**
* Retrieves all message header values.
* key MUST be a header name, and each value MUST be an array of strings
* for that header.
*/
- public function getHeaders();
+ public function getHeaders(): array;
/**
* Checks if a header exists by the given case-insensitive name.
* name using a case-insensitive string comparison. Returns false if
* no matching header name is found in the message.
*/
- public function hasHeader(string $name);
+ public function hasHeader(string $name): bool;
/**
* Retrieves a message header value by the given case-insensitive name.
* header. If the header does not appear in the message, this method MUST
* return an empty array.
*/
- public function getHeader(string $name);
+ public function getHeader(string $name): array;
/**
* Retrieves a comma-separated string of the values for a single header.
* concatenated together using a comma. If the header does not appear in
* the message, this method MUST return an empty string.
*/
- public function getHeaderLine(string $name);
+ public function getHeaderLine(string $name): string;
/**
* Return an instance with the provided value replacing the specified header.
* @return static
* @throws \InvalidArgumentException for invalid header names or values.
*/
- public function withHeader(string $name, $value);
+ public function withHeader(string $name, $value): MessageInterface;
/**
* Return an instance with the specified header appended with the given value.
* @return static
* @throws \InvalidArgumentException for invalid header names or values.
*/
- public function withAddedHeader(string $name, $value);
+ public function withAddedHeader(string $name, $value): MessageInterface;
/**
* Return an instance without the specified header.
* @param string $name Case-insensitive header field name to remove.
* @return static
*/
- public function withoutHeader(string $name);
+ public function withoutHeader(string $name): MessageInterface;
/**
* Gets the body of the message.
*
* @return StreamInterface Returns the body as a stream.
*/
- public function getBody();
+ public function getBody(): StreamInterface;
/**
* Return an instance with the specified message body.
* @return static
* @throws \InvalidArgumentException When the body is not valid.
*/
- public function withBody(StreamInterface $body);
+ public function withBody(StreamInterface $body): MessageInterface;
}
<?php
-declare(strict_types=1);
-
namespace Psr\Http\Message;
/**
*
* @return string
*/
- public function getRequestTarget();
+ public function getRequestTarget(): string;
/**
* Return an instance with the specific request-target.
* @param string $requestTarget
* @return static
*/
- public function withRequestTarget(string $requestTarget);
+ public function withRequestTarget(string $requestTarget): RequestInterface;
+
/**
* Retrieves the HTTP method of the request.
*
* @return string Returns the request method.
*/
- public function getMethod();
+ public function getMethod(): string;
/**
* Return an instance with the provided HTTP method.
* @return static
* @throws \InvalidArgumentException for invalid HTTP methods.
*/
- public function withMethod(string $method);
+ public function withMethod(string $method): RequestInterface;
/**
* Retrieves the URI instance.
* @return UriInterface Returns a UriInterface instance
* representing the URI of the request.
*/
- public function getUri();
+ public function getUri(): UriInterface;
/**
* Returns an instance with the provided URI.
* @param bool $preserveHost Preserve the original state of the Host header.
* @return static
*/
- public function withUri(UriInterface $uri, bool $preserveHost = false);
+ public function withUri(UriInterface $uri, bool $preserveHost = false): RequestInterface;
}
<?php
-declare(strict_types=1);
-
namespace Psr\Http\Message;
/**
*
* @return int Status code.
*/
- public function getStatusCode();
+ public function getStatusCode(): int;
/**
* Return an instance with the specified status code and, optionally, reason phrase.
* @return static
* @throws \InvalidArgumentException For invalid status code arguments.
*/
- public function withStatus(int $code, string $reasonPhrase = '');
+ public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface;
/**
* Gets the response reason phrase associated with the status code.
* @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.
*/
- public function getReasonPhrase();
+ public function getReasonPhrase(): string;
}
<?php
-declare(strict_types=1);
-
namespace Psr\Http\Message;
/**
*
* @return array
*/
- public function getServerParams();
+ public function getServerParams(): array;
/**
* Retrieve cookies.
*
* @return array
*/
- public function getCookieParams();
+ public function getCookieParams(): array;
/**
* Return an instance with the specified cookies.
* @param array $cookies Array of key/value pairs representing cookies.
* @return static
*/
- public function withCookieParams(array $cookies);
+ public function withCookieParams(array $cookies): ServerRequestInterface;
/**
* Retrieve query string arguments.
*
* @return array
*/
- public function getQueryParams();
+ public function getQueryParams(): array;
/**
* Return an instance with the specified query string arguments.
* $_GET.
* @return static
*/
- public function withQueryParams(array $query);
+ public function withQueryParams(array $query): ServerRequestInterface;
/**
* Retrieve normalized file upload data.
* @return array An array tree of UploadedFileInterface instances; an empty
* array MUST be returned if no data is present.
*/
- public function getUploadedFiles();
+ public function getUploadedFiles(): array;
/**
* Create a new instance with the specified uploaded files.
* @return static
* @throws \InvalidArgumentException if an invalid structure is provided.
*/
- public function withUploadedFiles(array $uploadedFiles);
+ public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface;
/**
* Retrieve any parameters provided in the request body.
* @throws \InvalidArgumentException if an unsupported argument type is
* provided.
*/
- public function withParsedBody($data);
+ public function withParsedBody($data): ServerRequestInterface;
/**
* Retrieve attributes derived from the request.
*
* @return array Attributes derived from the request.
*/
- public function getAttributes();
+ public function getAttributes(): array;
/**
* Retrieve a single derived request attribute.
* @param mixed $value The value of the attribute.
* @return static
*/
- public function withAttribute(string $name, $value);
+ public function withAttribute(string $name, $value): ServerRequestInterface;
/**
* Return an instance that removes the specified derived request attribute.
* @param string $name The attribute name.
* @return static
*/
- public function withoutAttribute(string $name);
+ public function withoutAttribute(string $name): ServerRequestInterface;
}
<?php
-declare(strict_types=1);
-
namespace Psr\Http\Message;
/**
* @see http://php.net/manual/en/language.oop5.magic.php#object.tostring
* @return string
*/
- public function __toString();
+ public function __toString(): string;
/**
* Closes the stream and any underlying resources.
*
* @return void
*/
- public function close();
+ public function close(): void;
/**
* Separates any underlying resources from the stream.
*
* @return int|null Returns the size in bytes if known, or null if unknown.
*/
- public function getSize();
+ public function getSize(): ?int;
/**
* Returns the current position of the file read/write pointer
* @return int Position of the file pointer
* @throws \RuntimeException on error.
*/
- public function tell();
+ public function tell(): int;
/**
* Returns true if the stream is at the end of the stream.
*
* @return bool
*/
- public function eof();
+ public function eof(): bool;
/**
* Returns whether or not the stream is seekable.
*
* @return bool
*/
- public function isSeekable();
+ public function isSeekable(): bool;
/**
* Seek to a position in the stream.
* SEEK_END: Set position to end-of-stream plus offset.
* @throws \RuntimeException on failure.
*/
- public function seek(int $offset, int $whence = SEEK_SET);
+ public function seek(int $offset, int $whence = SEEK_SET): void;
/**
* Seek to the beginning of the stream.
* @link http://www.php.net/manual/en/function.fseek.php
* @throws \RuntimeException on failure.
*/
- public function rewind();
+ public function rewind(): void;
/**
* Returns whether or not the stream is writable.
*
* @return bool
*/
- public function isWritable();
+ public function isWritable(): bool;
/**
* Write data to the stream.
* @return int Returns the number of bytes written to the stream.
* @throws \RuntimeException on failure.
*/
- public function write(string $string);
+ public function write(string $string): int;
/**
* Returns whether or not the stream is readable.
*
* @return bool
*/
- public function isReadable();
+ public function isReadable(): bool;
/**
* Read data from the stream.
* if no bytes are available.
* @throws \RuntimeException if an error occurs.
*/
- public function read(int $length);
+ public function read(int $length): string;
/**
* Returns the remaining contents in a string
* @throws \RuntimeException if unable to read or an error occurs while
* reading.
*/
- public function getContents();
+ public function getContents(): string;
/**
* Get stream metadata as an associative array or retrieve a specific key.
<?php
-declare(strict_types=1);
-
namespace Psr\Http\Message;
/**
* @throws \RuntimeException in cases when no stream is available or can be
* created.
*/
- public function getStream();
+ public function getStream(): StreamInterface;
/**
* Move the uploaded file to a new location.
* @throws \RuntimeException on any error during the move operation, or on
* the second or subsequent call to the method.
*/
- public function moveTo(string $targetPath);
+ public function moveTo(string $targetPath): void;
/**
* Retrieve the file size.
*
* @return int|null The file size in bytes or null if unknown.
*/
- public function getSize();
+ public function getSize(): ?int;
/**
* Retrieve the error associated with the uploaded file.
* @see http://php.net/manual/en/features.file-upload.errors.php
* @return int One of PHP's UPLOAD_ERR_XXX constants.
*/
- public function getError();
+ public function getError(): int;
/**
* Retrieve the filename sent by the client.
* @return string|null The filename sent by the client or null if none
* was provided.
*/
- public function getClientFilename();
+ public function getClientFilename(): ?string;
/**
* Retrieve the media type sent by the client.
* @return string|null The media type sent by the client or null if none
* was provided.
*/
- public function getClientMediaType();
+ public function getClientMediaType(): ?string;
}
<?php
-declare(strict_types=1);
-
namespace Psr\Http\Message;
/**
* @see https://tools.ietf.org/html/rfc3986#section-3.1
* @return string The URI scheme.
*/
- public function getScheme();
+ public function getScheme(): string;
/**
* Retrieve the authority component of the URI.
* @see https://tools.ietf.org/html/rfc3986#section-3.2
* @return string The URI authority, in "[user-info@]host[:port]" format.
*/
- public function getAuthority();
+ public function getAuthority(): string;
/**
* Retrieve the user information component of the URI.
*
* @return string The URI user information, in "username[:password]" format.
*/
- public function getUserInfo();
+ public function getUserInfo(): string;
/**
* Retrieve the host component of the URI.
* @see http://tools.ietf.org/html/rfc3986#section-3.2.2
* @return string The URI host.
*/
- public function getHost();
+ public function getHost(): string;
/**
* Retrieve the port component of the URI.
*
* @return null|int The URI port.
*/
- public function getPort();
+ public function getPort(): ?int;
/**
* Retrieve the path component of the URI.
* @see https://tools.ietf.org/html/rfc3986#section-3.3
* @return string The URI path.
*/
- public function getPath();
+ public function getPath(): string;
/**
* Retrieve the query string of the URI.
* @see https://tools.ietf.org/html/rfc3986#section-3.4
* @return string The URI query string.
*/
- public function getQuery();
+ public function getQuery(): string;
/**
* Retrieve the fragment component of the URI.
* @see https://tools.ietf.org/html/rfc3986#section-3.5
* @return string The URI fragment.
*/
- public function getFragment();
+ public function getFragment(): string;
/**
* Return an instance with the specified scheme.
* @return static A new instance with the specified scheme.
* @throws \InvalidArgumentException for invalid or unsupported schemes.
*/
- public function withScheme(string $scheme);
+ public function withScheme(string $scheme): UriInterface;
/**
* Return an instance with the specified user information.
* @param null|string $password The password associated with $user.
* @return static A new instance with the specified user information.
*/
- public function withUserInfo(string $user, ?string $password = null);
+ public function withUserInfo(string $user, ?string $password = null): UriInterface;
/**
* Return an instance with the specified host.
* @return static A new instance with the specified host.
* @throws \InvalidArgumentException for invalid hostnames.
*/
- public function withHost(string $host);
+ public function withHost(string $host): UriInterface;
/**
* Return an instance with the specified port.
* @return static A new instance with the specified port.
* @throws \InvalidArgumentException for invalid ports.
*/
- public function withPort(?int $port);
+ public function withPort(?int $port): UriInterface;
/**
* Return an instance with the specified path.
* @return static A new instance with the specified path.
* @throws \InvalidArgumentException for invalid paths.
*/
- public function withPath(string $path);
+ public function withPath(string $path): UriInterface;
/**
* Return an 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(string $query);
+ public function withQuery(string $query): UriInterface;
/**
* Return an instance with the specified URI fragment.
* @param string $fragment The fragment to use with the new instance.
* @return static A new instance with the specified fragment.
*/
- public function withFragment(string $fragment);
+ public function withFragment(string $fragment): UriInterface;
/**
* Return the string representation as a URI reference.
* @see http://tools.ietf.org/html/rfc3986#section-4.1
* @return string
*/
- public function __toString();
+ public function __toString(): string;
}