京东云
This commit is contained in:
2
vendor/guzzlehttp/psr7/.github/FUNDING.yml
vendored
Normal file
2
vendor/guzzlehttp/psr7/.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
github: [Nyholm, GrahamCampbell]
|
||||
tidelift: "packagist/guzzlehttp/psr7"
|
||||
14
vendor/guzzlehttp/psr7/.github/stale.yml
vendored
Normal file
14
vendor/guzzlehttp/psr7/.github/stale.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
daysUntilStale: 120
|
||||
daysUntilClose: 14
|
||||
exemptLabels:
|
||||
- lifecycle/keep-open
|
||||
- lifecycle/ready-for-merge
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: lifecycle/stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
30
vendor/guzzlehttp/psr7/.github/workflows/ci.yml
vendored
Normal file
30
vendor/guzzlehttp/psr7/.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
max-parallel: 10
|
||||
matrix:
|
||||
php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
|
||||
|
||||
steps:
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: 'none'
|
||||
extensions: mbstring
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer update --no-interaction --no-progress
|
||||
|
||||
- name: Run tests
|
||||
run: make test
|
||||
36
vendor/guzzlehttp/psr7/.github/workflows/integration.yml
vendored
Normal file
36
vendor/guzzlehttp/psr7/.github/workflows/integration.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Integration
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Test
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
max-parallel: 10
|
||||
matrix:
|
||||
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
|
||||
|
||||
steps:
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
coverage: none
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Download dependencies
|
||||
uses: ramsey/composer-install@v1
|
||||
with:
|
||||
composer-options: --no-interaction --optimize-autoloader
|
||||
|
||||
- name: Start server
|
||||
run: php -S 127.0.0.1:10002 tests/Integration/server.php &
|
||||
|
||||
- name: Run tests
|
||||
env:
|
||||
TEST_SERVER: 127.0.0.1:10002
|
||||
run: ./vendor/bin/phpunit --testsuite Integration
|
||||
29
vendor/guzzlehttp/psr7/.github/workflows/static.yml
vendored
Normal file
29
vendor/guzzlehttp/psr7/.github/workflows/static.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Static analysis
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
php-cs-fixer:
|
||||
name: PHP-CS-Fixer
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.4'
|
||||
coverage: none
|
||||
extensions: mbstring
|
||||
|
||||
- name: Download dependencies
|
||||
run: composer update --no-interaction --no-progress
|
||||
|
||||
- name: Download PHP CS Fixer
|
||||
run: composer require "friendsofphp/php-cs-fixer:2.18.4"
|
||||
|
||||
- name: Execute PHP CS Fixer
|
||||
run: vendor/bin/php-cs-fixer fix --diff-format udiff --dry-run
|
||||
56
vendor/guzzlehttp/psr7/.php_cs.dist
vendored
Normal file
56
vendor/guzzlehttp/psr7/.php_cs.dist
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
$config = PhpCsFixer\Config::create()
|
||||
->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PSR2' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'concat_space' => ['spacing' => 'one'],
|
||||
'declare_strict_types' => false,
|
||||
'final_static_access' => true,
|
||||
'fully_qualified_strict_types' => true,
|
||||
'header_comment' => false,
|
||||
'is_null' => ['use_yoda_style' => true],
|
||||
'list_syntax' => ['syntax' => 'long'],
|
||||
'lowercase_cast' => true,
|
||||
'magic_method_casing' => true,
|
||||
'modernize_types_casting' => true,
|
||||
'multiline_comment_opening_closing' => true,
|
||||
'no_alias_functions' => true,
|
||||
'no_alternative_syntax' => true,
|
||||
'no_blank_lines_after_phpdoc' => true,
|
||||
'no_empty_comment' => true,
|
||||
'no_empty_phpdoc' => true,
|
||||
'no_empty_statement' => true,
|
||||
'no_extra_blank_lines' => true,
|
||||
'no_leading_import_slash' => true,
|
||||
'no_trailing_comma_in_singleline_array' => true,
|
||||
'no_unset_cast' => true,
|
||||
'no_unused_imports' => true,
|
||||
'no_whitespace_in_blank_line' => true,
|
||||
'ordered_imports' => true,
|
||||
'php_unit_ordered_covers' => true,
|
||||
'php_unit_test_annotation' => ['style' => 'prefix'],
|
||||
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
|
||||
'phpdoc_align' => ['align' => 'vertical'],
|
||||
'phpdoc_no_useless_inheritdoc' => true,
|
||||
'phpdoc_scalar' => true,
|
||||
'phpdoc_separation' => true,
|
||||
'phpdoc_single_line_var_spacing' => true,
|
||||
'phpdoc_trim' => true,
|
||||
'phpdoc_trim_consecutive_blank_line_separation' => true,
|
||||
'phpdoc_types' => true,
|
||||
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
|
||||
'phpdoc_var_without_name' => true,
|
||||
'single_trait_insert_per_statement' => true,
|
||||
'standardize_not_equals' => true,
|
||||
])
|
||||
->setFinder(
|
||||
PhpCsFixer\Finder::create()
|
||||
->in(__DIR__.'/src')
|
||||
->in(__DIR__.'/tests')
|
||||
->name('*.php')
|
||||
)
|
||||
;
|
||||
|
||||
return $config;
|
||||
144
vendor/guzzlehttp/psr7/CHANGELOG.md
vendored
144
vendor/guzzlehttp/psr7/CHANGELOG.md
vendored
@@ -1,174 +1,50 @@
|
||||
# Change Log
|
||||
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## 2.6.2 - 2023-12-03
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 1.9.1 - 2023-04-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed another issue with the fact that PHP transforms numeric strings in array keys to ints
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated links in docs to their canonical versions
|
||||
- Replaced `call_user_func*` with native calls
|
||||
|
||||
## 2.6.1 - 2023-08-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- Properly handle the fact that PHP transforms numeric strings in array keys to ints
|
||||
|
||||
## 2.6.0 - 2023-08-03
|
||||
|
||||
### Changed
|
||||
|
||||
- Updated the mime type map to add some new entries, fix a couple of invalid entries, and remove an invalid entry
|
||||
- Fallback to `application/octet-stream` if we are unable to guess the content type for a multipart file upload
|
||||
|
||||
## 2.5.1 - 2023-08-03
|
||||
|
||||
### Fixed
|
||||
|
||||
- Corrected mime type for `.acc` files to `audio/aac`
|
||||
|
||||
### Changed
|
||||
|
||||
- PHP 8.3 support
|
||||
|
||||
## 2.5.0 - 2023-04-17
|
||||
|
||||
### Changed
|
||||
|
||||
- Adjusted `psr/http-message` version constraint to `^1.1 || ^2.0`
|
||||
|
||||
## 2.4.5 - 2023-04-17
|
||||
|
||||
### Fixed
|
||||
|
||||
- Prevent possible warnings on unset variables in `ServerRequest::normalizeNestedFileSpec`
|
||||
- Fixed `Message::bodySummary` when `preg_match` fails
|
||||
- Fixed header validation issue
|
||||
|
||||
## 2.4.4 - 2023-03-09
|
||||
|
||||
### Changed
|
||||
|
||||
- Removed the need for `AllowDynamicProperties` in `LazyOpenStream`
|
||||
|
||||
## 2.4.3 - 2022-10-26
|
||||
|
||||
### Changed
|
||||
|
||||
- Replaced `sha1(uniqid())` by `bin2hex(random_bytes(20))`
|
||||
|
||||
## 2.4.2 - 2022-10-25
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed erroneous behaviour when combining host and relative path
|
||||
|
||||
## 2.4.1 - 2022-08-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- Rewind body before reading in `Message::bodySummary`
|
||||
|
||||
## 2.4.0 - 2022-06-20
|
||||
## 1.9.0 - 2022-06-20
|
||||
|
||||
### Added
|
||||
|
||||
- Added provisional PHP 8.2 support
|
||||
- Added `UriComparator::isCrossOrigin` method
|
||||
|
||||
## 2.3.0 - 2022-06-09
|
||||
|
||||
### Fixed
|
||||
|
||||
- Added `Header::splitList` method
|
||||
- Added `Utils::tryGetContents` method
|
||||
- Improved `Stream::getContents` method
|
||||
- Updated mimetype mappings
|
||||
|
||||
## 2.2.2 - 2022-06-08
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fix `Message::parseRequestUri` for numeric headers
|
||||
- Re-wrap exceptions thrown in `fread` into runtime exceptions
|
||||
- Throw an exception when multipart options is misformatted
|
||||
|
||||
## 2.2.1 - 2022-03-20
|
||||
## 1.8.5 - 2022-03-20
|
||||
|
||||
### Fixed
|
||||
|
||||
- Correct header value validation
|
||||
|
||||
## 2.2.0 - 2022-03-20
|
||||
|
||||
### Added
|
||||
|
||||
- A more compressive list of mime types
|
||||
- Add JsonSerializable to Uri
|
||||
- Missing return types
|
||||
|
||||
### Fixed
|
||||
|
||||
- Bug MultipartStream no `uri` metadata
|
||||
- Bug MultipartStream with filename for `data://` streams
|
||||
- Fixed new line handling in MultipartStream
|
||||
- Reduced RAM usage when copying streams
|
||||
- Updated parsing in `Header::normalize()`
|
||||
|
||||
## 2.1.1 - 2022-03-20
|
||||
## 1.8.4 - 2022-03-20
|
||||
|
||||
### Fixed
|
||||
|
||||
- Validate header values properly
|
||||
|
||||
## 2.1.0 - 2021-10-06
|
||||
|
||||
### Changed
|
||||
|
||||
- Attempting to create a `Uri` object from a malformed URI will no longer throw a generic
|
||||
`InvalidArgumentException`, but rather a `MalformedUriException`, which inherits from the former
|
||||
for backwards compatibility. Callers relying on the exception being thrown to detect invalid
|
||||
URIs should catch the new exception.
|
||||
## 1.8.3 - 2021-10-05
|
||||
|
||||
### Fixed
|
||||
|
||||
- Return `null` in caching stream size if remote size is `null`
|
||||
|
||||
## 2.0.0 - 2021-06-30
|
||||
|
||||
Identical to the RC release.
|
||||
|
||||
## 2.0.0@RC-1 - 2021-04-29
|
||||
## 1.8.2 - 2021-04-26
|
||||
|
||||
### Fixed
|
||||
|
||||
- Handle possibly unset `url` in `stream_get_meta_data`
|
||||
|
||||
## 2.0.0@beta-1 - 2021-03-21
|
||||
|
||||
### Added
|
||||
|
||||
- PSR-17 factories
|
||||
- Made classes final
|
||||
- PHP7 type hints
|
||||
|
||||
### Changed
|
||||
|
||||
- When building a query string, booleans are represented as 1 and 0.
|
||||
|
||||
### Removed
|
||||
|
||||
- PHP < 7.2 support
|
||||
- All functions in the `GuzzleHttp\Psr7` namespace
|
||||
|
||||
## 1.8.1 - 2021-03-21
|
||||
|
||||
### Fixed
|
||||
|
||||
84
vendor/guzzlehttp/psr7/README.md
vendored
84
vendor/guzzlehttp/psr7/README.md
vendored
@@ -4,30 +4,16 @@ This repository contains a full [PSR-7](https://www.php-fig.org/psr/psr-7/)
|
||||
message implementation, several stream decorators, and some helpful
|
||||
functionality like query string parsing.
|
||||
|
||||

|
||||

|
||||
|
||||
[](https://travis-ci.org/guzzle/psr7)
|
||||
|
||||
|
||||
## Features
|
||||
# Stream implementation
|
||||
|
||||
This package comes with a number of stream implementations and stream
|
||||
decorators.
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```shell
|
||||
composer require guzzlehttp/psr7
|
||||
```
|
||||
|
||||
## Version Guidance
|
||||
|
||||
| Version | Status | PHP Version |
|
||||
|---------|---------------------|--------------|
|
||||
| 1.x | Security fixes only | >=5.4,<8.1 |
|
||||
| 2.x | Latest | >=7.2.5,<8.4 |
|
||||
|
||||
|
||||
## AppendStream
|
||||
|
||||
`GuzzleHttp\Psr7\AppendStream`
|
||||
@@ -144,9 +130,10 @@ $fnStream->rewind();
|
||||
|
||||
`GuzzleHttp\Psr7\InflateStream`
|
||||
|
||||
Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content.
|
||||
Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
|
||||
|
||||
This stream decorator converts the provided stream to a PHP stream resource,
|
||||
This stream decorator skips the first 10 bytes of the given stream to remove
|
||||
the gzip header, converts the provided stream to a PHP stream resource,
|
||||
then appends the zlib.inflate filter. The stream is then converted back
|
||||
to a Guzzle stream resource to be used as a Guzzle stream.
|
||||
|
||||
@@ -259,8 +246,6 @@ class EofCallbackStream implements StreamInterface
|
||||
|
||||
private $callback;
|
||||
|
||||
private $stream;
|
||||
|
||||
public function __construct(StreamInterface $stream, callable $cb)
|
||||
{
|
||||
$this->stream = $stream;
|
||||
@@ -273,7 +258,7 @@ class EofCallbackStream implements StreamInterface
|
||||
|
||||
// Invoke the callback when EOF is hit.
|
||||
if ($this->eof()) {
|
||||
($this->callback)();
|
||||
call_user_func($this->callback);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -396,28 +381,10 @@ of the header. When a parameter does not contain a value, but just
|
||||
contains a key, this function will inject a key with a '' string value.
|
||||
|
||||
|
||||
## `GuzzleHttp\Psr7\Header::splitList`
|
||||
|
||||
`public static function splitList(string|string[] $header): string[]`
|
||||
|
||||
Splits a HTTP header defined to contain a comma-separated list into
|
||||
each individual value:
|
||||
|
||||
```
|
||||
$knownEtags = Header::splitList($request->getHeader('if-none-match'));
|
||||
```
|
||||
|
||||
Example headers include `accept`, `cache-control` and `if-none-match`.
|
||||
|
||||
|
||||
## `GuzzleHttp\Psr7\Header::normalize` (deprecated)
|
||||
## `GuzzleHttp\Psr7\Header::normalize`
|
||||
|
||||
`public static function normalize(string|array $header): array`
|
||||
|
||||
`Header::normalize()` is deprecated in favor of [`Header::splitList()`](README.md#guzzlehttppsr7headersplitlist)
|
||||
which performs the same operation with a cleaned up API and improved
|
||||
documentation.
|
||||
|
||||
Converts an array of header values that may contain comma separated
|
||||
headers into an array of headers with no comma separated values.
|
||||
|
||||
@@ -561,17 +528,6 @@ When fopen fails, PHP normally raises a warning. This function adds an
|
||||
error handler that checks for errors and throws an exception instead.
|
||||
|
||||
|
||||
## `GuzzleHttp\Psr7\Utils::tryGetContents`
|
||||
|
||||
`public static function tryGetContents(resource $stream): string`
|
||||
|
||||
Safely gets the contents of a given stream.
|
||||
|
||||
When stream_get_contents fails, PHP normally raises a warning. This
|
||||
function adds an error handler that checks for errors and throws an
|
||||
exception instead.
|
||||
|
||||
|
||||
## `GuzzleHttp\Psr7\Utils::uriFor`
|
||||
|
||||
`public static function uriFor(string|UriInterface $uri): UriInterface`
|
||||
@@ -599,7 +555,7 @@ Maps a file extensions to a mimetype.
|
||||
|
||||
## Upgrading from Function API
|
||||
|
||||
The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API was removed in 2.0.0. A migration table has been provided here for your convenience:
|
||||
The static API was first introduced in 1.7.0, in order to mitigate problems with functions conflicting between global and local copies of the package. The function API will be removed in 2.0.0. A migration table has been provided here for your convenience:
|
||||
|
||||
| Original Function | Replacement Method |
|
||||
|----------------|----------------|
|
||||
@@ -637,7 +593,7 @@ this library also provides additional functionality when working with URIs as st
|
||||
An instance of `Psr\Http\Message\UriInterface` can either be an absolute URI or a relative reference.
|
||||
An absolute URI has a scheme. A relative reference is used to express a URI relative to another URI,
|
||||
the base URI. Relative references can be divided into several forms according to
|
||||
[RFC 3986 Section 4.2](https://datatracker.ietf.org/doc/html/rfc3986#section-4.2):
|
||||
[RFC 3986 Section 4.2](https://tools.ietf.org/html/rfc3986#section-4.2):
|
||||
|
||||
- network-path references, e.g. `//example.com/path`
|
||||
- absolute-path references, e.g. `/path`
|
||||
@@ -696,8 +652,8 @@ or the standard port. This method can be used independently of the implementatio
|
||||
`public static function composeComponents($scheme, $authority, $path, $query, $fragment): string`
|
||||
|
||||
Composes a URI reference string from its various components according to
|
||||
[RFC 3986 Section 5.3](https://datatracker.ietf.org/doc/html/rfc3986#section-5.3). Usually this method does not need
|
||||
to be called manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
|
||||
[RFC 3986 Section 5.3](https://tools.ietf.org/html/rfc3986#section-5.3). Usually this method does not need to be called
|
||||
manually but instead is used indirectly via `Psr\Http\Message\UriInterface::__toString`.
|
||||
|
||||
### `GuzzleHttp\Psr7\Uri::fromParts`
|
||||
|
||||
@@ -741,8 +697,8 @@ Determines if a modified URL should be considered cross-origin with respect to a
|
||||
## Reference Resolution
|
||||
|
||||
`GuzzleHttp\Psr7\UriResolver` provides methods to resolve a URI reference in the context of a base URI according
|
||||
to [RFC 3986 Section 5](https://datatracker.ietf.org/doc/html/rfc3986#section-5). This is for example also what web
|
||||
browsers do when resolving a link in a website based on the current request URI.
|
||||
to [RFC 3986 Section 5](https://tools.ietf.org/html/rfc3986#section-5). This is for example also what web browsers
|
||||
do when resolving a link in a website based on the current request URI.
|
||||
|
||||
### `GuzzleHttp\Psr7\UriResolver::resolve`
|
||||
|
||||
@@ -755,7 +711,7 @@ Converts the relative URI into a new URI that is resolved against the base URI.
|
||||
`public static function removeDotSegments(string $path): string`
|
||||
|
||||
Removes dot segments from a path and returns the new path according to
|
||||
[RFC 3986 Section 5.2.4](https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4).
|
||||
[RFC 3986 Section 5.2.4](https://tools.ietf.org/html/rfc3986#section-5.2.4).
|
||||
|
||||
### `GuzzleHttp\Psr7\UriResolver::relativize`
|
||||
|
||||
@@ -781,7 +737,7 @@ echo UriResolver::relativize($base, new Uri('http://example.org/a/b/')); // pr
|
||||
## Normalization and Comparison
|
||||
|
||||
`GuzzleHttp\Psr7\UriNormalizer` provides methods to normalize and compare URIs according to
|
||||
[RFC 3986 Section 6](https://datatracker.ietf.org/doc/html/rfc3986#section-6).
|
||||
[RFC 3986 Section 6](https://tools.ietf.org/html/rfc3986#section-6).
|
||||
|
||||
### `GuzzleHttp\Psr7\UriNormalizer::normalize`
|
||||
|
||||
@@ -863,6 +819,14 @@ This of course assumes they will be resolved against the same base URI. If this
|
||||
equivalence or difference of relative references does not mean anything.
|
||||
|
||||
|
||||
## Version Guidance
|
||||
|
||||
| Version | Status | PHP Version |
|
||||
|---------|----------------|------------------|
|
||||
| 1.x | Security fixes | >=5.4,<8.1 |
|
||||
| 2.x | Latest | ^7.2.5 \|\| ^8.0 |
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/psr7/security/policy) for more information.
|
||||
|
||||
50
vendor/guzzlehttp/psr7/composer.json
vendored
50
vendor/guzzlehttp/psr7/composer.json
vendored
@@ -1,16 +1,7 @@
|
||||
{
|
||||
"name": "guzzlehttp/psr7",
|
||||
"description": "PSR-7 message implementation that also provides common utility methods",
|
||||
"keywords": [
|
||||
"request",
|
||||
"response",
|
||||
"message",
|
||||
"stream",
|
||||
"http",
|
||||
"uri",
|
||||
"url",
|
||||
"psr-7"
|
||||
],
|
||||
"keywords": ["request", "response", "message", "stream", "http", "uri", "url", "psr-7"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
@@ -42,27 +33,19 @@
|
||||
"name": "Tobias Schultze",
|
||||
"email": "webmaster@tubo-world.de",
|
||||
"homepage": "https://github.com/Tobion"
|
||||
},
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com",
|
||||
"homepage": "https://sagikazarmark.hu"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.1 || ^2.0",
|
||||
"ralouphie/getallheaders": "^3.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-factory-implementation": "1.0",
|
||||
"psr/http-message-implementation": "1.0"
|
||||
"php": ">=5.4.0",
|
||||
"psr/http-message": "~1.0",
|
||||
"ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
||||
"http-interop/http-factory-tests": "^0.9",
|
||||
"phpunit/phpunit": "^8.5.36 || ^9.6.15"
|
||||
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10",
|
||||
"ext-zlib": "*"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-message-implementation": "1.0"
|
||||
},
|
||||
"suggest": {
|
||||
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
|
||||
@@ -70,24 +53,19 @@
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Psr7\\": "src/"
|
||||
}
|
||||
},
|
||||
"files": ["src/functions_include.php"]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Tests\\Psr7\\": "tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"bamarni-bin": {
|
||||
"bin-links": true,
|
||||
"forward-command": false
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"allow-plugins": {
|
||||
"bamarni/composer-bin-plugin": true
|
||||
},
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
74
vendor/guzzlehttp/psr7/src/AppendStream.php
vendored
74
vendor/guzzlehttp/psr7/src/AppendStream.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -10,19 +8,16 @@ use Psr\Http\Message\StreamInterface;
|
||||
* Reads from multiple streams, one after the other.
|
||||
*
|
||||
* This is a read-only stream decorator.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class AppendStream implements StreamInterface
|
||||
class AppendStream implements StreamInterface
|
||||
{
|
||||
/** @var StreamInterface[] Streams being decorated */
|
||||
private $streams = [];
|
||||
|
||||
/** @var bool */
|
||||
private $seekable = true;
|
||||
|
||||
/** @var int */
|
||||
private $current = 0;
|
||||
|
||||
/** @var int */
|
||||
private $pos = 0;
|
||||
|
||||
/**
|
||||
@@ -36,18 +31,12 @@ final class AppendStream implements StreamInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function __toString()
|
||||
{
|
||||
try {
|
||||
$this->rewind();
|
||||
|
||||
return $this->getContents();
|
||||
} catch (\Throwable $e) {
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw $e;
|
||||
}
|
||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -59,7 +48,7 @@ final class AppendStream implements StreamInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException if the stream is not readable
|
||||
*/
|
||||
public function addStream(StreamInterface $stream): void
|
||||
public function addStream(StreamInterface $stream)
|
||||
{
|
||||
if (!$stream->isReadable()) {
|
||||
throw new \InvalidArgumentException('Each stream must be readable');
|
||||
@@ -73,15 +62,17 @@ final class AppendStream implements StreamInterface
|
||||
$this->streams[] = $stream;
|
||||
}
|
||||
|
||||
public function getContents(): string
|
||||
public function getContents()
|
||||
{
|
||||
return Utils::copyToString($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes each attached stream.
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function close(): void
|
||||
public function close()
|
||||
{
|
||||
$this->pos = $this->current = 0;
|
||||
$this->seekable = true;
|
||||
@@ -97,6 +88,8 @@ final class AppendStream implements StreamInterface
|
||||
* Detaches each attached stream.
|
||||
*
|
||||
* Returns null as it's not clear which underlying stream resource to return.
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function detach()
|
||||
{
|
||||
@@ -112,7 +105,7 @@ final class AppendStream implements StreamInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
public function tell(): int
|
||||
public function tell()
|
||||
{
|
||||
return $this->pos;
|
||||
}
|
||||
@@ -122,8 +115,10 @@ final class AppendStream implements StreamInterface
|
||||
*
|
||||
* If any of the streams do not return a valid number, then the size of the
|
||||
* append stream cannot be determined and null is returned.
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSize(): ?int
|
||||
public function getSize()
|
||||
{
|
||||
$size = 0;
|
||||
|
||||
@@ -138,22 +133,24 @@ final class AppendStream implements StreamInterface
|
||||
return $size;
|
||||
}
|
||||
|
||||
public function eof(): bool
|
||||
public function eof()
|
||||
{
|
||||
return !$this->streams
|
||||
|| ($this->current >= count($this->streams) - 1
|
||||
&& $this->streams[$this->current]->eof());
|
||||
return !$this->streams ||
|
||||
($this->current >= count($this->streams) - 1 &&
|
||||
$this->streams[$this->current]->eof());
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
public function rewind()
|
||||
{
|
||||
$this->seek(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to seek to the given position. Only supports SEEK_SET.
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
if (!$this->seekable) {
|
||||
throw new \RuntimeException('This AppendStream is not seekable');
|
||||
@@ -169,7 +166,7 @@ final class AppendStream implements StreamInterface
|
||||
$stream->rewind();
|
||||
} catch (\Exception $e) {
|
||||
throw new \RuntimeException('Unable to seek stream '
|
||||
.$i.' of the AppendStream', 0, $e);
|
||||
. $i . ' of the AppendStream', 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,8 +181,10 @@ final class AppendStream implements StreamInterface
|
||||
|
||||
/**
|
||||
* Reads from all of the appended streams until the length is met or EOF.
|
||||
*
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function read($length): string
|
||||
public function read($length)
|
||||
{
|
||||
$buffer = '';
|
||||
$total = count($this->streams) - 1;
|
||||
@@ -193,18 +192,20 @@ final class AppendStream implements StreamInterface
|
||||
$progressToNext = false;
|
||||
|
||||
while ($remaining > 0) {
|
||||
|
||||
// Progress to the next stream if needed.
|
||||
if ($progressToNext || $this->streams[$this->current]->eof()) {
|
||||
$progressToNext = false;
|
||||
if ($this->current === $total) {
|
||||
break;
|
||||
}
|
||||
++$this->current;
|
||||
$this->current++;
|
||||
}
|
||||
|
||||
$result = $this->streams[$this->current]->read($remaining);
|
||||
|
||||
if ($result === '') {
|
||||
// Using a loose comparison here to match on '', false, and null
|
||||
if ($result == null) {
|
||||
$progressToNext = true;
|
||||
continue;
|
||||
}
|
||||
@@ -218,29 +219,26 @@ final class AppendStream implements StreamInterface
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
public function isReadable(): bool
|
||||
public function isReadable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isWritable(): bool
|
||||
public function isWritable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isSeekable(): bool
|
||||
public function isSeekable()
|
||||
{
|
||||
return $this->seekable;
|
||||
}
|
||||
|
||||
public function write($string): int
|
||||
public function write($string)
|
||||
{
|
||||
throw new \RuntimeException('Cannot write to an AppendStream');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadata($key = null)
|
||||
{
|
||||
return $key ? null : [];
|
||||
|
||||
47
vendor/guzzlehttp/psr7/src/BufferStream.php
vendored
47
vendor/guzzlehttp/psr7/src/BufferStream.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -13,33 +11,32 @@ use Psr\Http\Message\StreamInterface;
|
||||
* This stream returns a "hwm" metadata value that tells upstream consumers
|
||||
* what the configured high water mark of the stream is, or the maximum
|
||||
* preferred size of the buffer.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class BufferStream implements StreamInterface
|
||||
class BufferStream implements StreamInterface
|
||||
{
|
||||
/** @var int */
|
||||
private $hwm;
|
||||
|
||||
/** @var string */
|
||||
private $buffer = '';
|
||||
|
||||
/**
|
||||
* @param int $hwm High water mark, representing the preferred maximum
|
||||
* buffer size. If the size of the buffer exceeds the high
|
||||
* water mark, then calls to write will continue to succeed
|
||||
* but will return 0 to inform writers to slow down
|
||||
* but will return false to inform writers to slow down
|
||||
* until the buffer has been drained by reading from it.
|
||||
*/
|
||||
public function __construct(int $hwm = 16384)
|
||||
public function __construct($hwm = 16384)
|
||||
{
|
||||
$this->hwm = $hwm;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getContents();
|
||||
}
|
||||
|
||||
public function getContents(): string
|
||||
public function getContents()
|
||||
{
|
||||
$buffer = $this->buffer;
|
||||
$this->buffer = '';
|
||||
@@ -47,7 +44,7 @@ final class BufferStream implements StreamInterface
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
public function close(): void
|
||||
public function close()
|
||||
{
|
||||
$this->buffer = '';
|
||||
}
|
||||
@@ -59,42 +56,42 @@ final class BufferStream implements StreamInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getSize(): ?int
|
||||
public function getSize()
|
||||
{
|
||||
return strlen($this->buffer);
|
||||
}
|
||||
|
||||
public function isReadable(): bool
|
||||
public function isReadable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isWritable(): bool
|
||||
public function isWritable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isSeekable(): bool
|
||||
public function isSeekable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
public function rewind()
|
||||
{
|
||||
$this->seek(0);
|
||||
}
|
||||
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
throw new \RuntimeException('Cannot seek a BufferStream');
|
||||
}
|
||||
|
||||
public function eof(): bool
|
||||
public function eof()
|
||||
{
|
||||
return strlen($this->buffer) === 0;
|
||||
}
|
||||
|
||||
public function tell(): int
|
||||
public function tell()
|
||||
{
|
||||
throw new \RuntimeException('Cannot determine the position of a BufferStream');
|
||||
}
|
||||
@@ -102,7 +99,7 @@ final class BufferStream implements StreamInterface
|
||||
/**
|
||||
* Reads data from the buffer.
|
||||
*/
|
||||
public function read($length): string
|
||||
public function read($length)
|
||||
{
|
||||
$currentLength = strlen($this->buffer);
|
||||
|
||||
@@ -122,23 +119,21 @@ final class BufferStream implements StreamInterface
|
||||
/**
|
||||
* Writes data to the buffer.
|
||||
*/
|
||||
public function write($string): int
|
||||
public function write($string)
|
||||
{
|
||||
$this->buffer .= $string;
|
||||
|
||||
// TODO: What should happen here?
|
||||
if (strlen($this->buffer) >= $this->hwm) {
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return strlen($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadata($key = null)
|
||||
{
|
||||
if ($key === 'hwm') {
|
||||
if ($key == 'hwm') {
|
||||
return $this->hwm;
|
||||
}
|
||||
|
||||
|
||||
36
vendor/guzzlehttp/psr7/src/CachingStream.php
vendored
36
vendor/guzzlehttp/psr7/src/CachingStream.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -9,8 +7,10 @@ use Psr\Http\Message\StreamInterface;
|
||||
/**
|
||||
* Stream decorator that can cache previously read bytes from a sequentially
|
||||
* read stream.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class CachingStream implements StreamInterface
|
||||
class CachingStream implements StreamInterface
|
||||
{
|
||||
use StreamDecoratorTrait;
|
||||
|
||||
@@ -20,11 +20,6 @@ final class CachingStream implements StreamInterface
|
||||
/** @var int Number of bytes to skip reading due to a write on the buffer */
|
||||
private $skipReadBytes = 0;
|
||||
|
||||
/**
|
||||
* @var StreamInterface
|
||||
*/
|
||||
private $stream;
|
||||
|
||||
/**
|
||||
* We will treat the buffer object as the body of the stream
|
||||
*
|
||||
@@ -39,7 +34,7 @@ final class CachingStream implements StreamInterface
|
||||
$this->stream = $target ?: new Stream(Utils::tryFopen('php://temp', 'r+'));
|
||||
}
|
||||
|
||||
public function getSize(): ?int
|
||||
public function getSize()
|
||||
{
|
||||
$remoteSize = $this->remoteStream->getSize();
|
||||
|
||||
@@ -50,18 +45,18 @@ final class CachingStream implements StreamInterface
|
||||
return max($this->stream->getSize(), $remoteSize);
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
public function rewind()
|
||||
{
|
||||
$this->seek(0);
|
||||
}
|
||||
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
if ($whence === SEEK_SET) {
|
||||
if ($whence == SEEK_SET) {
|
||||
$byte = $offset;
|
||||
} elseif ($whence === SEEK_CUR) {
|
||||
} elseif ($whence == SEEK_CUR) {
|
||||
$byte = $offset + $this->tell();
|
||||
} elseif ($whence === SEEK_END) {
|
||||
} elseif ($whence == SEEK_END) {
|
||||
$size = $this->remoteStream->getSize();
|
||||
if ($size === null) {
|
||||
$size = $this->cacheEntireStream();
|
||||
@@ -86,7 +81,7 @@ final class CachingStream implements StreamInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function read($length): string
|
||||
public function read($length)
|
||||
{
|
||||
// Perform a regular read on any previously read data from the buffer
|
||||
$data = $this->stream->read($length);
|
||||
@@ -115,7 +110,7 @@ final class CachingStream implements StreamInterface
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function write($string): int
|
||||
public function write($string)
|
||||
{
|
||||
// When appending to the end of the currently read stream, you'll want
|
||||
// to skip bytes from being read from the remote stream to emulate
|
||||
@@ -129,7 +124,7 @@ final class CachingStream implements StreamInterface
|
||||
return $this->stream->write($string);
|
||||
}
|
||||
|
||||
public function eof(): bool
|
||||
public function eof()
|
||||
{
|
||||
return $this->stream->eof() && $this->remoteStream->eof();
|
||||
}
|
||||
@@ -137,13 +132,12 @@ final class CachingStream implements StreamInterface
|
||||
/**
|
||||
* Close both the remote stream and buffer stream
|
||||
*/
|
||||
public function close(): void
|
||||
public function close()
|
||||
{
|
||||
$this->remoteStream->close();
|
||||
$this->stream->close();
|
||||
$this->remoteStream->close() && $this->stream->close();
|
||||
}
|
||||
|
||||
private function cacheEntireStream(): int
|
||||
private function cacheEntireStream()
|
||||
{
|
||||
$target = new FnStream(['write' => 'strlen']);
|
||||
Utils::copyToStream($this, $target);
|
||||
|
||||
14
vendor/guzzlehttp/psr7/src/DroppingStream.php
vendored
14
vendor/guzzlehttp/psr7/src/DroppingStream.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -9,28 +7,26 @@ use Psr\Http\Message\StreamInterface;
|
||||
/**
|
||||
* Stream decorator that begins dropping data once the size of the underlying
|
||||
* stream becomes too full.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class DroppingStream implements StreamInterface
|
||||
class DroppingStream implements StreamInterface
|
||||
{
|
||||
use StreamDecoratorTrait;
|
||||
|
||||
/** @var int */
|
||||
private $maxLength;
|
||||
|
||||
/** @var StreamInterface */
|
||||
private $stream;
|
||||
|
||||
/**
|
||||
* @param StreamInterface $stream Underlying stream to decorate.
|
||||
* @param int $maxLength Maximum size before dropping data.
|
||||
*/
|
||||
public function __construct(StreamInterface $stream, int $maxLength)
|
||||
public function __construct(StreamInterface $stream, $maxLength)
|
||||
{
|
||||
$this->stream = $stream;
|
||||
$this->maxLength = $maxLength;
|
||||
}
|
||||
|
||||
public function write($string): int
|
||||
public function write($string)
|
||||
{
|
||||
$diff = $this->maxLength - $this->stream->getSize();
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7\Exception;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Exception thrown if a URI cannot be parsed because it's malformed.
|
||||
*/
|
||||
class MalformedUriException extends InvalidArgumentException
|
||||
{
|
||||
}
|
||||
111
vendor/guzzlehttp/psr7/src/FnStream.php
vendored
111
vendor/guzzlehttp/psr7/src/FnStream.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -11,21 +9,21 @@ use Psr\Http\Message\StreamInterface;
|
||||
*
|
||||
* Allows for easy testing and extension of a provided stream without needing
|
||||
* to create a concrete class for a simple extension point.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
final class FnStream implements StreamInterface
|
||||
class FnStream implements StreamInterface
|
||||
{
|
||||
private const SLOTS = [
|
||||
'__toString', 'close', 'detach', 'rewind',
|
||||
'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
|
||||
'isReadable', 'read', 'getContents', 'getMetadata',
|
||||
];
|
||||
|
||||
/** @var array<string, callable> */
|
||||
/** @var array */
|
||||
private $methods;
|
||||
|
||||
/** @var array Methods that must be implemented in the given array */
|
||||
private static $slots = ['__toString', 'close', 'detach', 'rewind',
|
||||
'getSize', 'tell', 'eof', 'isSeekable', 'seek', 'isWritable', 'write',
|
||||
'isReadable', 'read', 'getContents', 'getMetadata'];
|
||||
|
||||
/**
|
||||
* @param array<string, callable> $methods Hash of method name to a callable.
|
||||
* @param array $methods Hash of method name to a callable.
|
||||
*/
|
||||
public function __construct(array $methods)
|
||||
{
|
||||
@@ -33,7 +31,7 @@ final class FnStream implements StreamInterface
|
||||
|
||||
// Create the functions on the class
|
||||
foreach ($methods as $name => $fn) {
|
||||
$this->{'_fn_'.$name} = $fn;
|
||||
$this->{'_fn_' . $name} = $fn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,10 +40,10 @@ final class FnStream implements StreamInterface
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
public function __get(string $name): void
|
||||
public function __get($name)
|
||||
{
|
||||
throw new \BadMethodCallException(str_replace('_fn_', '', $name)
|
||||
.'() is not implemented in the FnStream');
|
||||
. '() is not implemented in the FnStream');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +52,7 @@ final class FnStream implements StreamInterface
|
||||
public function __destruct()
|
||||
{
|
||||
if (isset($this->_fn_close)) {
|
||||
($this->_fn_close)();
|
||||
call_user_func($this->_fn_close);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +61,7 @@ final class FnStream implements StreamInterface
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function __wakeup(): void
|
||||
public function __wakeup()
|
||||
{
|
||||
throw new \LogicException('FnStream should never be unserialized');
|
||||
}
|
||||
@@ -72,8 +70,8 @@ final class FnStream implements StreamInterface
|
||||
* Adds custom functionality to an underlying stream by intercepting
|
||||
* specific method calls.
|
||||
*
|
||||
* @param StreamInterface $stream Stream to decorate
|
||||
* @param array<string, callable> $methods Hash of method name to a closure
|
||||
* @param StreamInterface $stream Stream to decorate
|
||||
* @param array $methods Hash of method name to a closure
|
||||
*
|
||||
* @return FnStream
|
||||
*/
|
||||
@@ -81,100 +79,85 @@ final class FnStream implements StreamInterface
|
||||
{
|
||||
// If any of the required methods were not provided, then simply
|
||||
// proxy to the decorated stream.
|
||||
foreach (array_diff(self::SLOTS, array_keys($methods)) as $diff) {
|
||||
/** @var callable $callable */
|
||||
$callable = [$stream, $diff];
|
||||
$methods[$diff] = $callable;
|
||||
foreach (array_diff(self::$slots, array_keys($methods)) as $diff) {
|
||||
$methods[$diff] = [$stream, $diff];
|
||||
}
|
||||
|
||||
return new self($methods);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function __toString()
|
||||
{
|
||||
try {
|
||||
/** @var string */
|
||||
return ($this->_fn___toString)();
|
||||
} catch (\Throwable $e) {
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw $e;
|
||||
}
|
||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
||||
|
||||
return '';
|
||||
}
|
||||
return call_user_func($this->_fn___toString);
|
||||
}
|
||||
|
||||
public function close(): void
|
||||
public function close()
|
||||
{
|
||||
($this->_fn_close)();
|
||||
return call_user_func($this->_fn_close);
|
||||
}
|
||||
|
||||
public function detach()
|
||||
{
|
||||
return ($this->_fn_detach)();
|
||||
return call_user_func($this->_fn_detach);
|
||||
}
|
||||
|
||||
public function getSize(): ?int
|
||||
public function getSize()
|
||||
{
|
||||
return ($this->_fn_getSize)();
|
||||
return call_user_func($this->_fn_getSize);
|
||||
}
|
||||
|
||||
public function tell(): int
|
||||
public function tell()
|
||||
{
|
||||
return ($this->_fn_tell)();
|
||||
return call_user_func($this->_fn_tell);
|
||||
}
|
||||
|
||||
public function eof(): bool
|
||||
public function eof()
|
||||
{
|
||||
return ($this->_fn_eof)();
|
||||
return call_user_func($this->_fn_eof);
|
||||
}
|
||||
|
||||
public function isSeekable(): bool
|
||||
public function isSeekable()
|
||||
{
|
||||
return ($this->_fn_isSeekable)();
|
||||
return call_user_func($this->_fn_isSeekable);
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
public function rewind()
|
||||
{
|
||||
($this->_fn_rewind)();
|
||||
call_user_func($this->_fn_rewind);
|
||||
}
|
||||
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
($this->_fn_seek)($offset, $whence);
|
||||
call_user_func($this->_fn_seek, $offset, $whence);
|
||||
}
|
||||
|
||||
public function isWritable(): bool
|
||||
public function isWritable()
|
||||
{
|
||||
return ($this->_fn_isWritable)();
|
||||
return call_user_func($this->_fn_isWritable);
|
||||
}
|
||||
|
||||
public function write($string): int
|
||||
public function write($string)
|
||||
{
|
||||
return ($this->_fn_write)($string);
|
||||
return call_user_func($this->_fn_write, $string);
|
||||
}
|
||||
|
||||
public function isReadable(): bool
|
||||
public function isReadable()
|
||||
{
|
||||
return ($this->_fn_isReadable)();
|
||||
return call_user_func($this->_fn_isReadable);
|
||||
}
|
||||
|
||||
public function read($length): string
|
||||
public function read($length)
|
||||
{
|
||||
return ($this->_fn_read)($length);
|
||||
return call_user_func($this->_fn_read, $length);
|
||||
}
|
||||
|
||||
public function getContents(): string
|
||||
public function getContents()
|
||||
{
|
||||
return ($this->_fn_getContents)();
|
||||
return call_user_func($this->_fn_getContents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadata($key = null)
|
||||
{
|
||||
return ($this->_fn_getMetadata)($key);
|
||||
return call_user_func($this->_fn_getMetadata, $key);
|
||||
}
|
||||
}
|
||||
|
||||
113
vendor/guzzlehttp/psr7/src/Header.php
vendored
113
vendor/guzzlehttp/psr7/src/Header.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
final class Header
|
||||
@@ -13,28 +11,28 @@ final class Header
|
||||
* contains a key, this function will inject a key with a '' string value.
|
||||
*
|
||||
* @param string|array $header Header to parse into components.
|
||||
*
|
||||
* @return array Returns the parsed header values.
|
||||
*/
|
||||
public static function parse($header): array
|
||||
public static function parse($header)
|
||||
{
|
||||
static $trimmed = "\"' \n\t\r";
|
||||
$params = $matches = [];
|
||||
|
||||
foreach ((array) $header as $value) {
|
||||
foreach (self::splitList($value) as $val) {
|
||||
$part = [];
|
||||
foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) ?: [] as $kvp) {
|
||||
if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
|
||||
$m = $matches[0];
|
||||
if (isset($m[1])) {
|
||||
$part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
|
||||
} else {
|
||||
$part[] = trim($m[0], $trimmed);
|
||||
}
|
||||
foreach (self::normalize($header) as $val) {
|
||||
$part = [];
|
||||
foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
|
||||
if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) {
|
||||
$m = $matches[0];
|
||||
if (isset($m[1])) {
|
||||
$part[trim($m[0], $trimmed)] = trim($m[1], $trimmed);
|
||||
} else {
|
||||
$part[] = trim($m[0], $trimmed);
|
||||
}
|
||||
}
|
||||
if ($part) {
|
||||
$params[] = $part;
|
||||
}
|
||||
}
|
||||
if ($part) {
|
||||
$params[] = $part;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,85 +45,24 @@ final class Header
|
||||
*
|
||||
* @param string|array $header Header to normalize.
|
||||
*
|
||||
* @deprecated Use self::splitList() instead.
|
||||
* @return array Returns the normalized header field values.
|
||||
*/
|
||||
public static function normalize($header): array
|
||||
public static function normalize($header)
|
||||
{
|
||||
$result = [];
|
||||
foreach ((array) $header as $value) {
|
||||
foreach (self::splitList($value) as $parsed) {
|
||||
$result[] = $parsed;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits a HTTP header defined to contain a comma-separated list into
|
||||
* each individual value. Empty values will be removed.
|
||||
*
|
||||
* Example headers include 'accept', 'cache-control' and 'if-none-match'.
|
||||
*
|
||||
* This method must not be used to parse headers that are not defined as
|
||||
* a list, such as 'user-agent' or 'set-cookie'.
|
||||
*
|
||||
* @param string|string[] $values Header value as returned by MessageInterface::getHeader()
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function splitList($values): array
|
||||
{
|
||||
if (!\is_array($values)) {
|
||||
$values = [$values];
|
||||
if (!is_array($header)) {
|
||||
return array_map('trim', explode(',', $header));
|
||||
}
|
||||
|
||||
$result = [];
|
||||
foreach ($values as $value) {
|
||||
if (!\is_string($value)) {
|
||||
throw new \TypeError('$header must either be a string or an array containing strings.');
|
||||
}
|
||||
|
||||
$v = '';
|
||||
$isQuoted = false;
|
||||
$isEscaped = false;
|
||||
for ($i = 0, $max = \strlen($value); $i < $max; ++$i) {
|
||||
if ($isEscaped) {
|
||||
$v .= $value[$i];
|
||||
$isEscaped = false;
|
||||
|
||||
foreach ($header as $value) {
|
||||
foreach ((array) $value as $v) {
|
||||
if (strpos($v, ',') === false) {
|
||||
$result[] = $v;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$isQuoted && $value[$i] === ',') {
|
||||
$v = \trim($v);
|
||||
if ($v !== '') {
|
||||
$result[] = $v;
|
||||
}
|
||||
|
||||
$v = '';
|
||||
continue;
|
||||
foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) {
|
||||
$result[] = trim($vv);
|
||||
}
|
||||
|
||||
if ($isQuoted && $value[$i] === '\\') {
|
||||
$isEscaped = true;
|
||||
$v .= $value[$i];
|
||||
|
||||
continue;
|
||||
}
|
||||
if ($value[$i] === '"') {
|
||||
$isQuoted = !$isQuoted;
|
||||
$v .= $value[$i];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$v .= $value[$i];
|
||||
}
|
||||
|
||||
$v = \trim($v);
|
||||
if ($v !== '') {
|
||||
$result[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
94
vendor/guzzlehttp/psr7/src/HttpFactory.php
vendored
94
vendor/guzzlehttp/psr7/src/HttpFactory.php
vendored
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\RequestFactoryInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseFactoryInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestFactoryInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Message\StreamFactoryInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Http\Message\UploadedFileFactoryInterface;
|
||||
use Psr\Http\Message\UploadedFileInterface;
|
||||
use Psr\Http\Message\UriFactoryInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* Implements all of the PSR-17 interfaces.
|
||||
*
|
||||
* Note: in consuming code it is recommended to require the implemented interfaces
|
||||
* and inject the instance of this class multiple times.
|
||||
*/
|
||||
final class HttpFactory implements RequestFactoryInterface, ResponseFactoryInterface, ServerRequestFactoryInterface, StreamFactoryInterface, UploadedFileFactoryInterface, UriFactoryInterface
|
||||
{
|
||||
public function createUploadedFile(
|
||||
StreamInterface $stream,
|
||||
int $size = null,
|
||||
int $error = \UPLOAD_ERR_OK,
|
||||
string $clientFilename = null,
|
||||
string $clientMediaType = null
|
||||
): UploadedFileInterface {
|
||||
if ($size === null) {
|
||||
$size = $stream->getSize();
|
||||
}
|
||||
|
||||
return new UploadedFile($stream, $size, $error, $clientFilename, $clientMediaType);
|
||||
}
|
||||
|
||||
public function createStream(string $content = ''): StreamInterface
|
||||
{
|
||||
return Utils::streamFor($content);
|
||||
}
|
||||
|
||||
public function createStreamFromFile(string $file, string $mode = 'r'): StreamInterface
|
||||
{
|
||||
try {
|
||||
$resource = Utils::tryFopen($file, $mode);
|
||||
} catch (\RuntimeException $e) {
|
||||
if ('' === $mode || false === \in_array($mode[0], ['r', 'w', 'a', 'x', 'c'], true)) {
|
||||
throw new \InvalidArgumentException(sprintf('Invalid file opening mode "%s"', $mode), 0, $e);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return Utils::streamFor($resource);
|
||||
}
|
||||
|
||||
public function createStreamFromResource($resource): StreamInterface
|
||||
{
|
||||
return Utils::streamFor($resource);
|
||||
}
|
||||
|
||||
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface
|
||||
{
|
||||
if (empty($method)) {
|
||||
if (!empty($serverParams['REQUEST_METHOD'])) {
|
||||
$method = $serverParams['REQUEST_METHOD'];
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Cannot determine HTTP method');
|
||||
}
|
||||
}
|
||||
|
||||
return new ServerRequest($method, $uri, [], null, '1.1', $serverParams);
|
||||
}
|
||||
|
||||
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface
|
||||
{
|
||||
return new Response($code, [], null, '1.1', $reasonPhrase);
|
||||
}
|
||||
|
||||
public function createRequest(string $method, $uri): RequestInterface
|
||||
{
|
||||
return new Request($method, $uri);
|
||||
}
|
||||
|
||||
public function createUri(string $uri = ''): UriInterface
|
||||
{
|
||||
return new Uri($uri);
|
||||
}
|
||||
}
|
||||
51
vendor/guzzlehttp/psr7/src/InflateStream.php
vendored
51
vendor/guzzlehttp/psr7/src/InflateStream.php
vendored
@@ -1,37 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* Uses PHP's zlib.inflate filter to inflate zlib (HTTP deflate, RFC1950) or gzipped (RFC1952) content.
|
||||
* Uses PHP's zlib.inflate filter to inflate deflate or gzipped content.
|
||||
*
|
||||
* This stream decorator converts the provided stream to a PHP stream resource,
|
||||
* This stream decorator skips the first 10 bytes of the given stream to remove
|
||||
* the gzip header, converts the provided stream to a PHP stream resource,
|
||||
* then appends the zlib.inflate filter. The stream is then converted back
|
||||
* to a Guzzle stream resource to be used as a Guzzle stream.
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc1950
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc1952
|
||||
* @see https://www.php.net/manual/en/filters.compression.php
|
||||
* @link http://tools.ietf.org/html/rfc1952
|
||||
* @link http://php.net/manual/en/filters.compression.php
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class InflateStream implements StreamInterface
|
||||
class InflateStream implements StreamInterface
|
||||
{
|
||||
use StreamDecoratorTrait;
|
||||
|
||||
/** @var StreamInterface */
|
||||
private $stream;
|
||||
|
||||
public function __construct(StreamInterface $stream)
|
||||
{
|
||||
// read the first 10 bytes, ie. gzip header
|
||||
$header = $stream->read(10);
|
||||
$filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header);
|
||||
// Skip the header, that is 10 + length of filename + 1 (nil) bytes
|
||||
$stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength);
|
||||
$resource = StreamWrapper::getResource($stream);
|
||||
// Specify window=15+32, so zlib will use header detection to both gzip (with header) and zlib data
|
||||
// See https://www.zlib.net/manual.html#Advanced definition of inflateInit2
|
||||
// "Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection"
|
||||
// Default window size is 15.
|
||||
stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ, ['window' => 15 + 32]);
|
||||
stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ);
|
||||
$this->stream = $stream->isSeekable() ? new Stream($resource) : new NoSeekStream(new Stream($resource));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param StreamInterface $stream
|
||||
* @param $header
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header)
|
||||
{
|
||||
$filename_header_length = 0;
|
||||
|
||||
if (substr(bin2hex($header), 6, 2) === '08') {
|
||||
// we have a filename, read until nil
|
||||
$filename_header_length = 1;
|
||||
while ($stream->read(1) !== chr(0)) {
|
||||
$filename_header_length++;
|
||||
}
|
||||
}
|
||||
|
||||
return $filename_header_length;
|
||||
}
|
||||
}
|
||||
|
||||
23
vendor/guzzlehttp/psr7/src/LazyOpenStream.php
vendored
23
vendor/guzzlehttp/psr7/src/LazyOpenStream.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -9,40 +7,35 @@ use Psr\Http\Message\StreamInterface;
|
||||
/**
|
||||
* Lazily reads or writes to a file that is opened only after an IO operation
|
||||
* take place on the stream.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class LazyOpenStream implements StreamInterface
|
||||
class LazyOpenStream implements StreamInterface
|
||||
{
|
||||
use StreamDecoratorTrait;
|
||||
|
||||
/** @var string */
|
||||
/** @var string File to open */
|
||||
private $filename;
|
||||
|
||||
/** @var string */
|
||||
private $mode;
|
||||
|
||||
/**
|
||||
* @var StreamInterface
|
||||
*/
|
||||
private $stream;
|
||||
|
||||
/**
|
||||
* @param string $filename File to lazily open
|
||||
* @param string $mode fopen mode to use when opening the stream
|
||||
*/
|
||||
public function __construct(string $filename, string $mode)
|
||||
public function __construct($filename, $mode)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
$this->mode = $mode;
|
||||
|
||||
// unsetting the property forces the first access to go through
|
||||
// __get().
|
||||
unset($this->stream);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the underlying stream lazily when required.
|
||||
*
|
||||
* @return StreamInterface
|
||||
*/
|
||||
protected function createStream(): StreamInterface
|
||||
protected function createStream()
|
||||
{
|
||||
return Utils::streamFor(Utils::tryFopen($this->filename, $this->mode));
|
||||
}
|
||||
|
||||
36
vendor/guzzlehttp/psr7/src/LimitStream.php
vendored
36
vendor/guzzlehttp/psr7/src/LimitStream.php
vendored
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* Decorator used to return only a subset of a stream.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class LimitStream implements StreamInterface
|
||||
class LimitStream implements StreamInterface
|
||||
{
|
||||
use StreamDecoratorTrait;
|
||||
|
||||
@@ -19,9 +19,6 @@ final class LimitStream implements StreamInterface
|
||||
/** @var int Limit the number of bytes that can be read */
|
||||
private $limit;
|
||||
|
||||
/** @var StreamInterface */
|
||||
private $stream;
|
||||
|
||||
/**
|
||||
* @param StreamInterface $stream Stream to wrap
|
||||
* @param int $limit Total number of bytes to allow to be read
|
||||
@@ -31,15 +28,15 @@ final class LimitStream implements StreamInterface
|
||||
*/
|
||||
public function __construct(
|
||||
StreamInterface $stream,
|
||||
int $limit = -1,
|
||||
int $offset = 0
|
||||
$limit = -1,
|
||||
$offset = 0
|
||||
) {
|
||||
$this->stream = $stream;
|
||||
$this->setLimit($limit);
|
||||
$this->setOffset($offset);
|
||||
}
|
||||
|
||||
public function eof(): bool
|
||||
public function eof()
|
||||
{
|
||||
// Always return true if the underlying stream is EOF
|
||||
if ($this->stream->eof()) {
|
||||
@@ -47,7 +44,7 @@ final class LimitStream implements StreamInterface
|
||||
}
|
||||
|
||||
// No limit and the underlying stream is not at EOF
|
||||
if ($this->limit === -1) {
|
||||
if ($this->limit == -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -56,12 +53,13 @@ final class LimitStream implements StreamInterface
|
||||
|
||||
/**
|
||||
* Returns the size of the limited subset of data
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSize(): ?int
|
||||
public function getSize()
|
||||
{
|
||||
if (null === ($length = $this->stream->getSize())) {
|
||||
return null;
|
||||
} elseif ($this->limit === -1) {
|
||||
} elseif ($this->limit == -1) {
|
||||
return $length - $this->offset;
|
||||
} else {
|
||||
return min($this->limit, $length - $this->offset);
|
||||
@@ -70,8 +68,9 @@ final class LimitStream implements StreamInterface
|
||||
|
||||
/**
|
||||
* Allow for a bounded seek on the read limited stream
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
if ($whence !== SEEK_SET || $offset < 0) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
@@ -94,8 +93,9 @@ final class LimitStream implements StreamInterface
|
||||
|
||||
/**
|
||||
* Give a relative tell()
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function tell(): int
|
||||
public function tell()
|
||||
{
|
||||
return $this->stream->tell() - $this->offset;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ final class LimitStream implements StreamInterface
|
||||
*
|
||||
* @throws \RuntimeException if the stream cannot be seeked.
|
||||
*/
|
||||
public function setOffset(int $offset): void
|
||||
public function setOffset($offset)
|
||||
{
|
||||
$current = $this->stream->tell();
|
||||
|
||||
@@ -132,14 +132,14 @@ final class LimitStream implements StreamInterface
|
||||
* @param int $limit Number of bytes to allow to be read from the stream.
|
||||
* Use -1 for no limit.
|
||||
*/
|
||||
public function setLimit(int $limit): void
|
||||
public function setLimit($limit)
|
||||
{
|
||||
$this->limit = $limit;
|
||||
}
|
||||
|
||||
public function read($length): string
|
||||
public function read($length)
|
||||
{
|
||||
if ($this->limit === -1) {
|
||||
if ($this->limit == -1) {
|
||||
return $this->stream->read($length);
|
||||
}
|
||||
|
||||
|
||||
74
vendor/guzzlehttp/psr7/src/Message.php
vendored
74
vendor/guzzlehttp/psr7/src/Message.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
@@ -14,35 +12,37 @@ final class Message
|
||||
* Returns the string representation of an HTTP message.
|
||||
*
|
||||
* @param MessageInterface $message Message to convert to a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function toString(MessageInterface $message): string
|
||||
public static function toString(MessageInterface $message)
|
||||
{
|
||||
if ($message instanceof RequestInterface) {
|
||||
$msg = trim($message->getMethod().' '
|
||||
.$message->getRequestTarget())
|
||||
.' HTTP/'.$message->getProtocolVersion();
|
||||
$msg = trim($message->getMethod() . ' '
|
||||
. $message->getRequestTarget())
|
||||
. ' HTTP/' . $message->getProtocolVersion();
|
||||
if (!$message->hasHeader('host')) {
|
||||
$msg .= "\r\nHost: ".$message->getUri()->getHost();
|
||||
$msg .= "\r\nHost: " . $message->getUri()->getHost();
|
||||
}
|
||||
} elseif ($message instanceof ResponseInterface) {
|
||||
$msg = 'HTTP/'.$message->getProtocolVersion().' '
|
||||
.$message->getStatusCode().' '
|
||||
.$message->getReasonPhrase();
|
||||
$msg = 'HTTP/' . $message->getProtocolVersion() . ' '
|
||||
. $message->getStatusCode() . ' '
|
||||
. $message->getReasonPhrase();
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Unknown message type');
|
||||
}
|
||||
|
||||
foreach ($message->getHeaders() as $name => $values) {
|
||||
if (is_string($name) && strtolower($name) === 'set-cookie') {
|
||||
if (strtolower($name) === 'set-cookie') {
|
||||
foreach ($values as $value) {
|
||||
$msg .= "\r\n{$name}: ".$value;
|
||||
$msg .= "\r\n{$name}: " . $value;
|
||||
}
|
||||
} else {
|
||||
$msg .= "\r\n{$name}: ".implode(', ', $values);
|
||||
$msg .= "\r\n{$name}: " . implode(', ', $values);
|
||||
}
|
||||
}
|
||||
|
||||
return "{$msg}\r\n\r\n".$message->getBody();
|
||||
return "{$msg}\r\n\r\n" . $message->getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,8 +52,10 @@ final class Message
|
||||
*
|
||||
* @param MessageInterface $message The message to get the body summary
|
||||
* @param int $truncateAt The maximum allowed size of the summary
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public static function bodySummary(MessageInterface $message, int $truncateAt = 120): ?string
|
||||
public static function bodySummary(MessageInterface $message, $truncateAt = 120)
|
||||
{
|
||||
$body = $message->getBody();
|
||||
|
||||
@@ -67,7 +69,6 @@ final class Message
|
||||
return null;
|
||||
}
|
||||
|
||||
$body->rewind();
|
||||
$summary = $body->read($truncateAt);
|
||||
$body->rewind();
|
||||
|
||||
@@ -77,7 +78,7 @@ final class Message
|
||||
|
||||
// Matches any printable character, including unicode characters:
|
||||
// letters, marks, numbers, punctuation, spacing, and separators.
|
||||
if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary) !== 0) {
|
||||
if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/u', $summary)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -94,7 +95,7 @@ final class Message
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function rewindBody(MessageInterface $message): void
|
||||
public static function rewindBody(MessageInterface $message)
|
||||
{
|
||||
$body = $message->getBody();
|
||||
|
||||
@@ -111,8 +112,10 @@ final class Message
|
||||
* array values, and a "body" key containing the body of the message.
|
||||
*
|
||||
* @param string $message HTTP request or response to parse.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function parseMessage(string $message): array
|
||||
public static function parseMessage($message)
|
||||
{
|
||||
if (!$message) {
|
||||
throw new \InvalidArgumentException('Invalid message');
|
||||
@@ -126,7 +129,7 @@ final class Message
|
||||
throw new \InvalidArgumentException('Invalid message: Missing header delimiter');
|
||||
}
|
||||
|
||||
[$rawHeaders, $body] = $messageParts;
|
||||
list($rawHeaders, $body) = $messageParts;
|
||||
$rawHeaders .= "\r\n"; // Put back the delimiter we split previously
|
||||
$headerParts = preg_split("/\r?\n/", $rawHeaders, 2);
|
||||
|
||||
@@ -134,7 +137,7 @@ final class Message
|
||||
throw new \InvalidArgumentException('Invalid message: Missing status line');
|
||||
}
|
||||
|
||||
[$startLine, $rawHeaders] = $headerParts;
|
||||
list($startLine, $rawHeaders) = $headerParts;
|
||||
|
||||
if (preg_match("/(?:^HTTP\/|^[A-Z]+ \S+ HTTP\/)(\d+(?:\.\d+)?)/i", $startLine, $matches) && $matches[1] === '1.0') {
|
||||
// Header folding is deprecated for HTTP/1.1, but allowed in HTTP/1.0
|
||||
@@ -146,7 +149,7 @@ final class Message
|
||||
|
||||
// If these aren't the same, then one line didn't match and there's an invalid header.
|
||||
if ($count !== substr_count($rawHeaders, "\n")) {
|
||||
// Folding is deprecated, see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4
|
||||
// Folding is deprecated, see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
||||
if (preg_match(Rfc7230::HEADER_FOLD_REGEX, $rawHeaders)) {
|
||||
throw new \InvalidArgumentException('Invalid header syntax: Obsolete line folding');
|
||||
}
|
||||
@@ -172,13 +175,12 @@ final class Message
|
||||
*
|
||||
* @param string $path Path from the start-line
|
||||
* @param array $headers Array of headers (each value an array).
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function parseRequestUri(string $path, array $headers): string
|
||||
public static function parseRequestUri($path, array $headers)
|
||||
{
|
||||
$hostKey = array_filter(array_keys($headers), function ($k) {
|
||||
// Numeric array keys are converted to int by PHP.
|
||||
$k = (string) $k;
|
||||
|
||||
return strtolower($k) === 'host';
|
||||
});
|
||||
|
||||
@@ -190,15 +192,17 @@ final class Message
|
||||
$host = $headers[reset($hostKey)][0];
|
||||
$scheme = substr($host, -4) === ':443' ? 'https' : 'http';
|
||||
|
||||
return $scheme.'://'.$host.'/'.ltrim($path, '/');
|
||||
return $scheme . '://' . $host . '/' . ltrim($path, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a request message string into a request object.
|
||||
*
|
||||
* @param string $message Request message string.
|
||||
*
|
||||
* @return Request
|
||||
*/
|
||||
public static function parseRequest(string $message): RequestInterface
|
||||
public static function parseRequest($message)
|
||||
{
|
||||
$data = self::parseMessage($message);
|
||||
$matches = [];
|
||||
@@ -223,15 +227,17 @@ final class Message
|
||||
* Parses a response message string into a response object.
|
||||
*
|
||||
* @param string $message Response message string.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public static function parseResponse(string $message): ResponseInterface
|
||||
public static function parseResponse($message)
|
||||
{
|
||||
$data = self::parseMessage($message);
|
||||
// According to https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2
|
||||
// the space between status-code and reason-phrase is required. But
|
||||
// browsers accept responses without space and reason as well.
|
||||
// According to https://tools.ietf.org/html/rfc7230#section-3.1.2 the space
|
||||
// between status-code and reason-phrase is required. But browsers accept
|
||||
// responses without space and reason as well.
|
||||
if (!preg_match('/^HTTP\/.* [0-9]{3}( .*|$)/', $data['start-line'])) {
|
||||
throw new \InvalidArgumentException('Invalid response string: '.$data['start-line']);
|
||||
throw new \InvalidArgumentException('Invalid response string: ' . $data['start-line']);
|
||||
}
|
||||
$parts = explode(' ', $data['start-line'], 3);
|
||||
|
||||
@@ -240,7 +246,7 @@ final class Message
|
||||
$data['headers'],
|
||||
$data['body'],
|
||||
explode('/', $parts[0])[1],
|
||||
$parts[2] ?? null
|
||||
isset($parts[2]) ? $parts[2] : null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
74
vendor/guzzlehttp/psr7/src/MessageTrait.php
vendored
74
vendor/guzzlehttp/psr7/src/MessageTrait.php
vendored
@@ -1,10 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
@@ -12,11 +9,11 @@ use Psr\Http\Message\StreamInterface;
|
||||
*/
|
||||
trait MessageTrait
|
||||
{
|
||||
/** @var string[][] Map of all registered headers, as original name => array of values */
|
||||
/** @var array Map of all registered headers, as original name => array of values */
|
||||
private $headers = [];
|
||||
|
||||
/** @var string[] Map of lowercase header name => original name at registration */
|
||||
private $headerNames = [];
|
||||
/** @var array Map of lowercase header name => original name at registration */
|
||||
private $headerNames = [];
|
||||
|
||||
/** @var string */
|
||||
private $protocol = '1.1';
|
||||
@@ -24,12 +21,12 @@ trait MessageTrait
|
||||
/** @var StreamInterface|null */
|
||||
private $stream;
|
||||
|
||||
public function getProtocolVersion(): string
|
||||
public function getProtocolVersion()
|
||||
{
|
||||
return $this->protocol;
|
||||
}
|
||||
|
||||
public function withProtocolVersion($version): MessageInterface
|
||||
public function withProtocolVersion($version)
|
||||
{
|
||||
if ($this->protocol === $version) {
|
||||
return $this;
|
||||
@@ -37,21 +34,20 @@ trait MessageTrait
|
||||
|
||||
$new = clone $this;
|
||||
$new->protocol = $version;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function getHeaders(): array
|
||||
public function getHeaders()
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
public function hasHeader($header): bool
|
||||
public function hasHeader($header)
|
||||
{
|
||||
return isset($this->headerNames[strtolower($header)]);
|
||||
}
|
||||
|
||||
public function getHeader($header): array
|
||||
public function getHeader($header)
|
||||
{
|
||||
$header = strtolower($header);
|
||||
|
||||
@@ -64,12 +60,12 @@ trait MessageTrait
|
||||
return $this->headers[$header];
|
||||
}
|
||||
|
||||
public function getHeaderLine($header): string
|
||||
public function getHeaderLine($header)
|
||||
{
|
||||
return implode(', ', $this->getHeader($header));
|
||||
}
|
||||
|
||||
public function withHeader($header, $value): MessageInterface
|
||||
public function withHeader($header, $value)
|
||||
{
|
||||
$this->assertHeader($header);
|
||||
$value = $this->normalizeHeaderValue($value);
|
||||
@@ -85,7 +81,7 @@ trait MessageTrait
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function withAddedHeader($header, $value): MessageInterface
|
||||
public function withAddedHeader($header, $value)
|
||||
{
|
||||
$this->assertHeader($header);
|
||||
$value = $this->normalizeHeaderValue($value);
|
||||
@@ -103,7 +99,7 @@ trait MessageTrait
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function withoutHeader($header): MessageInterface
|
||||
public function withoutHeader($header)
|
||||
{
|
||||
$normalized = strtolower($header);
|
||||
|
||||
@@ -119,7 +115,7 @@ trait MessageTrait
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function getBody(): StreamInterface
|
||||
public function getBody()
|
||||
{
|
||||
if (!$this->stream) {
|
||||
$this->stream = Utils::streamFor('');
|
||||
@@ -128,7 +124,7 @@ trait MessageTrait
|
||||
return $this->stream;
|
||||
}
|
||||
|
||||
public function withBody(StreamInterface $body): MessageInterface
|
||||
public function withBody(StreamInterface $body)
|
||||
{
|
||||
if ($body === $this->stream) {
|
||||
return $this;
|
||||
@@ -136,20 +132,18 @@ trait MessageTrait
|
||||
|
||||
$new = clone $this;
|
||||
$new->stream = $body;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param (string|string[])[] $headers
|
||||
*/
|
||||
private function setHeaders(array $headers): void
|
||||
private function setHeaders(array $headers)
|
||||
{
|
||||
$this->headerNames = $this->headers = [];
|
||||
foreach ($headers as $header => $value) {
|
||||
// Numeric array keys are converted to int by PHP.
|
||||
$header = (string) $header;
|
||||
|
||||
if (is_int($header)) {
|
||||
// Numeric array keys are converted to int by PHP but having a header name '123' is not forbidden by the spec
|
||||
// and also allowed in withHeader(). So we need to cast it to string again for the following assertion to pass.
|
||||
$header = (string) $header;
|
||||
}
|
||||
$this->assertHeader($header);
|
||||
$value = $this->normalizeHeaderValue($value);
|
||||
$normalized = strtolower($header);
|
||||
@@ -168,7 +162,7 @@ trait MessageTrait
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
private function normalizeHeaderValue($value): array
|
||||
private function normalizeHeaderValue($value)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
return $this->trimAndValidateHeaderValues([$value]);
|
||||
@@ -193,9 +187,9 @@ trait MessageTrait
|
||||
*
|
||||
* @return string[] Trimmed header values
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.4
|
||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2.4
|
||||
*/
|
||||
private function trimAndValidateHeaderValues(array $values): array
|
||||
private function trimAndValidateHeaderValues(array $values)
|
||||
{
|
||||
return array_map(function ($value) {
|
||||
if (!is_scalar($value) && null !== $value) {
|
||||
@@ -213,11 +207,13 @@ trait MessageTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
|
||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2
|
||||
*
|
||||
* @param mixed $header
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function assertHeader($header): void
|
||||
private function assertHeader($header)
|
||||
{
|
||||
if (!is_string($header)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
@@ -226,7 +222,11 @@ trait MessageTrait
|
||||
));
|
||||
}
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) {
|
||||
if ($header === '') {
|
||||
throw new \InvalidArgumentException('Header name can not be empty.');
|
||||
}
|
||||
|
||||
if (! preg_match('/^[a-zA-Z0-9\'`#$%&*+.^_|~!-]+$/D', $header)) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('"%s" is not valid header name.', $header)
|
||||
);
|
||||
@@ -234,7 +234,11 @@ trait MessageTrait
|
||||
}
|
||||
|
||||
/**
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc7230#section-3.2
|
||||
* @param string $value
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc7230#section-3.2
|
||||
*
|
||||
* field-value = *( field-content / obs-fold )
|
||||
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
|
||||
@@ -243,7 +247,7 @@ trait MessageTrait
|
||||
* obs-text = %x80-FF
|
||||
* obs-fold = CRLF 1*( SP / HTAB )
|
||||
*/
|
||||
private function assertValue(string $value): void
|
||||
private function assertValue($value)
|
||||
{
|
||||
// The regular expression intentionally does not support the obs-fold production, because as
|
||||
// per RFC 7230#3.2.4:
|
||||
@@ -256,7 +260,7 @@ trait MessageTrait
|
||||
// Clients must not send a request with line folding and a server sending folded headers is
|
||||
// likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
|
||||
// folding is not likely to break any legitimate use case.
|
||||
if (!preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) {
|
||||
if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/D', $value)) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('"%s" is not valid header value.', $value)
|
||||
);
|
||||
|
||||
1357
vendor/guzzlehttp/psr7/src/MimeType.php
vendored
1357
vendor/guzzlehttp/psr7/src/MimeType.php
vendored
File diff suppressed because it is too large
Load Diff
67
vendor/guzzlehttp/psr7/src/MultipartStream.php
vendored
67
vendor/guzzlehttp/psr7/src/MultipartStream.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -9,17 +7,15 @@ use Psr\Http\Message\StreamInterface;
|
||||
/**
|
||||
* Stream that when read returns bytes for a streaming multipart or
|
||||
* multipart/form-data stream.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class MultipartStream implements StreamInterface
|
||||
class MultipartStream implements StreamInterface
|
||||
{
|
||||
use StreamDecoratorTrait;
|
||||
|
||||
/** @var string */
|
||||
private $boundary;
|
||||
|
||||
/** @var StreamInterface */
|
||||
private $stream;
|
||||
|
||||
/**
|
||||
* @param array $elements Array of associative arrays, each containing a
|
||||
* required "name" key mapping to the form field,
|
||||
@@ -32,48 +28,48 @@ final class MultipartStream implements StreamInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct(array $elements = [], string $boundary = null)
|
||||
public function __construct(array $elements = [], $boundary = null)
|
||||
{
|
||||
$this->boundary = $boundary ?: bin2hex(random_bytes(20));
|
||||
$this->boundary = $boundary ?: sha1(uniqid('', true));
|
||||
$this->stream = $this->createStream($elements);
|
||||
}
|
||||
|
||||
public function getBoundary(): string
|
||||
/**
|
||||
* Get the boundary
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getBoundary()
|
||||
{
|
||||
return $this->boundary;
|
||||
}
|
||||
|
||||
public function isWritable(): bool
|
||||
public function isWritable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the headers needed before transferring the content of a POST file
|
||||
*
|
||||
* @param string[] $headers
|
||||
*/
|
||||
private function getHeaders(array $headers): string
|
||||
private function getHeaders(array $headers)
|
||||
{
|
||||
$str = '';
|
||||
foreach ($headers as $key => $value) {
|
||||
$str .= "{$key}: {$value}\r\n";
|
||||
}
|
||||
|
||||
return "--{$this->boundary}\r\n".trim($str)."\r\n\r\n";
|
||||
return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the aggregate stream that will be used to upload the POST data
|
||||
*/
|
||||
protected function createStream(array $elements = []): StreamInterface
|
||||
protected function createStream(array $elements)
|
||||
{
|
||||
$stream = new AppendStream();
|
||||
|
||||
foreach ($elements as $element) {
|
||||
if (!is_array($element)) {
|
||||
throw new \UnexpectedValueException('An array is expected');
|
||||
}
|
||||
$this->addElement($stream, $element);
|
||||
}
|
||||
|
||||
@@ -83,7 +79,7 @@ final class MultipartStream implements StreamInterface
|
||||
return $stream;
|
||||
}
|
||||
|
||||
private function addElement(AppendStream $stream, array $element): void
|
||||
private function addElement(AppendStream $stream, array $element)
|
||||
{
|
||||
foreach (['contents', 'name'] as $key) {
|
||||
if (!array_key_exists($key, $element)) {
|
||||
@@ -95,16 +91,16 @@ final class MultipartStream implements StreamInterface
|
||||
|
||||
if (empty($element['filename'])) {
|
||||
$uri = $element['contents']->getMetadata('uri');
|
||||
if ($uri && \is_string($uri) && \substr($uri, 0, 6) !== 'php://' && \substr($uri, 0, 7) !== 'data://') {
|
||||
if (substr($uri, 0, 6) !== 'php://') {
|
||||
$element['filename'] = $uri;
|
||||
}
|
||||
}
|
||||
|
||||
[$body, $headers] = $this->createElement(
|
||||
list($body, $headers) = $this->createElement(
|
||||
$element['name'],
|
||||
$element['contents'],
|
||||
$element['filename'] ?? null,
|
||||
$element['headers'] ?? []
|
||||
isset($element['filename']) ? $element['filename'] : null,
|
||||
isset($element['headers']) ? $element['headers'] : []
|
||||
);
|
||||
|
||||
$stream->addStream(Utils::streamFor($this->getHeaders($headers)));
|
||||
@@ -113,14 +109,12 @@ final class MultipartStream implements StreamInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $headers
|
||||
*
|
||||
* @return array{0: StreamInterface, 1: string[]}
|
||||
* @return array
|
||||
*/
|
||||
private function createElement(string $name, StreamInterface $stream, ?string $filename, array $headers): array
|
||||
private function createElement($name, StreamInterface $stream, $filename, array $headers)
|
||||
{
|
||||
// Set a default content-disposition header if one was no provided
|
||||
$disposition = self::getHeader($headers, 'content-disposition');
|
||||
$disposition = $this->getHeader($headers, 'content-disposition');
|
||||
if (!$disposition) {
|
||||
$headers['Content-Disposition'] = ($filename === '0' || $filename)
|
||||
? sprintf(
|
||||
@@ -132,7 +126,7 @@ final class MultipartStream implements StreamInterface
|
||||
}
|
||||
|
||||
// Set a default content-length header if one was no provided
|
||||
$length = self::getHeader($headers, 'content-length');
|
||||
$length = $this->getHeader($headers, 'content-length');
|
||||
if (!$length) {
|
||||
if ($length = $stream->getSize()) {
|
||||
$headers['Content-Length'] = (string) $length;
|
||||
@@ -140,22 +134,21 @@ final class MultipartStream implements StreamInterface
|
||||
}
|
||||
|
||||
// Set a default Content-Type if one was not supplied
|
||||
$type = self::getHeader($headers, 'content-type');
|
||||
$type = $this->getHeader($headers, 'content-type');
|
||||
if (!$type && ($filename === '0' || $filename)) {
|
||||
$headers['Content-Type'] = MimeType::fromFilename($filename) ?? 'application/octet-stream';
|
||||
if ($type = MimeType::fromFilename($filename)) {
|
||||
$headers['Content-Type'] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
return [$stream, $headers];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $headers
|
||||
*/
|
||||
private static function getHeader(array $headers, string $key): ?string
|
||||
private function getHeader(array $headers, $key)
|
||||
{
|
||||
$lowercaseHeader = strtolower($key);
|
||||
foreach ($headers as $k => $v) {
|
||||
if (strtolower((string) $k) === $lowercaseHeader) {
|
||||
if (strtolower($k) === $lowercaseHeader) {
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
|
||||
13
vendor/guzzlehttp/psr7/src/NoSeekStream.php
vendored
13
vendor/guzzlehttp/psr7/src/NoSeekStream.php
vendored
@@ -1,27 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* Stream decorator that prevents a stream from being seeked.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class NoSeekStream implements StreamInterface
|
||||
class NoSeekStream implements StreamInterface
|
||||
{
|
||||
use StreamDecoratorTrait;
|
||||
|
||||
/** @var StreamInterface */
|
||||
private $stream;
|
||||
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
throw new \RuntimeException('Cannot seek a NoSeekStream');
|
||||
}
|
||||
|
||||
public function isSeekable(): bool
|
||||
public function isSeekable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
79
vendor/guzzlehttp/psr7/src/PumpStream.php
vendored
79
vendor/guzzlehttp/psr7/src/PumpStream.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -15,13 +13,15 @@ use Psr\Http\Message\StreamInterface;
|
||||
* returned by the provided callable is buffered internally until drained using
|
||||
* the read() function of the PumpStream. The provided callable MUST return
|
||||
* false when there is no more data to read.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
final class PumpStream implements StreamInterface
|
||||
class PumpStream implements StreamInterface
|
||||
{
|
||||
/** @var callable(int): (string|false|null)|null */
|
||||
/** @var callable */
|
||||
private $source;
|
||||
|
||||
/** @var int|null */
|
||||
/** @var int */
|
||||
private $size;
|
||||
|
||||
/** @var int */
|
||||
@@ -34,96 +34,91 @@ final class PumpStream implements StreamInterface
|
||||
private $buffer;
|
||||
|
||||
/**
|
||||
* @param callable(int): (string|false|null) $source Source of the stream data. The callable MAY
|
||||
* accept an integer argument used to control the
|
||||
* amount of data to return. The callable MUST
|
||||
* return a string when called, or false|null on error
|
||||
* or EOF.
|
||||
* @param array{size?: int, metadata?: array} $options Stream options:
|
||||
* - metadata: Hash of metadata to use with stream.
|
||||
* - size: Size of the stream, if known.
|
||||
* @param callable $source Source of the stream data. The callable MAY
|
||||
* accept an integer argument used to control the
|
||||
* amount of data to return. The callable MUST
|
||||
* return a string when called, or false on error
|
||||
* or EOF.
|
||||
* @param array $options Stream options:
|
||||
* - metadata: Hash of metadata to use with stream.
|
||||
* - size: Size of the stream, if known.
|
||||
*/
|
||||
public function __construct(callable $source, array $options = [])
|
||||
{
|
||||
$this->source = $source;
|
||||
$this->size = $options['size'] ?? null;
|
||||
$this->metadata = $options['metadata'] ?? [];
|
||||
$this->size = isset($options['size']) ? $options['size'] : null;
|
||||
$this->metadata = isset($options['metadata']) ? $options['metadata'] : [];
|
||||
$this->buffer = new BufferStream();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function __toString()
|
||||
{
|
||||
try {
|
||||
return Utils::copyToString($this);
|
||||
} catch (\Throwable $e) {
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw $e;
|
||||
}
|
||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public function close(): void
|
||||
public function close()
|
||||
{
|
||||
$this->detach();
|
||||
}
|
||||
|
||||
public function detach()
|
||||
{
|
||||
$this->tellPos = 0;
|
||||
$this->tellPos = false;
|
||||
$this->source = null;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getSize(): ?int
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function tell(): int
|
||||
public function tell()
|
||||
{
|
||||
return $this->tellPos;
|
||||
}
|
||||
|
||||
public function eof(): bool
|
||||
public function eof()
|
||||
{
|
||||
return $this->source === null;
|
||||
return !$this->source;
|
||||
}
|
||||
|
||||
public function isSeekable(): bool
|
||||
public function isSeekable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
public function rewind()
|
||||
{
|
||||
$this->seek(0);
|
||||
}
|
||||
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
throw new \RuntimeException('Cannot seek a PumpStream');
|
||||
}
|
||||
|
||||
public function isWritable(): bool
|
||||
public function isWritable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function write($string): int
|
||||
public function write($string)
|
||||
{
|
||||
throw new \RuntimeException('Cannot write to a PumpStream');
|
||||
}
|
||||
|
||||
public function isReadable(): bool
|
||||
public function isReadable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function read($length): string
|
||||
public function read($length)
|
||||
{
|
||||
$data = $this->buffer->read($length);
|
||||
$readLen = strlen($data);
|
||||
@@ -139,7 +134,7 @@ final class PumpStream implements StreamInterface
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function getContents(): string
|
||||
public function getContents()
|
||||
{
|
||||
$result = '';
|
||||
while (!$this->eof()) {
|
||||
@@ -149,26 +144,22 @@ final class PumpStream implements StreamInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadata($key = null)
|
||||
{
|
||||
if (!$key) {
|
||||
return $this->metadata;
|
||||
}
|
||||
|
||||
return $this->metadata[$key] ?? null;
|
||||
return isset($this->metadata[$key]) ? $this->metadata[$key] : null;
|
||||
}
|
||||
|
||||
private function pump(int $length): void
|
||||
private function pump($length)
|
||||
{
|
||||
if ($this->source !== null) {
|
||||
if ($this->source) {
|
||||
do {
|
||||
$data = ($this->source)($length);
|
||||
$data = call_user_func($this->source, $length);
|
||||
if ($data === false || $data === null) {
|
||||
$this->source = null;
|
||||
|
||||
return;
|
||||
}
|
||||
$this->buffer->write($data);
|
||||
|
||||
24
vendor/guzzlehttp/psr7/src/Query.php
vendored
24
vendor/guzzlehttp/psr7/src/Query.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
final class Query
|
||||
@@ -16,8 +14,10 @@ final class Query
|
||||
*
|
||||
* @param string $str Query string to parse
|
||||
* @param int|bool $urlEncoding How the query string is encoded
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function parse(string $str, $urlEncoding = true): array
|
||||
public static function parse($str, $urlEncoding = true)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
@@ -27,7 +27,7 @@ final class Query
|
||||
|
||||
if ($urlEncoding === true) {
|
||||
$decoder = function ($value) {
|
||||
return rawurldecode(str_replace('+', ' ', (string) $value));
|
||||
return rawurldecode(str_replace('+', ' ', $value));
|
||||
};
|
||||
} elseif ($urlEncoding === PHP_QUERY_RFC3986) {
|
||||
$decoder = 'rawurldecode';
|
||||
@@ -43,7 +43,7 @@ final class Query
|
||||
$parts = explode('=', $kvp, 2);
|
||||
$key = $decoder($parts[0]);
|
||||
$value = isset($parts[1]) ? $decoder($parts[1]) : null;
|
||||
if (!array_key_exists($key, $result)) {
|
||||
if (!isset($result[$key])) {
|
||||
$result[$key] = $value;
|
||||
} else {
|
||||
if (!is_array($result[$key])) {
|
||||
@@ -67,15 +67,17 @@ final class Query
|
||||
* @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
|
||||
* to encode using RFC3986, or PHP_QUERY_RFC1738
|
||||
* to encode using RFC1738.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function build(array $params, $encoding = PHP_QUERY_RFC3986): string
|
||||
public static function build(array $params, $encoding = PHP_QUERY_RFC3986)
|
||||
{
|
||||
if (!$params) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($encoding === false) {
|
||||
$encoder = function (string $str): string {
|
||||
$encoder = function ($str) {
|
||||
return $str;
|
||||
};
|
||||
} elseif ($encoding === PHP_QUERY_RFC3986) {
|
||||
@@ -88,20 +90,18 @@ final class Query
|
||||
|
||||
$qs = '';
|
||||
foreach ($params as $k => $v) {
|
||||
$k = $encoder((string) $k);
|
||||
$k = $encoder($k);
|
||||
if (!is_array($v)) {
|
||||
$qs .= $k;
|
||||
$v = is_bool($v) ? (int) $v : $v;
|
||||
if ($v !== null) {
|
||||
$qs .= '='.$encoder((string) $v);
|
||||
$qs .= '=' . $encoder($v);
|
||||
}
|
||||
$qs .= '&';
|
||||
} else {
|
||||
foreach ($v as $vv) {
|
||||
$qs .= $k;
|
||||
$vv = is_bool($vv) ? (int) $vv : $vv;
|
||||
if ($vv !== null) {
|
||||
$qs .= '='.$encoder((string) $vv);
|
||||
$qs .= '=' . $encoder($vv);
|
||||
}
|
||||
$qs .= '&';
|
||||
}
|
||||
|
||||
39
vendor/guzzlehttp/psr7/src/Request.php
vendored
39
vendor/guzzlehttp/psr7/src/Request.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use InvalidArgumentException;
|
||||
@@ -28,16 +26,16 @@ class Request implements RequestInterface
|
||||
/**
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI
|
||||
* @param (string|string[])[] $headers Request headers
|
||||
* @param array $headers Request headers
|
||||
* @param string|resource|StreamInterface|null $body Request body
|
||||
* @param string $version Protocol version
|
||||
*/
|
||||
public function __construct(
|
||||
string $method,
|
||||
$method,
|
||||
$uri,
|
||||
array $headers = [],
|
||||
$body = null,
|
||||
string $version = '1.1'
|
||||
$version = '1.1'
|
||||
) {
|
||||
$this->assertMethod($method);
|
||||
if (!($uri instanceof UriInterface)) {
|
||||
@@ -58,24 +56,24 @@ class Request implements RequestInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function getRequestTarget(): string
|
||||
public function getRequestTarget()
|
||||
{
|
||||
if ($this->requestTarget !== null) {
|
||||
return $this->requestTarget;
|
||||
}
|
||||
|
||||
$target = $this->uri->getPath();
|
||||
if ($target === '') {
|
||||
if ($target == '') {
|
||||
$target = '/';
|
||||
}
|
||||
if ($this->uri->getQuery() != '') {
|
||||
$target .= '?'.$this->uri->getQuery();
|
||||
$target .= '?' . $this->uri->getQuery();
|
||||
}
|
||||
|
||||
return $target;
|
||||
}
|
||||
|
||||
public function withRequestTarget($requestTarget): RequestInterface
|
||||
public function withRequestTarget($requestTarget)
|
||||
{
|
||||
if (preg_match('#\s#', $requestTarget)) {
|
||||
throw new InvalidArgumentException(
|
||||
@@ -85,30 +83,28 @@ class Request implements RequestInterface
|
||||
|
||||
$new = clone $this;
|
||||
$new->requestTarget = $requestTarget;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function getMethod(): string
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
public function withMethod($method): RequestInterface
|
||||
public function withMethod($method)
|
||||
{
|
||||
$this->assertMethod($method);
|
||||
$new = clone $this;
|
||||
$new->method = strtoupper($method);
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function getUri(): UriInterface
|
||||
public function getUri()
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
|
||||
public function withUri(UriInterface $uri, $preserveHost = false)
|
||||
{
|
||||
if ($uri === $this->uri) {
|
||||
return $this;
|
||||
@@ -124,7 +120,7 @@ class Request implements RequestInterface
|
||||
return $new;
|
||||
}
|
||||
|
||||
private function updateHostFromUri(): void
|
||||
private function updateHostFromUri()
|
||||
{
|
||||
$host = $this->uri->getHost();
|
||||
|
||||
@@ -133,7 +129,7 @@ class Request implements RequestInterface
|
||||
}
|
||||
|
||||
if (($port = $this->uri->getPort()) !== null) {
|
||||
$host .= ':'.$port;
|
||||
$host .= ':' . $port;
|
||||
}
|
||||
|
||||
if (isset($this->headerNames['host'])) {
|
||||
@@ -143,17 +139,14 @@ class Request implements RequestInterface
|
||||
$this->headerNames['host'] = 'Host';
|
||||
}
|
||||
// Ensure Host is the first header.
|
||||
// See: https://datatracker.ietf.org/doc/html/rfc7230#section-5.4
|
||||
// See: http://tools.ietf.org/html/rfc7230#section-5.4
|
||||
$this->headers = [$header => [$host]] + $this->headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $method
|
||||
*/
|
||||
private function assertMethod($method): void
|
||||
private function assertMethod($method)
|
||||
{
|
||||
if (!is_string($method) || $method === '') {
|
||||
throw new InvalidArgumentException('Method must be a non-empty string.');
|
||||
throw new \InvalidArgumentException('Method must be a non-empty string.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
44
vendor/guzzlehttp/psr7/src/Response.php
vendored
44
vendor/guzzlehttp/psr7/src/Response.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
@@ -14,8 +12,8 @@ class Response implements ResponseInterface
|
||||
{
|
||||
use MessageTrait;
|
||||
|
||||
/** Map of standard HTTP status code/reason phrases */
|
||||
private const PHRASES = [
|
||||
/** @var array Map of standard HTTP status code/reason phrases */
|
||||
private static $phrases = [
|
||||
100 => 'Continue',
|
||||
101 => 'Switching Protocols',
|
||||
102 => 'Processing',
|
||||
@@ -36,7 +34,6 @@ class Response implements ResponseInterface
|
||||
305 => 'Use Proxy',
|
||||
306 => 'Switch Proxy',
|
||||
307 => 'Temporary Redirect',
|
||||
308 => 'Permanent Redirect',
|
||||
400 => 'Bad Request',
|
||||
401 => 'Unauthorized',
|
||||
402 => 'Payment Required',
|
||||
@@ -74,30 +71,31 @@ class Response implements ResponseInterface
|
||||
506 => 'Variant Also Negotiates',
|
||||
507 => 'Insufficient Storage',
|
||||
508 => 'Loop Detected',
|
||||
510 => 'Not Extended',
|
||||
511 => 'Network Authentication Required',
|
||||
];
|
||||
|
||||
/** @var string */
|
||||
private $reasonPhrase;
|
||||
private $reasonPhrase = '';
|
||||
|
||||
/** @var int */
|
||||
private $statusCode;
|
||||
private $statusCode = 200;
|
||||
|
||||
/**
|
||||
* @param int $status Status code
|
||||
* @param (string|string[])[] $headers Response headers
|
||||
* @param array $headers Response headers
|
||||
* @param string|resource|StreamInterface|null $body Response body
|
||||
* @param string $version Protocol version
|
||||
* @param string|null $reason Reason phrase (when empty a default will be used based on the status code)
|
||||
*/
|
||||
public function __construct(
|
||||
int $status = 200,
|
||||
$status = 200,
|
||||
array $headers = [],
|
||||
$body = null,
|
||||
string $version = '1.1',
|
||||
string $reason = null
|
||||
$version = '1.1',
|
||||
$reason = null
|
||||
) {
|
||||
$this->assertStatusCodeIsInteger($status);
|
||||
$status = (int) $status;
|
||||
$this->assertStatusCodeRange($status);
|
||||
|
||||
$this->statusCode = $status;
|
||||
@@ -107,8 +105,8 @@ class Response implements ResponseInterface
|
||||
}
|
||||
|
||||
$this->setHeaders($headers);
|
||||
if ($reason == '' && isset(self::PHRASES[$this->statusCode])) {
|
||||
$this->reasonPhrase = self::PHRASES[$this->statusCode];
|
||||
if ($reason == '' && isset(self::$phrases[$this->statusCode])) {
|
||||
$this->reasonPhrase = self::$phrases[$this->statusCode];
|
||||
} else {
|
||||
$this->reasonPhrase = (string) $reason;
|
||||
}
|
||||
@@ -116,17 +114,17 @@ class Response implements ResponseInterface
|
||||
$this->protocol = $version;
|
||||
}
|
||||
|
||||
public function getStatusCode(): int
|
||||
public function getStatusCode()
|
||||
{
|
||||
return $this->statusCode;
|
||||
}
|
||||
|
||||
public function getReasonPhrase(): string
|
||||
public function getReasonPhrase()
|
||||
{
|
||||
return $this->reasonPhrase;
|
||||
}
|
||||
|
||||
public function withStatus($code, $reasonPhrase = ''): ResponseInterface
|
||||
public function withStatus($code, $reasonPhrase = '')
|
||||
{
|
||||
$this->assertStatusCodeIsInteger($code);
|
||||
$code = (int) $code;
|
||||
@@ -134,25 +132,21 @@ class Response implements ResponseInterface
|
||||
|
||||
$new = clone $this;
|
||||
$new->statusCode = $code;
|
||||
if ($reasonPhrase == '' && isset(self::PHRASES[$new->statusCode])) {
|
||||
$reasonPhrase = self::PHRASES[$new->statusCode];
|
||||
if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) {
|
||||
$reasonPhrase = self::$phrases[$new->statusCode];
|
||||
}
|
||||
$new->reasonPhrase = (string) $reasonPhrase;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $statusCode
|
||||
*/
|
||||
private function assertStatusCodeIsInteger($statusCode): void
|
||||
private function assertStatusCodeIsInteger($statusCode)
|
||||
{
|
||||
if (filter_var($statusCode, FILTER_VALIDATE_INT) === false) {
|
||||
throw new \InvalidArgumentException('Status code must be an integer value.');
|
||||
}
|
||||
}
|
||||
|
||||
private function assertStatusCodeRange(int $statusCode): void
|
||||
private function assertStatusCodeRange($statusCode)
|
||||
{
|
||||
if ($statusCode < 100 || $statusCode >= 600) {
|
||||
throw new \InvalidArgumentException('Status code must be an integer value between 1xx and 5xx.');
|
||||
|
||||
14
vendor/guzzlehttp/psr7/src/Rfc7230.php
vendored
14
vendor/guzzlehttp/psr7/src/Rfc7230.php
vendored
@@ -1,23 +1,19 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
final class Rfc7230
|
||||
{
|
||||
/**
|
||||
* Header related regular expressions (based on amphp/http package)
|
||||
* Header related regular expressions (copied from amphp/http package)
|
||||
* (Note: once we require PHP 7.x we could just depend on the upstream package)
|
||||
*
|
||||
* Note: header delimiter (\r\n) is modified to \r?\n to accept line feed only delimiters for BC reasons.
|
||||
*
|
||||
* @see https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
|
||||
* @link https://github.com/amphp/http/blob/v1.0.1/src/Rfc7230.php#L12-L15
|
||||
*
|
||||
* @license https://github.com/amphp/http/blob/v1.0.1/LICENSE
|
||||
*/
|
||||
public const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m";
|
||||
public const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
|
||||
const HEADER_REGEX = "(^([^()<>@,;:\\\"/[\]?={}\x01-\x20\x7F]++):[ \t]*+((?:[ \t]*+[\x21-\x7E\x80-\xFF]++)*+)[ \t]*+\r?\n)m";
|
||||
const HEADER_FOLD_REGEX = "(\r?\n[ \t]++)";
|
||||
}
|
||||
|
||||
107
vendor/guzzlehttp/psr7/src/ServerRequest.php
vendored
107
vendor/guzzlehttp/psr7/src/ServerRequest.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use InvalidArgumentException;
|
||||
@@ -59,17 +57,17 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
/**
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI
|
||||
* @param (string|string[])[] $headers Request headers
|
||||
* @param array $headers Request headers
|
||||
* @param string|resource|StreamInterface|null $body Request body
|
||||
* @param string $version Protocol version
|
||||
* @param array $serverParams Typically the $_SERVER superglobal
|
||||
*/
|
||||
public function __construct(
|
||||
string $method,
|
||||
$method,
|
||||
$uri,
|
||||
array $headers = [],
|
||||
$body = null,
|
||||
string $version = '1.1',
|
||||
$version = '1.1',
|
||||
array $serverParams = []
|
||||
) {
|
||||
$this->serverParams = $serverParams;
|
||||
@@ -80,11 +78,13 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
/**
|
||||
* Return an UploadedFile instance array.
|
||||
*
|
||||
* @param array $files An array which respect $_FILES structure
|
||||
* @param array $files A array which respect $_FILES structure
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws InvalidArgumentException for unrecognized values
|
||||
*/
|
||||
public static function normalizeFiles(array $files): array
|
||||
public static function normalizeFiles(array $files)
|
||||
{
|
||||
$normalized = [];
|
||||
|
||||
@@ -112,7 +112,7 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
*
|
||||
* @param array $value $_FILES struct
|
||||
*
|
||||
* @return UploadedFileInterface|UploadedFileInterface[]
|
||||
* @return array|UploadedFileInterface
|
||||
*/
|
||||
private static function createUploadedFileFromSpec(array $value)
|
||||
{
|
||||
@@ -135,19 +135,21 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
* Loops through all nested files and returns a normalized array of
|
||||
* UploadedFileInterface instances.
|
||||
*
|
||||
* @param array $files
|
||||
*
|
||||
* @return UploadedFileInterface[]
|
||||
*/
|
||||
private static function normalizeNestedFileSpec(array $files = []): array
|
||||
private static function normalizeNestedFileSpec(array $files = [])
|
||||
{
|
||||
$normalizedFiles = [];
|
||||
|
||||
foreach (array_keys($files['tmp_name']) as $key) {
|
||||
$spec = [
|
||||
'tmp_name' => $files['tmp_name'][$key],
|
||||
'size' => $files['size'][$key] ?? null,
|
||||
'error' => $files['error'][$key] ?? null,
|
||||
'name' => $files['name'][$key] ?? null,
|
||||
'type' => $files['type'][$key] ?? null,
|
||||
'size' => $files['size'][$key],
|
||||
'error' => $files['error'][$key],
|
||||
'name' => $files['name'][$key],
|
||||
'type' => $files['type'][$key],
|
||||
];
|
||||
$normalizedFiles[$key] = self::createUploadedFileFromSpec($spec);
|
||||
}
|
||||
@@ -162,10 +164,12 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
* $_COOKIE
|
||||
* $_FILES
|
||||
* $_SERVER
|
||||
*
|
||||
* @return ServerRequestInterface
|
||||
*/
|
||||
public static function fromGlobals(): ServerRequestInterface
|
||||
public static function fromGlobals()
|
||||
{
|
||||
$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
|
||||
$method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
|
||||
$headers = getallheaders();
|
||||
$uri = self::getUriFromGlobals();
|
||||
$body = new CachingStream(new LazyOpenStream('php://input', 'r+'));
|
||||
@@ -180,24 +184,26 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
->withUploadedFiles(self::normalizeFiles($_FILES));
|
||||
}
|
||||
|
||||
private static function extractHostAndPortFromAuthority(string $authority): array
|
||||
private static function extractHostAndPortFromAuthority($authority)
|
||||
{
|
||||
$uri = 'http://'.$authority;
|
||||
$uri = 'http://' . $authority;
|
||||
$parts = parse_url($uri);
|
||||
if (false === $parts) {
|
||||
return [null, null];
|
||||
}
|
||||
|
||||
$host = $parts['host'] ?? null;
|
||||
$port = $parts['port'] ?? null;
|
||||
$host = isset($parts['host']) ? $parts['host'] : null;
|
||||
$port = isset($parts['port']) ? $parts['port'] : null;
|
||||
|
||||
return [$host, $port];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Uri populated with values from $_SERVER.
|
||||
*
|
||||
* @return UriInterface
|
||||
*/
|
||||
public static function getUriFromGlobals(): UriInterface
|
||||
public static function getUriFromGlobals()
|
||||
{
|
||||
$uri = new Uri('');
|
||||
|
||||
@@ -205,7 +211,7 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
|
||||
$hasPort = false;
|
||||
if (isset($_SERVER['HTTP_HOST'])) {
|
||||
[$host, $port] = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
|
||||
list($host, $port) = self::extractHostAndPortFromAuthority($_SERVER['HTTP_HOST']);
|
||||
if ($host !== null) {
|
||||
$uri = $uri->withHost($host);
|
||||
}
|
||||
@@ -241,17 +247,26 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public function getServerParams(): array
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getServerParams()
|
||||
{
|
||||
return $this->serverParams;
|
||||
}
|
||||
|
||||
public function getUploadedFiles(): array
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getUploadedFiles()
|
||||
{
|
||||
return $this->uploadedFiles;
|
||||
}
|
||||
|
||||
public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function withUploadedFiles(array $uploadedFiles)
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->uploadedFiles = $uploadedFiles;
|
||||
@@ -259,12 +274,18 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function getCookieParams(): array
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCookieParams()
|
||||
{
|
||||
return $this->cookieParams;
|
||||
}
|
||||
|
||||
public function withCookieParams(array $cookies): ServerRequestInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function withCookieParams(array $cookies)
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->cookieParams = $cookies;
|
||||
@@ -272,12 +293,18 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function getQueryParams(): array
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQueryParams()
|
||||
{
|
||||
return $this->queryParams;
|
||||
}
|
||||
|
||||
public function withQueryParams(array $query): ServerRequestInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function withQueryParams(array $query)
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->queryParams = $query;
|
||||
@@ -286,14 +313,17 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|object|null
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParsedBody()
|
||||
{
|
||||
return $this->parsedBody;
|
||||
}
|
||||
|
||||
public function withParsedBody($data): ServerRequestInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function withParsedBody($data)
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->parsedBody = $data;
|
||||
@@ -301,13 +331,16 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function getAttributes(): array
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getAttribute($attribute, $default = null)
|
||||
{
|
||||
@@ -318,7 +351,10 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
return $this->attributes[$attribute];
|
||||
}
|
||||
|
||||
public function withAttribute($attribute, $value): ServerRequestInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function withAttribute($attribute, $value)
|
||||
{
|
||||
$new = clone $this;
|
||||
$new->attributes[$attribute] = $value;
|
||||
@@ -326,7 +362,10 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function withoutAttribute($attribute): ServerRequestInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function withoutAttribute($attribute)
|
||||
{
|
||||
if (false === array_key_exists($attribute, $this->attributes)) {
|
||||
return $this;
|
||||
|
||||
97
vendor/guzzlehttp/psr7/src/Stream.php
vendored
97
vendor/guzzlehttp/psr7/src/Stream.php
vendored
@@ -1,36 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
/**
|
||||
* PHP stream implementation.
|
||||
*
|
||||
* @var $stream
|
||||
*/
|
||||
class Stream implements StreamInterface
|
||||
{
|
||||
/**
|
||||
* @see https://www.php.net/manual/en/function.fopen.php
|
||||
* @see https://www.php.net/manual/en/function.gzopen.php
|
||||
* Resource modes.
|
||||
*
|
||||
* @var string
|
||||
*
|
||||
* @see http://php.net/manual/function.fopen.php
|
||||
* @see http://php.net/manual/en/function.gzopen.php
|
||||
*/
|
||||
private const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
|
||||
private const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
|
||||
const READABLE_MODES = '/r|a\+|ab\+|w\+|wb\+|x\+|xb\+|c\+|cb\+/';
|
||||
const WRITABLE_MODES = '/a|w|r\+|rb\+|rw|x|c/';
|
||||
|
||||
/** @var resource */
|
||||
private $stream;
|
||||
/** @var int|null */
|
||||
private $size;
|
||||
/** @var bool */
|
||||
private $seekable;
|
||||
/** @var bool */
|
||||
private $readable;
|
||||
/** @var bool */
|
||||
private $writable;
|
||||
/** @var string|null */
|
||||
private $uri;
|
||||
/** @var mixed[] */
|
||||
private $customMetadata;
|
||||
|
||||
/**
|
||||
@@ -42,12 +39,12 @@ class Stream implements StreamInterface
|
||||
* - metadata: (array) Any additional metadata to return when the metadata
|
||||
* of the stream is accessed.
|
||||
*
|
||||
* @param resource $stream Stream resource to wrap.
|
||||
* @param array{size?: int, metadata?: array} $options Associative array of options.
|
||||
* @param resource $stream Stream resource to wrap.
|
||||
* @param array $options Associative array of options.
|
||||
*
|
||||
* @throws \InvalidArgumentException if the stream is not a stream resource
|
||||
*/
|
||||
public function __construct($stream, array $options = [])
|
||||
public function __construct($stream, $options = [])
|
||||
{
|
||||
if (!is_resource($stream)) {
|
||||
throw new \InvalidArgumentException('Stream must be a resource');
|
||||
@@ -57,12 +54,15 @@ class Stream implements StreamInterface
|
||||
$this->size = $options['size'];
|
||||
}
|
||||
|
||||
$this->customMetadata = $options['metadata'] ?? [];
|
||||
$this->customMetadata = isset($options['metadata'])
|
||||
? $options['metadata']
|
||||
: [];
|
||||
|
||||
$this->stream = $stream;
|
||||
$meta = stream_get_meta_data($this->stream);
|
||||
$this->seekable = $meta['seekable'];
|
||||
$this->readable = (bool) preg_match(self::READABLE_MODES, $meta['mode']);
|
||||
$this->writable = (bool) preg_match(self::WRITABLE_MODES, $meta['mode']);
|
||||
$this->readable = (bool)preg_match(self::READABLE_MODES, $meta['mode']);
|
||||
$this->writable = (bool)preg_match(self::WRITABLE_MODES, $meta['mode']);
|
||||
$this->uri = $this->getMetadata('uri');
|
||||
}
|
||||
|
||||
@@ -74,38 +74,34 @@ class Stream implements StreamInterface
|
||||
$this->close();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function __toString()
|
||||
{
|
||||
try {
|
||||
if ($this->isSeekable()) {
|
||||
$this->seek(0);
|
||||
}
|
||||
|
||||
return $this->getContents();
|
||||
} catch (\Throwable $e) {
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw $e;
|
||||
}
|
||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public function getContents(): string
|
||||
public function getContents()
|
||||
{
|
||||
if (!isset($this->stream)) {
|
||||
throw new \RuntimeException('Stream is detached');
|
||||
}
|
||||
|
||||
if (!$this->readable) {
|
||||
throw new \RuntimeException('Cannot read from non-readable stream');
|
||||
$contents = stream_get_contents($this->stream);
|
||||
|
||||
if ($contents === false) {
|
||||
throw new \RuntimeException('Unable to read stream contents');
|
||||
}
|
||||
|
||||
return Utils::tryGetContents($this->stream);
|
||||
return $contents;
|
||||
}
|
||||
|
||||
public function close(): void
|
||||
public function close()
|
||||
{
|
||||
if (isset($this->stream)) {
|
||||
if (is_resource($this->stream)) {
|
||||
@@ -129,7 +125,7 @@ class Stream implements StreamInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getSize(): ?int
|
||||
public function getSize()
|
||||
{
|
||||
if ($this->size !== null) {
|
||||
return $this->size;
|
||||
@@ -145,31 +141,30 @@ class Stream implements StreamInterface
|
||||
}
|
||||
|
||||
$stats = fstat($this->stream);
|
||||
if (is_array($stats) && isset($stats['size'])) {
|
||||
if (isset($stats['size'])) {
|
||||
$this->size = $stats['size'];
|
||||
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function isReadable(): bool
|
||||
public function isReadable()
|
||||
{
|
||||
return $this->readable;
|
||||
}
|
||||
|
||||
public function isWritable(): bool
|
||||
public function isWritable()
|
||||
{
|
||||
return $this->writable;
|
||||
}
|
||||
|
||||
public function isSeekable(): bool
|
||||
public function isSeekable()
|
||||
{
|
||||
return $this->seekable;
|
||||
}
|
||||
|
||||
public function eof(): bool
|
||||
public function eof()
|
||||
{
|
||||
if (!isset($this->stream)) {
|
||||
throw new \RuntimeException('Stream is detached');
|
||||
@@ -178,7 +173,7 @@ class Stream implements StreamInterface
|
||||
return feof($this->stream);
|
||||
}
|
||||
|
||||
public function tell(): int
|
||||
public function tell()
|
||||
{
|
||||
if (!isset($this->stream)) {
|
||||
throw new \RuntimeException('Stream is detached');
|
||||
@@ -193,12 +188,12 @@ class Stream implements StreamInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
public function rewind()
|
||||
{
|
||||
$this->seek(0);
|
||||
}
|
||||
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
$whence = (int) $whence;
|
||||
|
||||
@@ -210,11 +205,11 @@ class Stream implements StreamInterface
|
||||
}
|
||||
if (fseek($this->stream, $offset, $whence) === -1) {
|
||||
throw new \RuntimeException('Unable to seek to stream position '
|
||||
.$offset.' with whence '.var_export($whence, true));
|
||||
. $offset . ' with whence ' . var_export($whence, true));
|
||||
}
|
||||
}
|
||||
|
||||
public function read($length): string
|
||||
public function read($length)
|
||||
{
|
||||
if (!isset($this->stream)) {
|
||||
throw new \RuntimeException('Stream is detached');
|
||||
@@ -230,12 +225,7 @@ class Stream implements StreamInterface
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
$string = fread($this->stream, $length);
|
||||
} catch (\Exception $e) {
|
||||
throw new \RuntimeException('Unable to read from stream', 0, $e);
|
||||
}
|
||||
|
||||
$string = fread($this->stream, $length);
|
||||
if (false === $string) {
|
||||
throw new \RuntimeException('Unable to read from stream');
|
||||
}
|
||||
@@ -243,7 +233,7 @@ class Stream implements StreamInterface
|
||||
return $string;
|
||||
}
|
||||
|
||||
public function write($string): int
|
||||
public function write($string)
|
||||
{
|
||||
if (!isset($this->stream)) {
|
||||
throw new \RuntimeException('Stream is detached');
|
||||
@@ -263,9 +253,6 @@ class Stream implements StreamInterface
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadata($key = null)
|
||||
{
|
||||
if (!isset($this->stream)) {
|
||||
@@ -278,6 +265,6 @@ class Stream implements StreamInterface
|
||||
|
||||
$meta = stream_get_meta_data($this->stream);
|
||||
|
||||
return $meta[$key] ?? null;
|
||||
return isset($meta[$key]) ? $meta[$key] : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -9,7 +7,7 @@ use Psr\Http\Message\StreamInterface;
|
||||
/**
|
||||
* Stream decorator trait
|
||||
*
|
||||
* @property StreamInterface $stream
|
||||
* @property StreamInterface stream
|
||||
*/
|
||||
trait StreamDecoratorTrait
|
||||
{
|
||||
@@ -25,38 +23,36 @@ trait StreamDecoratorTrait
|
||||
* Magic method used to create a new stream if streams are not added in
|
||||
* the constructor of a decorator (e.g., LazyOpenStream).
|
||||
*
|
||||
* @param string $name Name of the property (allows "stream" only).
|
||||
*
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function __get(string $name)
|
||||
public function __get($name)
|
||||
{
|
||||
if ($name === 'stream') {
|
||||
if ($name == 'stream') {
|
||||
$this->stream = $this->createStream();
|
||||
|
||||
return $this->stream;
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException("$name not found on class");
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function __toString()
|
||||
{
|
||||
try {
|
||||
if ($this->isSeekable()) {
|
||||
$this->seek(0);
|
||||
}
|
||||
|
||||
return $this->getContents();
|
||||
} catch (\Throwable $e) {
|
||||
if (\PHP_VERSION_ID >= 70400) {
|
||||
throw $e;
|
||||
}
|
||||
trigger_error(sprintf('%s::__toString exception: %s', self::class, (string) $e), E_USER_ERROR);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Really, PHP? https://bugs.php.net/bug.php?id=53648
|
||||
trigger_error('StreamDecorator::__toString exception: '
|
||||
. (string) $e, E_USER_ERROR);
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public function getContents(): string
|
||||
public function getContents()
|
||||
{
|
||||
return Utils::copyToString($this);
|
||||
}
|
||||
@@ -64,26 +60,24 @@ trait StreamDecoratorTrait
|
||||
/**
|
||||
* Allow decorators to implement custom methods
|
||||
*
|
||||
* @param string $method Missing method name
|
||||
* @param array $args Method arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call(string $method, array $args)
|
||||
public function __call($method, array $args)
|
||||
{
|
||||
/** @var callable $callable */
|
||||
$callable = [$this->stream, $method];
|
||||
$result = ($callable)(...$args);
|
||||
$result = call_user_func_array([$this->stream, $method], $args);
|
||||
|
||||
// Always return the wrapped object if the result is a return $this
|
||||
return $result === $this->stream ? $this : $result;
|
||||
}
|
||||
|
||||
public function close(): void
|
||||
public function close()
|
||||
{
|
||||
$this->stream->close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadata($key = null)
|
||||
{
|
||||
return $this->stream->getMetadata($key);
|
||||
@@ -94,52 +88,52 @@ trait StreamDecoratorTrait
|
||||
return $this->stream->detach();
|
||||
}
|
||||
|
||||
public function getSize(): ?int
|
||||
public function getSize()
|
||||
{
|
||||
return $this->stream->getSize();
|
||||
}
|
||||
|
||||
public function eof(): bool
|
||||
public function eof()
|
||||
{
|
||||
return $this->stream->eof();
|
||||
}
|
||||
|
||||
public function tell(): int
|
||||
public function tell()
|
||||
{
|
||||
return $this->stream->tell();
|
||||
}
|
||||
|
||||
public function isReadable(): bool
|
||||
public function isReadable()
|
||||
{
|
||||
return $this->stream->isReadable();
|
||||
}
|
||||
|
||||
public function isWritable(): bool
|
||||
public function isWritable()
|
||||
{
|
||||
return $this->stream->isWritable();
|
||||
}
|
||||
|
||||
public function isSeekable(): bool
|
||||
public function isSeekable()
|
||||
{
|
||||
return $this->stream->isSeekable();
|
||||
}
|
||||
|
||||
public function rewind(): void
|
||||
public function rewind()
|
||||
{
|
||||
$this->seek(0);
|
||||
}
|
||||
|
||||
public function seek($offset, $whence = SEEK_SET): void
|
||||
public function seek($offset, $whence = SEEK_SET)
|
||||
{
|
||||
$this->stream->seek($offset, $whence);
|
||||
}
|
||||
|
||||
public function read($length): string
|
||||
public function read($length)
|
||||
{
|
||||
return $this->stream->read($length);
|
||||
}
|
||||
|
||||
public function write($string): int
|
||||
public function write($string)
|
||||
{
|
||||
return $this->stream->write($string);
|
||||
}
|
||||
@@ -147,9 +141,11 @@ trait StreamDecoratorTrait
|
||||
/**
|
||||
* Implement in subclasses to dynamically create streams when requested.
|
||||
*
|
||||
* @return StreamInterface
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
*/
|
||||
protected function createStream(): StreamInterface
|
||||
protected function createStream()
|
||||
{
|
||||
throw new \BadMethodCallException('Not implemented');
|
||||
}
|
||||
|
||||
132
vendor/guzzlehttp/psr7/src/StreamWrapper.php
vendored
132
vendor/guzzlehttp/psr7/src/StreamWrapper.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
@@ -9,9 +7,9 @@ use Psr\Http\Message\StreamInterface;
|
||||
/**
|
||||
* Converts Guzzle streams into PHP stream resources.
|
||||
*
|
||||
* @see https://www.php.net/streamwrapper
|
||||
* @final
|
||||
*/
|
||||
final class StreamWrapper
|
||||
class StreamWrapper
|
||||
{
|
||||
/** @var resource */
|
||||
public $context;
|
||||
@@ -41,35 +39,37 @@ final class StreamWrapper
|
||||
$mode = 'w';
|
||||
} else {
|
||||
throw new \InvalidArgumentException('The stream must be readable, '
|
||||
.'writable, or both.');
|
||||
. 'writable, or both.');
|
||||
}
|
||||
|
||||
return fopen('guzzle://stream', $mode, false, self::createStreamContext($stream));
|
||||
return fopen('guzzle://stream', $mode, null, self::createStreamContext($stream));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a stream context that can be used to open a stream as a php stream resource.
|
||||
*
|
||||
* @param StreamInterface $stream
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public static function createStreamContext(StreamInterface $stream)
|
||||
{
|
||||
return stream_context_create([
|
||||
'guzzle' => ['stream' => $stream],
|
||||
'guzzle' => ['stream' => $stream]
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the stream wrapper if needed
|
||||
*/
|
||||
public static function register(): void
|
||||
public static function register()
|
||||
{
|
||||
if (!in_array('guzzle', stream_get_wrappers())) {
|
||||
stream_wrapper_register('guzzle', __CLASS__);
|
||||
}
|
||||
}
|
||||
|
||||
public function stream_open(string $path, string $mode, int $options, string &$opened_path = null): bool
|
||||
public function stream_open($path, $mode, $options, &$opened_path)
|
||||
{
|
||||
$options = stream_context_get_options($this->context);
|
||||
|
||||
@@ -83,121 +83,83 @@ final class StreamWrapper
|
||||
return true;
|
||||
}
|
||||
|
||||
public function stream_read(int $count): string
|
||||
public function stream_read($count)
|
||||
{
|
||||
return $this->stream->read($count);
|
||||
}
|
||||
|
||||
public function stream_write(string $data): int
|
||||
public function stream_write($data)
|
||||
{
|
||||
return $this->stream->write($data);
|
||||
return (int) $this->stream->write($data);
|
||||
}
|
||||
|
||||
public function stream_tell(): int
|
||||
public function stream_tell()
|
||||
{
|
||||
return $this->stream->tell();
|
||||
}
|
||||
|
||||
public function stream_eof(): bool
|
||||
public function stream_eof()
|
||||
{
|
||||
return $this->stream->eof();
|
||||
}
|
||||
|
||||
public function stream_seek(int $offset, int $whence): bool
|
||||
public function stream_seek($offset, $whence)
|
||||
{
|
||||
$this->stream->seek($offset, $whence);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource|false
|
||||
*/
|
||||
public function stream_cast(int $cast_as)
|
||||
public function stream_cast($cast_as)
|
||||
{
|
||||
$stream = clone $this->stream;
|
||||
$resource = $stream->detach();
|
||||
$stream = clone($this->stream);
|
||||
|
||||
return $resource ?? false;
|
||||
return $stream->detach();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* dev: int,
|
||||
* ino: int,
|
||||
* mode: int,
|
||||
* nlink: int,
|
||||
* uid: int,
|
||||
* gid: int,
|
||||
* rdev: int,
|
||||
* size: int,
|
||||
* atime: int,
|
||||
* mtime: int,
|
||||
* ctime: int,
|
||||
* blksize: int,
|
||||
* blocks: int
|
||||
* }
|
||||
*/
|
||||
public function stream_stat(): array
|
||||
public function stream_stat()
|
||||
{
|
||||
static $modeMap = [
|
||||
'r' => 33060,
|
||||
'r' => 33060,
|
||||
'rb' => 33060,
|
||||
'r+' => 33206,
|
||||
'w' => 33188,
|
||||
'wb' => 33188,
|
||||
'w' => 33188,
|
||||
'wb' => 33188
|
||||
];
|
||||
|
||||
return [
|
||||
'dev' => 0,
|
||||
'ino' => 0,
|
||||
'mode' => $modeMap[$this->mode],
|
||||
'nlink' => 0,
|
||||
'uid' => 0,
|
||||
'gid' => 0,
|
||||
'rdev' => 0,
|
||||
'size' => $this->stream->getSize() ?: 0,
|
||||
'atime' => 0,
|
||||
'mtime' => 0,
|
||||
'ctime' => 0,
|
||||
'dev' => 0,
|
||||
'ino' => 0,
|
||||
'mode' => $modeMap[$this->mode],
|
||||
'nlink' => 0,
|
||||
'uid' => 0,
|
||||
'gid' => 0,
|
||||
'rdev' => 0,
|
||||
'size' => $this->stream->getSize() ?: 0,
|
||||
'atime' => 0,
|
||||
'mtime' => 0,
|
||||
'ctime' => 0,
|
||||
'blksize' => 0,
|
||||
'blocks' => 0,
|
||||
'blocks' => 0
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{
|
||||
* dev: int,
|
||||
* ino: int,
|
||||
* mode: int,
|
||||
* nlink: int,
|
||||
* uid: int,
|
||||
* gid: int,
|
||||
* rdev: int,
|
||||
* size: int,
|
||||
* atime: int,
|
||||
* mtime: int,
|
||||
* ctime: int,
|
||||
* blksize: int,
|
||||
* blocks: int
|
||||
* }
|
||||
*/
|
||||
public function url_stat(string $path, int $flags): array
|
||||
public function url_stat($path, $flags)
|
||||
{
|
||||
return [
|
||||
'dev' => 0,
|
||||
'ino' => 0,
|
||||
'mode' => 0,
|
||||
'nlink' => 0,
|
||||
'uid' => 0,
|
||||
'gid' => 0,
|
||||
'rdev' => 0,
|
||||
'size' => 0,
|
||||
'atime' => 0,
|
||||
'mtime' => 0,
|
||||
'ctime' => 0,
|
||||
'dev' => 0,
|
||||
'ino' => 0,
|
||||
'mode' => 0,
|
||||
'nlink' => 0,
|
||||
'uid' => 0,
|
||||
'gid' => 0,
|
||||
'rdev' => 0,
|
||||
'size' => 0,
|
||||
'atime' => 0,
|
||||
'mtime' => 0,
|
||||
'ctime' => 0,
|
||||
'blksize' => 0,
|
||||
'blocks' => 0,
|
||||
'blocks' => 0
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
185
vendor/guzzlehttp/psr7/src/UploadedFile.php
vendored
185
vendor/guzzlehttp/psr7/src/UploadedFile.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use InvalidArgumentException;
|
||||
@@ -11,7 +9,10 @@ use RuntimeException;
|
||||
|
||||
class UploadedFile implements UploadedFileInterface
|
||||
{
|
||||
private const ERRORS = [
|
||||
/**
|
||||
* @var int[]
|
||||
*/
|
||||
private static $errors = [
|
||||
UPLOAD_ERR_OK,
|
||||
UPLOAD_ERR_INI_SIZE,
|
||||
UPLOAD_ERR_FORM_SIZE,
|
||||
@@ -23,12 +24,12 @@ class UploadedFile implements UploadedFileInterface
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
* @var string
|
||||
*/
|
||||
private $clientFilename;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
* @var string
|
||||
*/
|
||||
private $clientMediaType;
|
||||
|
||||
@@ -48,7 +49,7 @@ class UploadedFile implements UploadedFileInterface
|
||||
private $moved = false;
|
||||
|
||||
/**
|
||||
* @var int|null
|
||||
* @var int
|
||||
*/
|
||||
private $size;
|
||||
|
||||
@@ -59,18 +60,22 @@ class UploadedFile implements UploadedFileInterface
|
||||
|
||||
/**
|
||||
* @param StreamInterface|string|resource $streamOrFile
|
||||
* @param int $size
|
||||
* @param int $errorStatus
|
||||
* @param string|null $clientFilename
|
||||
* @param string|null $clientMediaType
|
||||
*/
|
||||
public function __construct(
|
||||
$streamOrFile,
|
||||
?int $size,
|
||||
int $errorStatus,
|
||||
string $clientFilename = null,
|
||||
string $clientMediaType = null
|
||||
$size,
|
||||
$errorStatus,
|
||||
$clientFilename = null,
|
||||
$clientMediaType = null
|
||||
) {
|
||||
$this->setError($errorStatus);
|
||||
$this->size = $size;
|
||||
$this->clientFilename = $clientFilename;
|
||||
$this->clientMediaType = $clientMediaType;
|
||||
$this->setSize($size);
|
||||
$this->setClientFilename($clientFilename);
|
||||
$this->setClientMediaType($clientMediaType);
|
||||
|
||||
if ($this->isOk()) {
|
||||
$this->setStreamOrFile($streamOrFile);
|
||||
@@ -80,11 +85,11 @@ class UploadedFile implements UploadedFileInterface
|
||||
/**
|
||||
* Depending on the value set file or stream variable
|
||||
*
|
||||
* @param StreamInterface|string|resource $streamOrFile
|
||||
* @param mixed $streamOrFile
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function setStreamOrFile($streamOrFile): void
|
||||
private function setStreamOrFile($streamOrFile)
|
||||
{
|
||||
if (is_string($streamOrFile)) {
|
||||
$this->file = $streamOrFile;
|
||||
@@ -100,11 +105,19 @@ class UploadedFile implements UploadedFileInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $error
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function setError(int $error): void
|
||||
private function setError($error)
|
||||
{
|
||||
if (false === in_array($error, UploadedFile::ERRORS, true)) {
|
||||
if (false === is_int($error)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Upload file error status must be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
if (false === in_array($error, UploadedFile::$errors)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Invalid error status for UploadedFile'
|
||||
);
|
||||
@@ -113,20 +126,88 @@ class UploadedFile implements UploadedFileInterface
|
||||
$this->error = $error;
|
||||
}
|
||||
|
||||
private static function isStringNotEmpty($param): bool
|
||||
/**
|
||||
* @param int $size
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function setSize($size)
|
||||
{
|
||||
if (false === is_int($size)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Upload file size must be an integer'
|
||||
);
|
||||
}
|
||||
|
||||
$this->size = $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $param
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isStringOrNull($param)
|
||||
{
|
||||
return in_array(gettype($param), ['string', 'NULL']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $param
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isStringNotEmpty($param)
|
||||
{
|
||||
return is_string($param) && false === empty($param);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if there is no upload error
|
||||
* @param string|null $clientFilename
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function isOk(): bool
|
||||
private function setClientFilename($clientFilename)
|
||||
{
|
||||
if (false === $this->isStringOrNull($clientFilename)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Upload file client filename must be a string or null'
|
||||
);
|
||||
}
|
||||
|
||||
$this->clientFilename = $clientFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|null $clientMediaType
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
private function setClientMediaType($clientMediaType)
|
||||
{
|
||||
if (false === $this->isStringOrNull($clientMediaType)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Upload file client media type must be a string or null'
|
||||
);
|
||||
}
|
||||
|
||||
$this->clientMediaType = $clientMediaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if there is no upload error
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isOk()
|
||||
{
|
||||
return $this->error === UPLOAD_ERR_OK;
|
||||
}
|
||||
|
||||
public function isMoved(): bool
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isMoved()
|
||||
{
|
||||
return $this->moved;
|
||||
}
|
||||
@@ -134,7 +215,7 @@ class UploadedFile implements UploadedFileInterface
|
||||
/**
|
||||
* @throws RuntimeException if is moved or not ok
|
||||
*/
|
||||
private function validateActive(): void
|
||||
private function validateActive()
|
||||
{
|
||||
if (false === $this->isOk()) {
|
||||
throw new RuntimeException('Cannot retrieve stream due to upload error');
|
||||
@@ -145,7 +226,12 @@ class UploadedFile implements UploadedFileInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function getStream(): StreamInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @throws RuntimeException if the upload was not successful.
|
||||
*/
|
||||
public function getStream()
|
||||
{
|
||||
$this->validateActive();
|
||||
|
||||
@@ -153,24 +239,34 @@ class UploadedFile implements UploadedFileInterface
|
||||
return $this->stream;
|
||||
}
|
||||
|
||||
/** @var string $file */
|
||||
$file = $this->file;
|
||||
|
||||
return new LazyOpenStream($file, 'r+');
|
||||
return new LazyOpenStream($this->file, 'r+');
|
||||
}
|
||||
|
||||
public function moveTo($targetPath): void
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see http://php.net/is_uploaded_file
|
||||
* @see http://php.net/move_uploaded_file
|
||||
*
|
||||
* @param string $targetPath Path to which to move the uploaded file.
|
||||
*
|
||||
* @throws RuntimeException if the upload was not successful.
|
||||
* @throws InvalidArgumentException if the $path specified is invalid.
|
||||
* @throws RuntimeException on any error during the move operation, or on
|
||||
* the second or subsequent call to the method.
|
||||
*/
|
||||
public function moveTo($targetPath)
|
||||
{
|
||||
$this->validateActive();
|
||||
|
||||
if (false === self::isStringNotEmpty($targetPath)) {
|
||||
if (false === $this->isStringNotEmpty($targetPath)) {
|
||||
throw new InvalidArgumentException(
|
||||
'Invalid path provided for move operation; must be a non-empty string'
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->file) {
|
||||
$this->moved = PHP_SAPI === 'cli'
|
||||
$this->moved = php_sapi_name() == 'cli'
|
||||
? rename($this->file, $targetPath)
|
||||
: move_uploaded_file($this->file, $targetPath);
|
||||
} else {
|
||||
@@ -189,22 +285,43 @@ class UploadedFile implements UploadedFileInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function getSize(): ?int
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return int|null The file size in bytes or null if unknown.
|
||||
*/
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function getError(): int
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see http://php.net/manual/en/features.file-upload.errors.php
|
||||
*
|
||||
* @return int One of PHP's UPLOAD_ERR_XXX constants.
|
||||
*/
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
public function getClientFilename(): ?string
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return string|null The filename sent by the client or null if none
|
||||
* was provided.
|
||||
*/
|
||||
public function getClientFilename()
|
||||
{
|
||||
return $this->clientFilename;
|
||||
}
|
||||
|
||||
public function getClientMediaType(): ?string
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getClientMediaType()
|
||||
{
|
||||
return $this->clientMediaType;
|
||||
}
|
||||
|
||||
341
vendor/guzzlehttp/psr7/src/Uri.php
vendored
341
vendor/guzzlehttp/psr7/src/Uri.php
vendored
@@ -1,10 +1,7 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use GuzzleHttp\Psr7\Exception\MalformedUriException;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
@@ -14,7 +11,7 @@ use Psr\Http\Message\UriInterface;
|
||||
* @author Tobias Schultze
|
||||
* @author Matthew Weier O'Phinney
|
||||
*/
|
||||
class Uri implements UriInterface, \JsonSerializable
|
||||
class Uri implements UriInterface
|
||||
{
|
||||
/**
|
||||
* Absolute http and https URIs require a host per RFC 7230 Section 2.7
|
||||
@@ -22,10 +19,10 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
* we apply this default host when no host is given yet to form a
|
||||
* valid URI.
|
||||
*/
|
||||
private const HTTP_DEFAULT_HOST = 'localhost';
|
||||
const HTTP_DEFAULT_HOST = 'localhost';
|
||||
|
||||
private const DEFAULT_PORTS = [
|
||||
'http' => 80,
|
||||
private static $defaultPorts = [
|
||||
'http' => 80,
|
||||
'https' => 443,
|
||||
'ftp' => 21,
|
||||
'gopher' => 70,
|
||||
@@ -38,20 +35,9 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
'ldap' => 389,
|
||||
];
|
||||
|
||||
/**
|
||||
* Unreserved characters for use in a regex.
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
|
||||
*/
|
||||
private const CHAR_UNRESERVED = 'a-zA-Z0-9_\-\.~';
|
||||
|
||||
/**
|
||||
* Sub-delims for use in a regex.
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
|
||||
*/
|
||||
private const CHAR_SUB_DELIMS = '!\$&\'\(\)\*\+,;=';
|
||||
private const QUERY_SEPARATORS_REPLACEMENT = ['=' => '%3D', '&' => '%26'];
|
||||
private static $charUnreserved = 'a-zA-Z0-9_\-\.~';
|
||||
private static $charSubDelims = '!\$&\'\(\)\*\+,;=';
|
||||
private static $replaceQuery = ['=' => '%3D', '&' => '%26'];
|
||||
|
||||
/** @var string Uri scheme. */
|
||||
private $scheme = '';
|
||||
@@ -74,15 +60,16 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
/** @var string Uri fragment. */
|
||||
private $fragment = '';
|
||||
|
||||
/** @var string|null String representation */
|
||||
private $composedComponents;
|
||||
|
||||
public function __construct(string $uri = '')
|
||||
/**
|
||||
* @param string $uri URI to parse
|
||||
*/
|
||||
public function __construct($uri = '')
|
||||
{
|
||||
if ($uri !== '') {
|
||||
// weak type check to also accept null until we can add scalar type hints
|
||||
if ($uri != '') {
|
||||
$parts = self::parse($uri);
|
||||
if ($parts === false) {
|
||||
throw new MalformedUriException("Unable to parse URI: $uri");
|
||||
throw new \InvalidArgumentException("Unable to parse URI: $uri");
|
||||
}
|
||||
$this->applyParts($parts);
|
||||
}
|
||||
@@ -101,19 +88,19 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
* @see https://www.php.net/manual/en/function.parse-url.php#114817
|
||||
* @see https://curl.haxx.se/libcurl/c/CURLOPT_URL.html#ENCODING
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
private static function parse(string $url)
|
||||
private static function parse($url)
|
||||
{
|
||||
// If IPv6
|
||||
$prefix = '';
|
||||
if (preg_match('%^(.*://\[[0-9:a-f]+\])(.*?)$%', $url, $matches)) {
|
||||
/** @var array{0:string, 1:string, 2:string} $matches */
|
||||
$prefix = $matches[1];
|
||||
$url = $matches[2];
|
||||
}
|
||||
|
||||
/** @var string */
|
||||
$encodedUrl = preg_replace_callback(
|
||||
'%[^:/@?&=#]+%usD',
|
||||
static function ($matches) {
|
||||
@@ -122,7 +109,7 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
$url
|
||||
);
|
||||
|
||||
$result = parse_url($prefix.$encodedUrl);
|
||||
$result = parse_url($prefix . $encodedUrl);
|
||||
|
||||
if ($result === false) {
|
||||
return false;
|
||||
@@ -131,19 +118,15 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
return array_map('urldecode', $result);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
public function __toString()
|
||||
{
|
||||
if ($this->composedComponents === null) {
|
||||
$this->composedComponents = self::composeComponents(
|
||||
$this->scheme,
|
||||
$this->getAuthority(),
|
||||
$this->path,
|
||||
$this->query,
|
||||
$this->fragment
|
||||
);
|
||||
}
|
||||
|
||||
return $this->composedComponents;
|
||||
return self::composeComponents(
|
||||
$this->scheme,
|
||||
$this->getAuthority(),
|
||||
$this->path,
|
||||
$this->query,
|
||||
$this->fragment
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -162,33 +145,37 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
* `file:///` is the more common syntax for the file scheme anyway (Chrome for example redirects to
|
||||
* that format).
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.3
|
||||
* @param string $scheme
|
||||
* @param string $authority
|
||||
* @param string $path
|
||||
* @param string $query
|
||||
* @param string $fragment
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-5.3
|
||||
*/
|
||||
public static function composeComponents(?string $scheme, ?string $authority, string $path, ?string $query, ?string $fragment): string
|
||||
public static function composeComponents($scheme, $authority, $path, $query, $fragment)
|
||||
{
|
||||
$uri = '';
|
||||
|
||||
// weak type checks to also accept null until we can add scalar type hints
|
||||
if ($scheme != '') {
|
||||
$uri .= $scheme.':';
|
||||
$uri .= $scheme . ':';
|
||||
}
|
||||
|
||||
if ($authority != '' || $scheme === 'file') {
|
||||
$uri .= '//'.$authority;
|
||||
}
|
||||
|
||||
if ($authority != '' && $path != '' && $path[0] != '/') {
|
||||
$path = '/'.$path;
|
||||
if ($authority != ''|| $scheme === 'file') {
|
||||
$uri .= '//' . $authority;
|
||||
}
|
||||
|
||||
$uri .= $path;
|
||||
|
||||
if ($query != '') {
|
||||
$uri .= '?'.$query;
|
||||
$uri .= '?' . $query;
|
||||
}
|
||||
|
||||
if ($fragment != '') {
|
||||
$uri .= '#'.$fragment;
|
||||
$uri .= '#' . $fragment;
|
||||
}
|
||||
|
||||
return $uri;
|
||||
@@ -199,11 +186,15 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
*
|
||||
* `Psr\Http\Message\UriInterface::getPort` may return null or the standard port. This method can be used
|
||||
* independently of the implementation.
|
||||
*
|
||||
* @param UriInterface $uri
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isDefaultPort(UriInterface $uri): bool
|
||||
public static function isDefaultPort(UriInterface $uri)
|
||||
{
|
||||
return $uri->getPort() === null
|
||||
|| (isset(self::DEFAULT_PORTS[$uri->getScheme()]) && $uri->getPort() === self::DEFAULT_PORTS[$uri->getScheme()]);
|
||||
|| (isset(self::$defaultPorts[$uri->getScheme()]) && $uri->getPort() === self::$defaultPorts[$uri->getScheme()]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,12 +207,16 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
* - absolute-path references, e.g. '/path'
|
||||
* - relative-path references, e.g. 'subpath'
|
||||
*
|
||||
* @param UriInterface $uri
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @see Uri::isNetworkPathReference
|
||||
* @see Uri::isAbsolutePathReference
|
||||
* @see Uri::isRelativePathReference
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-4
|
||||
*/
|
||||
public static function isAbsolute(UriInterface $uri): bool
|
||||
public static function isAbsolute(UriInterface $uri)
|
||||
{
|
||||
return $uri->getScheme() !== '';
|
||||
}
|
||||
@@ -231,9 +226,13 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
*
|
||||
* A relative reference that begins with two slash characters is termed an network-path reference.
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||
* @param UriInterface $uri
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
||||
*/
|
||||
public static function isNetworkPathReference(UriInterface $uri): bool
|
||||
public static function isNetworkPathReference(UriInterface $uri)
|
||||
{
|
||||
return $uri->getScheme() === '' && $uri->getAuthority() !== '';
|
||||
}
|
||||
@@ -243,9 +242,13 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
*
|
||||
* A relative reference that begins with a single slash character is termed an absolute-path reference.
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||
* @param UriInterface $uri
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
||||
*/
|
||||
public static function isAbsolutePathReference(UriInterface $uri): bool
|
||||
public static function isAbsolutePathReference(UriInterface $uri)
|
||||
{
|
||||
return $uri->getScheme() === ''
|
||||
&& $uri->getAuthority() === ''
|
||||
@@ -258,9 +261,13 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
*
|
||||
* A relative reference that does not begin with a slash character is termed a relative-path reference.
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.2
|
||||
* @param UriInterface $uri
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-4.2
|
||||
*/
|
||||
public static function isRelativePathReference(UriInterface $uri): bool
|
||||
public static function isRelativePathReference(UriInterface $uri)
|
||||
{
|
||||
return $uri->getScheme() === ''
|
||||
&& $uri->getAuthority() === ''
|
||||
@@ -277,9 +284,11 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
* @param UriInterface $uri The URI to check
|
||||
* @param UriInterface|null $base An optional base URI to compare against
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-4.4
|
||||
* @return bool
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-4.4
|
||||
*/
|
||||
public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null): bool
|
||||
public static function isSameDocumentReference(UriInterface $uri, UriInterface $base = null)
|
||||
{
|
||||
if ($base !== null) {
|
||||
$uri = UriResolver::resolve($base, $uri);
|
||||
@@ -293,6 +302,41 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
return $uri->getScheme() === '' && $uri->getAuthority() === '' && $uri->getPath() === '' && $uri->getQuery() === '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes dot segments from a path and returns the new path.
|
||||
*
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @deprecated since version 1.4. Use UriResolver::removeDotSegments instead.
|
||||
* @see UriResolver::removeDotSegments
|
||||
*/
|
||||
public static function removeDotSegments($path)
|
||||
{
|
||||
return UriResolver::removeDotSegments($path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the relative URI into a new URI that is resolved against the base URI.
|
||||
*
|
||||
* @param UriInterface $base Base URI
|
||||
* @param string|UriInterface $rel Relative URI
|
||||
*
|
||||
* @return UriInterface
|
||||
*
|
||||
* @deprecated since version 1.4. Use UriResolver::resolve instead.
|
||||
* @see UriResolver::resolve
|
||||
*/
|
||||
public static function resolve(UriInterface $base, $rel)
|
||||
{
|
||||
if (!($rel instanceof UriInterface)) {
|
||||
$rel = new self($rel);
|
||||
}
|
||||
|
||||
return UriResolver::resolve($base, $rel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new URI with a specific query string value removed.
|
||||
*
|
||||
@@ -301,8 +345,10 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
*
|
||||
* @param UriInterface $uri URI to use as a base.
|
||||
* @param string $key Query string key to remove.
|
||||
*
|
||||
* @return UriInterface
|
||||
*/
|
||||
public static function withoutQueryValue(UriInterface $uri, string $key): UriInterface
|
||||
public static function withoutQueryValue(UriInterface $uri, $key)
|
||||
{
|
||||
$result = self::getFilteredQueryString($uri, [$key]);
|
||||
|
||||
@@ -321,8 +367,10 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
* @param UriInterface $uri URI to use as a base.
|
||||
* @param string $key Key to set.
|
||||
* @param string|null $value Value to set
|
||||
*
|
||||
* @return UriInterface
|
||||
*/
|
||||
public static function withQueryValue(UriInterface $uri, string $key, ?string $value): UriInterface
|
||||
public static function withQueryValue(UriInterface $uri, $key, $value)
|
||||
{
|
||||
$result = self::getFilteredQueryString($uri, [$key]);
|
||||
|
||||
@@ -336,15 +384,17 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
*
|
||||
* It has the same behavior as withQueryValue() but for an associative array of key => value.
|
||||
*
|
||||
* @param UriInterface $uri URI to use as a base.
|
||||
* @param (string|null)[] $keyValueArray Associative array of key and values
|
||||
* @param UriInterface $uri URI to use as a base.
|
||||
* @param array $keyValueArray Associative array of key and values
|
||||
*
|
||||
* @return UriInterface
|
||||
*/
|
||||
public static function withQueryValues(UriInterface $uri, array $keyValueArray): UriInterface
|
||||
public static function withQueryValues(UriInterface $uri, array $keyValueArray)
|
||||
{
|
||||
$result = self::getFilteredQueryString($uri, array_keys($keyValueArray));
|
||||
|
||||
foreach ($keyValueArray as $key => $value) {
|
||||
$result[] = self::generateQueryString((string) $key, $value !== null ? (string) $value : null);
|
||||
$result[] = self::generateQueryString($key, $value);
|
||||
}
|
||||
|
||||
return $uri->withQuery(implode('&', $result));
|
||||
@@ -353,11 +403,15 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
/**
|
||||
* Creates a URI from a hash of `parse_url` components.
|
||||
*
|
||||
* @see https://www.php.net/manual/en/function.parse-url.php
|
||||
* @param array $parts
|
||||
*
|
||||
* @throws MalformedUriException If the components do not form a valid URI.
|
||||
* @return UriInterface
|
||||
*
|
||||
* @link http://php.net/manual/en/function.parse-url.php
|
||||
*
|
||||
* @throws \InvalidArgumentException If the components do not form a valid URI.
|
||||
*/
|
||||
public static function fromParts(array $parts): UriInterface
|
||||
public static function fromParts(array $parts)
|
||||
{
|
||||
$uri = new self();
|
||||
$uri->applyParts($parts);
|
||||
@@ -366,56 +420,56 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public function getScheme(): string
|
||||
public function getScheme()
|
||||
{
|
||||
return $this->scheme;
|
||||
}
|
||||
|
||||
public function getAuthority(): string
|
||||
public function getAuthority()
|
||||
{
|
||||
$authority = $this->host;
|
||||
if ($this->userInfo !== '') {
|
||||
$authority = $this->userInfo.'@'.$authority;
|
||||
$authority = $this->userInfo . '@' . $authority;
|
||||
}
|
||||
|
||||
if ($this->port !== null) {
|
||||
$authority .= ':'.$this->port;
|
||||
$authority .= ':' . $this->port;
|
||||
}
|
||||
|
||||
return $authority;
|
||||
}
|
||||
|
||||
public function getUserInfo(): string
|
||||
public function getUserInfo()
|
||||
{
|
||||
return $this->userInfo;
|
||||
}
|
||||
|
||||
public function getHost(): string
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
public function getPort(): ?int
|
||||
public function getPort()
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
public function getPath()
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function getQuery(): string
|
||||
public function getQuery()
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
public function getFragment(): string
|
||||
public function getFragment()
|
||||
{
|
||||
return $this->fragment;
|
||||
}
|
||||
|
||||
public function withScheme($scheme): UriInterface
|
||||
public function withScheme($scheme)
|
||||
{
|
||||
$scheme = $this->filterScheme($scheme);
|
||||
|
||||
@@ -425,18 +479,17 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
|
||||
$new = clone $this;
|
||||
$new->scheme = $scheme;
|
||||
$new->composedComponents = null;
|
||||
$new->removeDefaultPort();
|
||||
$new->validateState();
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function withUserInfo($user, $password = null): UriInterface
|
||||
public function withUserInfo($user, $password = null)
|
||||
{
|
||||
$info = $this->filterUserInfoComponent($user);
|
||||
if ($password !== null) {
|
||||
$info .= ':'.$this->filterUserInfoComponent($password);
|
||||
$info .= ':' . $this->filterUserInfoComponent($password);
|
||||
}
|
||||
|
||||
if ($this->userInfo === $info) {
|
||||
@@ -445,13 +498,12 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
|
||||
$new = clone $this;
|
||||
$new->userInfo = $info;
|
||||
$new->composedComponents = null;
|
||||
$new->validateState();
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function withHost($host): UriInterface
|
||||
public function withHost($host)
|
||||
{
|
||||
$host = $this->filterHost($host);
|
||||
|
||||
@@ -461,13 +513,12 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
|
||||
$new = clone $this;
|
||||
$new->host = $host;
|
||||
$new->composedComponents = null;
|
||||
$new->validateState();
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function withPort($port): UriInterface
|
||||
public function withPort($port)
|
||||
{
|
||||
$port = $this->filterPort($port);
|
||||
|
||||
@@ -477,14 +528,13 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
|
||||
$new = clone $this;
|
||||
$new->port = $port;
|
||||
$new->composedComponents = null;
|
||||
$new->removeDefaultPort();
|
||||
$new->validateState();
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function withPath($path): UriInterface
|
||||
public function withPath($path)
|
||||
{
|
||||
$path = $this->filterPath($path);
|
||||
|
||||
@@ -494,13 +544,12 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
|
||||
$new = clone $this;
|
||||
$new->path = $path;
|
||||
$new->composedComponents = null;
|
||||
$new->validateState();
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function withQuery($query): UriInterface
|
||||
public function withQuery($query)
|
||||
{
|
||||
$query = $this->filterQueryAndFragment($query);
|
||||
|
||||
@@ -510,12 +559,11 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
|
||||
$new = clone $this;
|
||||
$new->query = $query;
|
||||
$new->composedComponents = null;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function withFragment($fragment): UriInterface
|
||||
public function withFragment($fragment)
|
||||
{
|
||||
$fragment = $this->filterQueryAndFragment($fragment);
|
||||
|
||||
@@ -525,22 +573,16 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
|
||||
$new = clone $this;
|
||||
$new->fragment = $fragment;
|
||||
$new->composedComponents = null;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function jsonSerialize(): string
|
||||
{
|
||||
return $this->__toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply parse_url parts to a URI.
|
||||
*
|
||||
* @param array $parts Array of parse_url parts to apply.
|
||||
*/
|
||||
private function applyParts(array $parts): void
|
||||
private function applyParts(array $parts)
|
||||
{
|
||||
$this->scheme = isset($parts['scheme'])
|
||||
? $this->filterScheme($parts['scheme'])
|
||||
@@ -564,18 +606,20 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
? $this->filterQueryAndFragment($parts['fragment'])
|
||||
: '';
|
||||
if (isset($parts['pass'])) {
|
||||
$this->userInfo .= ':'.$this->filterUserInfoComponent($parts['pass']);
|
||||
$this->userInfo .= ':' . $this->filterUserInfoComponent($parts['pass']);
|
||||
}
|
||||
|
||||
$this->removeDefaultPort();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $scheme
|
||||
* @param string $scheme
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException If the scheme is invalid.
|
||||
*/
|
||||
private function filterScheme($scheme): string
|
||||
private function filterScheme($scheme)
|
||||
{
|
||||
if (!is_string($scheme)) {
|
||||
throw new \InvalidArgumentException('Scheme must be a string');
|
||||
@@ -585,29 +629,33 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $component
|
||||
* @param string $component
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException If the user info is invalid.
|
||||
*/
|
||||
private function filterUserInfoComponent($component): string
|
||||
private function filterUserInfoComponent($component)
|
||||
{
|
||||
if (!is_string($component)) {
|
||||
throw new \InvalidArgumentException('User info must be a string');
|
||||
}
|
||||
|
||||
return preg_replace_callback(
|
||||
'/(?:[^%'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.']+|%(?![A-Fa-f0-9]{2}))/',
|
||||
'/(?:[^%' . self::$charUnreserved . self::$charSubDelims . ']+|%(?![A-Fa-f0-9]{2}))/',
|
||||
[$this, 'rawurlencodeMatchZero'],
|
||||
$component
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $host
|
||||
* @param string $host
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException If the host is invalid.
|
||||
*/
|
||||
private function filterHost($host): string
|
||||
private function filterHost($host)
|
||||
{
|
||||
if (!is_string($host)) {
|
||||
throw new \InvalidArgumentException('Host must be a string');
|
||||
@@ -617,18 +665,20 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $port
|
||||
* @param int|null $port
|
||||
*
|
||||
* @return int|null
|
||||
*
|
||||
* @throws \InvalidArgumentException If the port is invalid.
|
||||
*/
|
||||
private function filterPort($port): ?int
|
||||
private function filterPort($port)
|
||||
{
|
||||
if ($port === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$port = (int) $port;
|
||||
if (0 > $port || 0xFFFF < $port) {
|
||||
if (0 > $port || 0xffff < $port) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf('Invalid port: %d. Must be between 0 and 65535', $port)
|
||||
);
|
||||
@@ -638,11 +688,12 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
}
|
||||
|
||||
/**
|
||||
* @param (string|int)[] $keys
|
||||
* @param UriInterface $uri
|
||||
* @param array $keys
|
||||
*
|
||||
* @return string[]
|
||||
* @return array
|
||||
*/
|
||||
private static function getFilteredQueryString(UriInterface $uri, array $keys): array
|
||||
private static function getFilteredQueryString(UriInterface $uri, array $keys)
|
||||
{
|
||||
$current = $uri->getQuery();
|
||||
|
||||
@@ -650,30 +701,34 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
return [];
|
||||
}
|
||||
|
||||
$decodedKeys = array_map(function ($k): string {
|
||||
return rawurldecode((string) $k);
|
||||
}, $keys);
|
||||
$decodedKeys = array_map('rawurldecode', $keys);
|
||||
|
||||
return array_filter(explode('&', $current), function ($part) use ($decodedKeys) {
|
||||
return !in_array(rawurldecode(explode('=', $part)[0]), $decodedKeys, true);
|
||||
});
|
||||
}
|
||||
|
||||
private static function generateQueryString(string $key, ?string $value): string
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function generateQueryString($key, $value)
|
||||
{
|
||||
// Query string separators ("=", "&") within the key or value need to be encoded
|
||||
// (while preventing double-encoding) before setting the query string. All other
|
||||
// chars that need percent-encoding will be encoded by withQuery().
|
||||
$queryString = strtr($key, self::QUERY_SEPARATORS_REPLACEMENT);
|
||||
$queryString = strtr($key, self::$replaceQuery);
|
||||
|
||||
if ($value !== null) {
|
||||
$queryString .= '='.strtr($value, self::QUERY_SEPARATORS_REPLACEMENT);
|
||||
$queryString .= '=' . strtr($value, self::$replaceQuery);
|
||||
}
|
||||
|
||||
return $queryString;
|
||||
}
|
||||
|
||||
private function removeDefaultPort(): void
|
||||
private function removeDefaultPort()
|
||||
{
|
||||
if ($this->port !== null && self::isDefaultPort($this)) {
|
||||
$this->port = null;
|
||||
@@ -683,18 +738,20 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
/**
|
||||
* Filters the path of a URI
|
||||
*
|
||||
* @param mixed $path
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException If the path is invalid.
|
||||
*/
|
||||
private function filterPath($path): string
|
||||
private function filterPath($path)
|
||||
{
|
||||
if (!is_string($path)) {
|
||||
throw new \InvalidArgumentException('Path must be a string');
|
||||
}
|
||||
|
||||
return preg_replace_callback(
|
||||
'/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
|
||||
'/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/',
|
||||
[$this, 'rawurlencodeMatchZero'],
|
||||
$path
|
||||
);
|
||||
@@ -703,29 +760,31 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
/**
|
||||
* Filters the query string or fragment of a URI.
|
||||
*
|
||||
* @param mixed $str
|
||||
* @param string $str
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \InvalidArgumentException If the query or fragment is invalid.
|
||||
*/
|
||||
private function filterQueryAndFragment($str): string
|
||||
private function filterQueryAndFragment($str)
|
||||
{
|
||||
if (!is_string($str)) {
|
||||
throw new \InvalidArgumentException('Query and fragment must be a string');
|
||||
}
|
||||
|
||||
return preg_replace_callback(
|
||||
'/(?:[^'.self::CHAR_UNRESERVED.self::CHAR_SUB_DELIMS.'%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
|
||||
'/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
|
||||
[$this, 'rawurlencodeMatchZero'],
|
||||
$str
|
||||
);
|
||||
}
|
||||
|
||||
private function rawurlencodeMatchZero(array $match): string
|
||||
private function rawurlencodeMatchZero(array $match)
|
||||
{
|
||||
return rawurlencode($match[0]);
|
||||
}
|
||||
|
||||
private function validateState(): void
|
||||
private function validateState()
|
||||
{
|
||||
if ($this->host === '' && ($this->scheme === 'http' || $this->scheme === 'https')) {
|
||||
$this->host = self::HTTP_DEFAULT_HOST;
|
||||
@@ -733,11 +792,19 @@ class Uri implements UriInterface, \JsonSerializable
|
||||
|
||||
if ($this->getAuthority() === '') {
|
||||
if (0 === strpos($this->path, '//')) {
|
||||
throw new MalformedUriException('The path of a URI without an authority must not start with two slashes "//"');
|
||||
throw new \InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
|
||||
}
|
||||
if ($this->scheme === '' && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
|
||||
throw new MalformedUriException('A relative URI must not have a path beginning with a segment containing a colon');
|
||||
throw new \InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
|
||||
}
|
||||
} elseif (isset($this->path[0]) && $this->path[0] !== '/') {
|
||||
@trigger_error(
|
||||
'The path of a URI with an authority must start with a slash "/" or be empty. Automagically fixing the URI ' .
|
||||
'by adding a leading slash to the path is deprecated since version 1.4 and will throw an exception instead.',
|
||||
E_USER_DEPRECATED
|
||||
);
|
||||
$this->path = '/' . $this->path;
|
||||
//throw new \InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
vendor/guzzlehttp/psr7/src/UriComparator.php
vendored
11
vendor/guzzlehttp/psr7/src/UriComparator.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\UriInterface;
|
||||
@@ -16,8 +14,10 @@ final class UriComparator
|
||||
/**
|
||||
* Determines if a modified URL should be considered cross-origin with
|
||||
* respect to an original URL.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function isCrossOrigin(UriInterface $original, UriInterface $modified): bool
|
||||
public static function isCrossOrigin(UriInterface $original, UriInterface $modified)
|
||||
{
|
||||
if (\strcasecmp($original->getHost(), $modified->getHost()) !== 0) {
|
||||
return true;
|
||||
@@ -34,7 +34,10 @@ final class UriComparator
|
||||
return false;
|
||||
}
|
||||
|
||||
private static function computePort(UriInterface $uri): int
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
private static function computePort(UriInterface $uri)
|
||||
{
|
||||
$port = $uri->getPort();
|
||||
|
||||
|
||||
55
vendor/guzzlehttp/psr7/src/UriNormalizer.php
vendored
55
vendor/guzzlehttp/psr7/src/UriNormalizer.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\UriInterface;
|
||||
@@ -11,27 +9,24 @@ use Psr\Http\Message\UriInterface;
|
||||
*
|
||||
* @author Tobias Schultze
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-6
|
||||
*/
|
||||
final class UriNormalizer
|
||||
{
|
||||
/**
|
||||
* Default normalizations which only include the ones that preserve semantics.
|
||||
*
|
||||
* self::CAPITALIZE_PERCENT_ENCODING | self::DECODE_UNRESERVED_CHARACTERS | self::CONVERT_EMPTY_PATH |
|
||||
* self::REMOVE_DEFAULT_HOST | self::REMOVE_DEFAULT_PORT | self::REMOVE_DOT_SEGMENTS
|
||||
*/
|
||||
public const PRESERVING_NORMALIZATIONS =
|
||||
self::CAPITALIZE_PERCENT_ENCODING |
|
||||
self::DECODE_UNRESERVED_CHARACTERS |
|
||||
self::CONVERT_EMPTY_PATH |
|
||||
self::REMOVE_DEFAULT_HOST |
|
||||
self::REMOVE_DEFAULT_PORT |
|
||||
self::REMOVE_DOT_SEGMENTS;
|
||||
const PRESERVING_NORMALIZATIONS = 63;
|
||||
|
||||
/**
|
||||
* All letters within a percent-encoding triplet (e.g., "%3A") are case-insensitive, and should be capitalized.
|
||||
*
|
||||
* Example: http://example.org/a%c2%b1b → http://example.org/a%C2%B1b
|
||||
*/
|
||||
public const CAPITALIZE_PERCENT_ENCODING = 1;
|
||||
const CAPITALIZE_PERCENT_ENCODING = 1;
|
||||
|
||||
/**
|
||||
* Decodes percent-encoded octets of unreserved characters.
|
||||
@@ -42,14 +37,14 @@ final class UriNormalizer
|
||||
*
|
||||
* Example: http://example.org/%7Eusern%61me/ → http://example.org/~username/
|
||||
*/
|
||||
public const DECODE_UNRESERVED_CHARACTERS = 2;
|
||||
const DECODE_UNRESERVED_CHARACTERS = 2;
|
||||
|
||||
/**
|
||||
* Converts the empty path to "/" for http and https URIs.
|
||||
*
|
||||
* Example: http://example.org → http://example.org/
|
||||
*/
|
||||
public const CONVERT_EMPTY_PATH = 4;
|
||||
const CONVERT_EMPTY_PATH = 4;
|
||||
|
||||
/**
|
||||
* Removes the default host of the given URI scheme from the URI.
|
||||
@@ -62,14 +57,14 @@ final class UriNormalizer
|
||||
*
|
||||
* Example: file://localhost/myfile → file:///myfile
|
||||
*/
|
||||
public const REMOVE_DEFAULT_HOST = 8;
|
||||
const REMOVE_DEFAULT_HOST = 8;
|
||||
|
||||
/**
|
||||
* Removes the default port of the given URI scheme from the URI.
|
||||
*
|
||||
* Example: http://example.org:80/ → http://example.org/
|
||||
*/
|
||||
public const REMOVE_DEFAULT_PORT = 16;
|
||||
const REMOVE_DEFAULT_PORT = 16;
|
||||
|
||||
/**
|
||||
* Removes unnecessary dot-segments.
|
||||
@@ -79,7 +74,7 @@ final class UriNormalizer
|
||||
*
|
||||
* Example: http://example.org/../a/b/../c/./d.html → http://example.org/a/c/d.html
|
||||
*/
|
||||
public const REMOVE_DOT_SEGMENTS = 32;
|
||||
const REMOVE_DOT_SEGMENTS = 32;
|
||||
|
||||
/**
|
||||
* Paths which include two or more adjacent slashes are converted to one.
|
||||
@@ -90,7 +85,7 @@ final class UriNormalizer
|
||||
*
|
||||
* Example: http://example.org//foo///bar.html → http://example.org/foo/bar.html
|
||||
*/
|
||||
public const REMOVE_DUPLICATE_SLASHES = 64;
|
||||
const REMOVE_DUPLICATE_SLASHES = 64;
|
||||
|
||||
/**
|
||||
* Sort query parameters with their values in alphabetical order.
|
||||
@@ -103,7 +98,7 @@ final class UriNormalizer
|
||||
* Note: The sorting is neither locale nor Unicode aware (the URI query does not get decoded at all) as the
|
||||
* purpose is to be able to compare URIs in a reproducible way, not to have the params sorted perfectly.
|
||||
*/
|
||||
public const SORT_QUERY_PARAMETERS = 128;
|
||||
const SORT_QUERY_PARAMETERS = 128;
|
||||
|
||||
/**
|
||||
* Returns a normalized URI.
|
||||
@@ -119,9 +114,11 @@ final class UriNormalizer
|
||||
* @param UriInterface $uri The URI to normalize
|
||||
* @param int $flags A bitmask of normalizations to apply, see constants
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.2
|
||||
* @return UriInterface The normalized URI
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-6.2
|
||||
*/
|
||||
public static function normalize(UriInterface $uri, int $flags = self::PRESERVING_NORMALIZATIONS): UriInterface
|
||||
public static function normalize(UriInterface $uri, $flags = self::PRESERVING_NORMALIZATIONS)
|
||||
{
|
||||
if ($flags & self::CAPITALIZE_PERCENT_ENCODING) {
|
||||
$uri = self::capitalizePercentEncoding($uri);
|
||||
@@ -131,8 +128,8 @@ final class UriNormalizer
|
||||
$uri = self::decodeUnreservedCharacters($uri);
|
||||
}
|
||||
|
||||
if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === ''
|
||||
&& ($uri->getScheme() === 'http' || $uri->getScheme() === 'https')
|
||||
if ($flags & self::CONVERT_EMPTY_PATH && $uri->getPath() === '' &&
|
||||
($uri->getScheme() === 'http' || $uri->getScheme() === 'https')
|
||||
) {
|
||||
$uri = $uri->withPath('/');
|
||||
}
|
||||
@@ -174,18 +171,20 @@ final class UriNormalizer
|
||||
* @param UriInterface $uri2 An URI to compare
|
||||
* @param int $normalizations A bitmask of normalizations to apply, see constants
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-6.1
|
||||
* @return bool
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-6.1
|
||||
*/
|
||||
public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, int $normalizations = self::PRESERVING_NORMALIZATIONS): bool
|
||||
public static function isEquivalent(UriInterface $uri1, UriInterface $uri2, $normalizations = self::PRESERVING_NORMALIZATIONS)
|
||||
{
|
||||
return (string) self::normalize($uri1, $normalizations) === (string) self::normalize($uri2, $normalizations);
|
||||
}
|
||||
|
||||
private static function capitalizePercentEncoding(UriInterface $uri): UriInterface
|
||||
private static function capitalizePercentEncoding(UriInterface $uri)
|
||||
{
|
||||
$regex = '/(?:%[A-Fa-f0-9]{2})++/';
|
||||
|
||||
$callback = function (array $match): string {
|
||||
$callback = function (array $match) {
|
||||
return strtoupper($match[0]);
|
||||
};
|
||||
|
||||
@@ -197,11 +196,11 @@ final class UriNormalizer
|
||||
);
|
||||
}
|
||||
|
||||
private static function decodeUnreservedCharacters(UriInterface $uri): UriInterface
|
||||
private static function decodeUnreservedCharacters(UriInterface $uri)
|
||||
{
|
||||
$regex = '/%(?:2D|2E|5F|7E|3[0-9]|[46][1-9A-F]|[57][0-9A])/i';
|
||||
|
||||
$callback = function (array $match): string {
|
||||
$callback = function (array $match) {
|
||||
return rawurldecode($match[0]);
|
||||
};
|
||||
|
||||
|
||||
43
vendor/guzzlehttp/psr7/src/UriResolver.php
vendored
43
vendor/guzzlehttp/psr7/src/UriResolver.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\UriInterface;
|
||||
@@ -11,16 +9,20 @@ use Psr\Http\Message\UriInterface;
|
||||
*
|
||||
* @author Tobias Schultze
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5
|
||||
* @link https://tools.ietf.org/html/rfc3986#section-5
|
||||
*/
|
||||
final class UriResolver
|
||||
{
|
||||
/**
|
||||
* Removes dot segments from a path and returns the new path.
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
|
||||
* @param string $path
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc3986#section-5.2.4
|
||||
*/
|
||||
public static function removeDotSegments(string $path): string
|
||||
public static function removeDotSegments($path)
|
||||
{
|
||||
if ($path === '' || $path === '/') {
|
||||
return $path;
|
||||
@@ -40,7 +42,7 @@ final class UriResolver
|
||||
|
||||
if ($path[0] === '/' && (!isset($newPath[0]) || $newPath[0] !== '/')) {
|
||||
// Re-add the leading slash if necessary for cases like "/.."
|
||||
$newPath = '/'.$newPath;
|
||||
$newPath = '/' . $newPath;
|
||||
} elseif ($newPath !== '' && ($segment === '.' || $segment === '..')) {
|
||||
// Add the trailing slash if necessary
|
||||
// If newPath is not empty, then $segment must be set and is the last segment from the foreach
|
||||
@@ -53,9 +55,14 @@ final class UriResolver
|
||||
/**
|
||||
* Converts the relative URI into a new URI that is resolved against the base URI.
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2
|
||||
* @param UriInterface $base Base URI
|
||||
* @param UriInterface $rel Relative URI
|
||||
*
|
||||
* @return UriInterface
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc3986#section-5.2
|
||||
*/
|
||||
public static function resolve(UriInterface $base, UriInterface $rel): UriInterface
|
||||
public static function resolve(UriInterface $base, UriInterface $rel)
|
||||
{
|
||||
if ((string) $rel === '') {
|
||||
// we can simply return the same base URI instance for this same-document reference
|
||||
@@ -80,13 +87,13 @@ final class UriResolver
|
||||
$targetPath = $rel->getPath();
|
||||
} else {
|
||||
if ($targetAuthority != '' && $base->getPath() === '') {
|
||||
$targetPath = '/'.$rel->getPath();
|
||||
$targetPath = '/' . $rel->getPath();
|
||||
} else {
|
||||
$lastSlashPos = strrpos($base->getPath(), '/');
|
||||
if ($lastSlashPos === false) {
|
||||
$targetPath = $rel->getPath();
|
||||
} else {
|
||||
$targetPath = substr($base->getPath(), 0, $lastSlashPos + 1).$rel->getPath();
|
||||
$targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,11 +131,16 @@ final class UriResolver
|
||||
* relative-path reference will be returned as-is.
|
||||
*
|
||||
* echo UriResolver::relativize($base, new Uri('/a/b/c')); // prints 'c' as well
|
||||
*
|
||||
* @param UriInterface $base Base URI
|
||||
* @param UriInterface $target Target URI
|
||||
*
|
||||
* @return UriInterface The relative URI reference
|
||||
*/
|
||||
public static function relativize(UriInterface $base, UriInterface $target): UriInterface
|
||||
public static function relativize(UriInterface $base, UriInterface $target)
|
||||
{
|
||||
if ($target->getScheme() !== ''
|
||||
&& ($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '')
|
||||
if ($target->getScheme() !== '' &&
|
||||
($base->getScheme() !== $target->getScheme() || $target->getAuthority() === '' && $base->getAuthority() !== '')
|
||||
) {
|
||||
return $target;
|
||||
}
|
||||
@@ -162,7 +174,6 @@ final class UriResolver
|
||||
// inherit the base query component when resolving.
|
||||
if ($target->getQuery() === '') {
|
||||
$segments = explode('/', $target->getPath());
|
||||
/** @var string $lastSegment */
|
||||
$lastSegment = end($segments);
|
||||
|
||||
return $emptyPathUri->withPath($lastSegment === '' ? './' : $lastSegment);
|
||||
@@ -171,7 +182,7 @@ final class UriResolver
|
||||
return $emptyPathUri;
|
||||
}
|
||||
|
||||
private static function getRelativePath(UriInterface $base, UriInterface $target): string
|
||||
private static function getRelativePath(UriInterface $base, UriInterface $target)
|
||||
{
|
||||
$sourceSegments = explode('/', $base->getPath());
|
||||
$targetSegments = explode('/', $target->getPath());
|
||||
@@ -185,7 +196,7 @@ final class UriResolver
|
||||
}
|
||||
}
|
||||
$targetSegments[] = $targetLastSegment;
|
||||
$relativePath = str_repeat('../', count($sourceSegments)).implode('/', $targetSegments);
|
||||
$relativePath = str_repeat('../', count($sourceSegments)) . implode('/', $targetSegments);
|
||||
|
||||
// A reference to am empty last segment or an empty first sub-segment must be prefixed with "./".
|
||||
// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
|
||||
|
||||
141
vendor/guzzlehttp/psr7/src/Utils.php
vendored
141
vendor/guzzlehttp/psr7/src/Utils.php
vendored
@@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
@@ -14,18 +12,20 @@ final class Utils
|
||||
/**
|
||||
* Remove the items given by the keys, case insensitively from the data.
|
||||
*
|
||||
* @param (string|int)[] $keys
|
||||
* @param iterable<string> $keys
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function caselessRemove(array $keys, array $data): array
|
||||
public static function caselessRemove($keys, array $data)
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($keys as &$key) {
|
||||
$key = strtolower((string) $key);
|
||||
$key = strtolower($key);
|
||||
}
|
||||
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array(strtolower((string) $k), $keys)) {
|
||||
if (!in_array(strtolower($k), $keys)) {
|
||||
$result[$k] = $v;
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ final class Utils
|
||||
*
|
||||
* @throws \RuntimeException on error.
|
||||
*/
|
||||
public static function copyToStream(StreamInterface $source, StreamInterface $dest, int $maxLen = -1): void
|
||||
public static function copyToStream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)
|
||||
{
|
||||
$bufferSize = 8192;
|
||||
|
||||
@@ -76,28 +76,31 @@ final class Utils
|
||||
* @param int $maxLen Maximum number of bytes to read. Pass -1
|
||||
* to read the entire stream.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \RuntimeException on error.
|
||||
*/
|
||||
public static function copyToString(StreamInterface $stream, int $maxLen = -1): string
|
||||
public static function copyToString(StreamInterface $stream, $maxLen = -1)
|
||||
{
|
||||
$buffer = '';
|
||||
|
||||
if ($maxLen === -1) {
|
||||
while (!$stream->eof()) {
|
||||
$buf = $stream->read(1048576);
|
||||
if ($buf === '') {
|
||||
// Using a loose equality here to match on '' and false.
|
||||
if ($buf == null) {
|
||||
break;
|
||||
}
|
||||
$buffer .= $buf;
|
||||
}
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
|
||||
$len = 0;
|
||||
while (!$stream->eof() && $len < $maxLen) {
|
||||
$buf = $stream->read($maxLen - $len);
|
||||
if ($buf === '') {
|
||||
// Using a loose equality here to match on '' and false.
|
||||
if ($buf == null) {
|
||||
break;
|
||||
}
|
||||
$buffer .= $buf;
|
||||
@@ -117,9 +120,11 @@ final class Utils
|
||||
* @param string $algo Hash algorithm (e.g. md5, crc32, etc)
|
||||
* @param bool $rawOutput Whether or not to use raw output
|
||||
*
|
||||
* @return string Returns the hash of the stream
|
||||
*
|
||||
* @throws \RuntimeException on error.
|
||||
*/
|
||||
public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): string
|
||||
public static function hash(StreamInterface $stream, $algo, $rawOutput = false)
|
||||
{
|
||||
$pos = $stream->tell();
|
||||
|
||||
@@ -132,7 +137,7 @@ final class Utils
|
||||
hash_update($ctx, $stream->read(1048576));
|
||||
}
|
||||
|
||||
$out = hash_final($ctx, $rawOutput);
|
||||
$out = hash_final($ctx, (bool) $rawOutput);
|
||||
$stream->seek($pos);
|
||||
|
||||
return $out;
|
||||
@@ -155,8 +160,10 @@ final class Utils
|
||||
*
|
||||
* @param RequestInterface $request Request to clone and modify.
|
||||
* @param array $changes Changes to apply.
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public static function modifyRequest(RequestInterface $request, array $changes): RequestInterface
|
||||
public static function modifyRequest(RequestInterface $request, array $changes)
|
||||
{
|
||||
if (!$changes) {
|
||||
return $request;
|
||||
@@ -175,7 +182,7 @@ final class Utils
|
||||
$standardPorts = ['http' => 80, 'https' => 443];
|
||||
$scheme = $changes['uri']->getScheme();
|
||||
if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) {
|
||||
$changes['set_headers']['Host'] .= ':'.$port;
|
||||
$changes['set_headers']['Host'] .= ':' . $port;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,11 +204,13 @@ final class Utils
|
||||
|
||||
if ($request instanceof ServerRequestInterface) {
|
||||
$new = (new ServerRequest(
|
||||
$changes['method'] ?? $request->getMethod(),
|
||||
isset($changes['method']) ? $changes['method'] : $request->getMethod(),
|
||||
$uri,
|
||||
$headers,
|
||||
$changes['body'] ?? $request->getBody(),
|
||||
$changes['version'] ?? $request->getProtocolVersion(),
|
||||
isset($changes['body']) ? $changes['body'] : $request->getBody(),
|
||||
isset($changes['version'])
|
||||
? $changes['version']
|
||||
: $request->getProtocolVersion(),
|
||||
$request->getServerParams()
|
||||
))
|
||||
->withParsedBody($request->getParsedBody())
|
||||
@@ -217,11 +226,13 @@ final class Utils
|
||||
}
|
||||
|
||||
return new Request(
|
||||
$changes['method'] ?? $request->getMethod(),
|
||||
isset($changes['method']) ? $changes['method'] : $request->getMethod(),
|
||||
$uri,
|
||||
$headers,
|
||||
$changes['body'] ?? $request->getBody(),
|
||||
$changes['version'] ?? $request->getProtocolVersion()
|
||||
isset($changes['body']) ? $changes['body'] : $request->getBody(),
|
||||
isset($changes['version'])
|
||||
? $changes['version']
|
||||
: $request->getProtocolVersion()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -230,14 +241,17 @@ final class Utils
|
||||
*
|
||||
* @param StreamInterface $stream Stream to read from
|
||||
* @param int|null $maxLength Maximum buffer length
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function readLine(StreamInterface $stream, int $maxLength = null): string
|
||||
public static function readLine(StreamInterface $stream, $maxLength = null)
|
||||
{
|
||||
$buffer = '';
|
||||
$size = 0;
|
||||
|
||||
while (!$stream->eof()) {
|
||||
if ('' === ($byte = $stream->read(1))) {
|
||||
// Using a loose equality here to match on '' and false.
|
||||
if (null == ($byte = $stream->read(1))) {
|
||||
return $buffer;
|
||||
}
|
||||
$buffer .= $byte;
|
||||
@@ -280,19 +294,20 @@ final class Utils
|
||||
* buffered and used in subsequent reads.
|
||||
*
|
||||
* @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data
|
||||
* @param array{size?: int, metadata?: array} $options Additional options
|
||||
* @param array $options Additional options
|
||||
*
|
||||
* @return StreamInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException if the $resource arg is not valid.
|
||||
*/
|
||||
public static function streamFor($resource = '', array $options = []): StreamInterface
|
||||
public static function streamFor($resource = '', array $options = [])
|
||||
{
|
||||
if (is_scalar($resource)) {
|
||||
$stream = self::tryFopen('php://temp', 'r+');
|
||||
if ($resource !== '') {
|
||||
fwrite($stream, (string) $resource);
|
||||
fwrite($stream, $resource);
|
||||
fseek($stream, 0);
|
||||
}
|
||||
|
||||
return new Stream($stream, $options);
|
||||
}
|
||||
|
||||
@@ -302,18 +317,15 @@ final class Utils
|
||||
* The 'php://input' is a special stream with quirks and inconsistencies.
|
||||
* We avoid using that stream by reading it into php://temp
|
||||
*/
|
||||
|
||||
/** @var resource $resource */
|
||||
if ((\stream_get_meta_data($resource)['uri'] ?? '') === 'php://input') {
|
||||
$metaData = \stream_get_meta_data($resource);
|
||||
if (isset($metaData['uri']) && $metaData['uri'] === 'php://input') {
|
||||
$stream = self::tryFopen('php://temp', 'w+');
|
||||
stream_copy_to_stream($resource, $stream);
|
||||
fwrite($stream, stream_get_contents($resource));
|
||||
fseek($stream, 0);
|
||||
$resource = $stream;
|
||||
}
|
||||
|
||||
return new Stream($resource, $options);
|
||||
case 'object':
|
||||
/** @var object $resource */
|
||||
if ($resource instanceof StreamInterface) {
|
||||
return $resource;
|
||||
} elseif ($resource instanceof \Iterator) {
|
||||
@@ -323,11 +335,10 @@ final class Utils
|
||||
}
|
||||
$result = $resource->current();
|
||||
$resource->next();
|
||||
|
||||
return $result;
|
||||
}, $options);
|
||||
} elseif (method_exists($resource, '__toString')) {
|
||||
return self::streamFor((string) $resource, $options);
|
||||
return Utils::streamFor((string) $resource, $options);
|
||||
}
|
||||
break;
|
||||
case 'NULL':
|
||||
@@ -338,7 +349,7 @@ final class Utils
|
||||
return new PumpStream($resource, $options);
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Invalid resource type: '.gettype($resource));
|
||||
throw new \InvalidArgumentException('Invalid resource type: ' . gettype($resource));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,22 +365,21 @@ final class Utils
|
||||
*
|
||||
* @throws \RuntimeException if the file cannot be opened
|
||||
*/
|
||||
public static function tryFopen(string $filename, string $mode)
|
||||
public static function tryFopen($filename, $mode)
|
||||
{
|
||||
$ex = null;
|
||||
set_error_handler(static function (int $errno, string $errstr) use ($filename, $mode, &$ex): bool {
|
||||
set_error_handler(function () use ($filename, $mode, &$ex) {
|
||||
$ex = new \RuntimeException(sprintf(
|
||||
'Unable to open "%s" using mode "%s": %s',
|
||||
$filename,
|
||||
$mode,
|
||||
$errstr
|
||||
func_get_args()[1]
|
||||
));
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
try {
|
||||
/** @var resource $handle */
|
||||
$handle = fopen($filename, $mode);
|
||||
} catch (\Throwable $e) {
|
||||
$ex = new \RuntimeException(sprintf(
|
||||
@@ -390,53 +400,6 @@ final class Utils
|
||||
return $handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely gets the contents of a given stream.
|
||||
*
|
||||
* When stream_get_contents fails, PHP normally raises a warning. This
|
||||
* function adds an error handler that checks for errors and throws an
|
||||
* exception instead.
|
||||
*
|
||||
* @param resource $stream
|
||||
*
|
||||
* @throws \RuntimeException if the stream cannot be read
|
||||
*/
|
||||
public static function tryGetContents($stream): string
|
||||
{
|
||||
$ex = null;
|
||||
set_error_handler(static function (int $errno, string $errstr) use (&$ex): bool {
|
||||
$ex = new \RuntimeException(sprintf(
|
||||
'Unable to read stream contents: %s',
|
||||
$errstr
|
||||
));
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
try {
|
||||
/** @var string|false $contents */
|
||||
$contents = stream_get_contents($stream);
|
||||
|
||||
if ($contents === false) {
|
||||
$ex = new \RuntimeException('Unable to read stream contents');
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$ex = new \RuntimeException(sprintf(
|
||||
'Unable to read stream contents: %s',
|
||||
$e->getMessage()
|
||||
), 0, $e);
|
||||
}
|
||||
|
||||
restore_error_handler();
|
||||
|
||||
if ($ex) {
|
||||
/** @var $ex \RuntimeException */
|
||||
throw $ex;
|
||||
}
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a UriInterface for the given value.
|
||||
*
|
||||
@@ -446,9 +409,11 @@ final class Utils
|
||||
*
|
||||
* @param string|UriInterface $uri
|
||||
*
|
||||
* @return UriInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function uriFor($uri): UriInterface
|
||||
public static function uriFor($uri)
|
||||
{
|
||||
if ($uri instanceof UriInterface) {
|
||||
return $uri;
|
||||
|
||||
422
vendor/guzzlehttp/psr7/src/functions.php
vendored
Normal file
422
vendor/guzzlehttp/psr7/src/functions.php
vendored
Normal file
@@ -0,0 +1,422 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Psr7;
|
||||
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* Returns the string representation of an HTTP message.
|
||||
*
|
||||
* @param MessageInterface $message Message to convert to a string.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @deprecated str will be removed in guzzlehttp/psr7:2.0. Use Message::toString instead.
|
||||
*/
|
||||
function str(MessageInterface $message)
|
||||
{
|
||||
return Message::toString($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a UriInterface for the given value.
|
||||
*
|
||||
* This function accepts a string or UriInterface and returns a
|
||||
* UriInterface for the given value. If the value is already a
|
||||
* UriInterface, it is returned as-is.
|
||||
*
|
||||
* @param string|UriInterface $uri
|
||||
*
|
||||
* @return UriInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @deprecated uri_for will be removed in guzzlehttp/psr7:2.0. Use Utils::uriFor instead.
|
||||
*/
|
||||
function uri_for($uri)
|
||||
{
|
||||
return Utils::uriFor($uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new stream based on the input type.
|
||||
*
|
||||
* Options is an associative array that can contain the following keys:
|
||||
* - metadata: Array of custom metadata.
|
||||
* - size: Size of the stream.
|
||||
*
|
||||
* This method accepts the following `$resource` types:
|
||||
* - `Psr\Http\Message\StreamInterface`: Returns the value as-is.
|
||||
* - `string`: Creates a stream object that uses the given string as the contents.
|
||||
* - `resource`: Creates a stream object that wraps the given PHP stream resource.
|
||||
* - `Iterator`: If the provided value implements `Iterator`, then a read-only
|
||||
* stream object will be created that wraps the given iterable. Each time the
|
||||
* stream is read from, data from the iterator will fill a buffer and will be
|
||||
* continuously called until the buffer is equal to the requested read size.
|
||||
* Subsequent read calls will first read from the buffer and then call `next`
|
||||
* on the underlying iterator until it is exhausted.
|
||||
* - `object` with `__toString()`: If the object has the `__toString()` method,
|
||||
* the object will be cast to a string and then a stream will be returned that
|
||||
* uses the string value.
|
||||
* - `NULL`: When `null` is passed, an empty stream object is returned.
|
||||
* - `callable` When a callable is passed, a read-only stream object will be
|
||||
* created that invokes the given callable. The callable is invoked with the
|
||||
* number of suggested bytes to read. The callable can return any number of
|
||||
* bytes, but MUST return `false` when there is no more data to return. The
|
||||
* stream object that wraps the callable will invoke the callable until the
|
||||
* number of requested bytes are available. Any additional bytes will be
|
||||
* buffered and used in subsequent reads.
|
||||
*
|
||||
* @param resource|string|int|float|bool|StreamInterface|callable|\Iterator|null $resource Entity body data
|
||||
* @param array $options Additional options
|
||||
*
|
||||
* @return StreamInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException if the $resource arg is not valid.
|
||||
*
|
||||
* @deprecated stream_for will be removed in guzzlehttp/psr7:2.0. Use Utils::streamFor instead.
|
||||
*/
|
||||
function stream_for($resource = '', array $options = [])
|
||||
{
|
||||
return Utils::streamFor($resource, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an array of header values containing ";" separated data into an
|
||||
* array of associative arrays representing the header key value pair data
|
||||
* of the header. When a parameter does not contain a value, but just
|
||||
* contains a key, this function will inject a key with a '' string value.
|
||||
*
|
||||
* @param string|array $header Header to parse into components.
|
||||
*
|
||||
* @return array Returns the parsed header values.
|
||||
*
|
||||
* @deprecated parse_header will be removed in guzzlehttp/psr7:2.0. Use Header::parse instead.
|
||||
*/
|
||||
function parse_header($header)
|
||||
{
|
||||
return Header::parse($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an array of header values that may contain comma separated
|
||||
* headers into an array of headers with no comma separated values.
|
||||
*
|
||||
* @param string|array $header Header to normalize.
|
||||
*
|
||||
* @return array Returns the normalized header field values.
|
||||
*
|
||||
* @deprecated normalize_header will be removed in guzzlehttp/psr7:2.0. Use Header::normalize instead.
|
||||
*/
|
||||
function normalize_header($header)
|
||||
{
|
||||
return Header::normalize($header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone and modify a request with the given changes.
|
||||
*
|
||||
* This method is useful for reducing the number of clones needed to mutate a
|
||||
* message.
|
||||
*
|
||||
* The changes can be one of:
|
||||
* - method: (string) Changes the HTTP method.
|
||||
* - set_headers: (array) Sets the given headers.
|
||||
* - remove_headers: (array) Remove the given headers.
|
||||
* - body: (mixed) Sets the given body.
|
||||
* - uri: (UriInterface) Set the URI.
|
||||
* - query: (string) Set the query string value of the URI.
|
||||
* - version: (string) Set the protocol version.
|
||||
*
|
||||
* @param RequestInterface $request Request to clone and modify.
|
||||
* @param array $changes Changes to apply.
|
||||
*
|
||||
* @return RequestInterface
|
||||
*
|
||||
* @deprecated modify_request will be removed in guzzlehttp/psr7:2.0. Use Utils::modifyRequest instead.
|
||||
*/
|
||||
function modify_request(RequestInterface $request, array $changes)
|
||||
{
|
||||
return Utils::modifyRequest($request, $changes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to rewind a message body and throws an exception on failure.
|
||||
*
|
||||
* The body of the message will only be rewound if a call to `tell()` returns a
|
||||
* value other than `0`.
|
||||
*
|
||||
* @param MessageInterface $message Message to rewind
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*
|
||||
* @deprecated rewind_body will be removed in guzzlehttp/psr7:2.0. Use Message::rewindBody instead.
|
||||
*/
|
||||
function rewind_body(MessageInterface $message)
|
||||
{
|
||||
Message::rewindBody($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely opens a PHP stream resource using a filename.
|
||||
*
|
||||
* When fopen fails, PHP normally raises a warning. This function adds an
|
||||
* error handler that checks for errors and throws an exception instead.
|
||||
*
|
||||
* @param string $filename File to open
|
||||
* @param string $mode Mode used to open the file
|
||||
*
|
||||
* @return resource
|
||||
*
|
||||
* @throws \RuntimeException if the file cannot be opened
|
||||
*
|
||||
* @deprecated try_fopen will be removed in guzzlehttp/psr7:2.0. Use Utils::tryFopen instead.
|
||||
*/
|
||||
function try_fopen($filename, $mode)
|
||||
{
|
||||
return Utils::tryFopen($filename, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the contents of a stream into a string until the given number of
|
||||
* bytes have been read.
|
||||
*
|
||||
* @param StreamInterface $stream Stream to read
|
||||
* @param int $maxLen Maximum number of bytes to read. Pass -1
|
||||
* to read the entire stream.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \RuntimeException on error.
|
||||
*
|
||||
* @deprecated copy_to_string will be removed in guzzlehttp/psr7:2.0. Use Utils::copyToString instead.
|
||||
*/
|
||||
function copy_to_string(StreamInterface $stream, $maxLen = -1)
|
||||
{
|
||||
return Utils::copyToString($stream, $maxLen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the contents of a stream into another stream until the given number
|
||||
* of bytes have been read.
|
||||
*
|
||||
* @param StreamInterface $source Stream to read from
|
||||
* @param StreamInterface $dest Stream to write to
|
||||
* @param int $maxLen Maximum number of bytes to read. Pass -1
|
||||
* to read the entire stream.
|
||||
*
|
||||
* @throws \RuntimeException on error.
|
||||
*
|
||||
* @deprecated copy_to_stream will be removed in guzzlehttp/psr7:2.0. Use Utils::copyToStream instead.
|
||||
*/
|
||||
function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)
|
||||
{
|
||||
return Utils::copyToStream($source, $dest, $maxLen);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate a hash of a stream.
|
||||
*
|
||||
* This method reads the entire stream to calculate a rolling hash, based on
|
||||
* PHP's `hash_init` functions.
|
||||
*
|
||||
* @param StreamInterface $stream Stream to calculate the hash for
|
||||
* @param string $algo Hash algorithm (e.g. md5, crc32, etc)
|
||||
* @param bool $rawOutput Whether or not to use raw output
|
||||
*
|
||||
* @return string Returns the hash of the stream
|
||||
*
|
||||
* @throws \RuntimeException on error.
|
||||
*
|
||||
* @deprecated hash will be removed in guzzlehttp/psr7:2.0. Use Utils::hash instead.
|
||||
*/
|
||||
function hash(StreamInterface $stream, $algo, $rawOutput = false)
|
||||
{
|
||||
return Utils::hash($stream, $algo, $rawOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a line from the stream up to the maximum allowed buffer length.
|
||||
*
|
||||
* @param StreamInterface $stream Stream to read from
|
||||
* @param int|null $maxLength Maximum buffer length
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @deprecated readline will be removed in guzzlehttp/psr7:2.0. Use Utils::readLine instead.
|
||||
*/
|
||||
function readline(StreamInterface $stream, $maxLength = null)
|
||||
{
|
||||
return Utils::readLine($stream, $maxLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a request message string into a request object.
|
||||
*
|
||||
* @param string $message Request message string.
|
||||
*
|
||||
* @return Request
|
||||
*
|
||||
* @deprecated parse_request will be removed in guzzlehttp/psr7:2.0. Use Message::parseRequest instead.
|
||||
*/
|
||||
function parse_request($message)
|
||||
{
|
||||
return Message::parseRequest($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a response message string into a response object.
|
||||
*
|
||||
* @param string $message Response message string.
|
||||
*
|
||||
* @return Response
|
||||
*
|
||||
* @deprecated parse_response will be removed in guzzlehttp/psr7:2.0. Use Message::parseResponse instead.
|
||||
*/
|
||||
function parse_response($message)
|
||||
{
|
||||
return Message::parseResponse($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a query string into an associative array.
|
||||
*
|
||||
* If multiple values are found for the same key, the value of that key value
|
||||
* pair will become an array. This function does not parse nested PHP style
|
||||
* arrays into an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed
|
||||
* into `['foo[a]' => '1', 'foo[b]' => '2'])`.
|
||||
*
|
||||
* @param string $str Query string to parse
|
||||
* @param int|bool $urlEncoding How the query string is encoded
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @deprecated parse_query will be removed in guzzlehttp/psr7:2.0. Use Query::parse instead.
|
||||
*/
|
||||
function parse_query($str, $urlEncoding = true)
|
||||
{
|
||||
return Query::parse($str, $urlEncoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a query string from an array of key value pairs.
|
||||
*
|
||||
* This function can use the return value of `parse_query()` to build a query
|
||||
* string. This function does not modify the provided keys when an array is
|
||||
* encountered (like `http_build_query()` would).
|
||||
*
|
||||
* @param array $params Query string parameters.
|
||||
* @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986
|
||||
* to encode using RFC3986, or PHP_QUERY_RFC1738
|
||||
* to encode using RFC1738.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @deprecated build_query will be removed in guzzlehttp/psr7:2.0. Use Query::build instead.
|
||||
*/
|
||||
function build_query(array $params, $encoding = PHP_QUERY_RFC3986)
|
||||
{
|
||||
return Query::build($params, $encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the mimetype of a file by looking at its extension.
|
||||
*
|
||||
* @param string $filename
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @deprecated mimetype_from_filename will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromFilename instead.
|
||||
*/
|
||||
function mimetype_from_filename($filename)
|
||||
{
|
||||
return MimeType::fromFilename($filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps a file extensions to a mimetype.
|
||||
*
|
||||
* @param $extension string The file extension.
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types
|
||||
* @deprecated mimetype_from_extension will be removed in guzzlehttp/psr7:2.0. Use MimeType::fromExtension instead.
|
||||
*/
|
||||
function mimetype_from_extension($extension)
|
||||
{
|
||||
return MimeType::fromExtension($extension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses an HTTP message into an associative array.
|
||||
*
|
||||
* The array contains the "start-line" key containing the start line of
|
||||
* the message, "headers" key containing an associative array of header
|
||||
* array values, and a "body" key containing the body of the message.
|
||||
*
|
||||
* @param string $message HTTP request or response to parse.
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @deprecated _parse_message will be removed in guzzlehttp/psr7:2.0. Use Message::parseMessage instead.
|
||||
*/
|
||||
function _parse_message($message)
|
||||
{
|
||||
return Message::parseMessage($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a URI for an HTTP request message.
|
||||
*
|
||||
* @param string $path Path from the start-line
|
||||
* @param array $headers Array of headers (each value an array).
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @deprecated _parse_request_uri will be removed in guzzlehttp/psr7:2.0. Use Message::parseRequestUri instead.
|
||||
*/
|
||||
function _parse_request_uri($path, array $headers)
|
||||
{
|
||||
return Message::parseRequestUri($path, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a short summary of the message body.
|
||||
*
|
||||
* Will return `null` if the response is not printable.
|
||||
*
|
||||
* @param MessageInterface $message The message to get the body summary
|
||||
* @param int $truncateAt The maximum allowed size of the summary
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @deprecated get_message_body_summary will be removed in guzzlehttp/psr7:2.0. Use Message::bodySummary instead.
|
||||
*/
|
||||
function get_message_body_summary(MessageInterface $message, $truncateAt = 120)
|
||||
{
|
||||
return Message::bodySummary($message, $truncateAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the items given by the keys, case insensitively from the data.
|
||||
*
|
||||
* @param iterable<string> $keys
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @internal
|
||||
*
|
||||
* @deprecated _caseless_remove will be removed in guzzlehttp/psr7:2.0. Use Utils::caselessRemove instead.
|
||||
*/
|
||||
function _caseless_remove($keys, array $data)
|
||||
{
|
||||
return Utils::caselessRemove($keys, $data);
|
||||
}
|
||||
6
vendor/guzzlehttp/psr7/src/functions_include.php
vendored
Normal file
6
vendor/guzzlehttp/psr7/src/functions_include.php
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
// Don't redefine the functions if included multiple times.
|
||||
if (!function_exists('GuzzleHttp\Psr7\str')) {
|
||||
require __DIR__ . '/functions.php';
|
||||
}
|
||||
Reference in New Issue
Block a user