代码同步
This commit is contained in:
31
Server/vendor/psr/http-client/CHANGELOG.md
vendored
Normal file
31
Server/vendor/psr/http-client/CHANGELOG.md
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file, in reverse chronological order by release.
|
||||
|
||||
## 1.0.3
|
||||
|
||||
Add `source` link in composer.json. No code changes.
|
||||
|
||||
## 1.0.2
|
||||
|
||||
Allow PSR-7 (psr/http-message) 2.0. No code changes.
|
||||
|
||||
## 1.0.1
|
||||
|
||||
Allow installation with PHP 8. No code changes.
|
||||
|
||||
## 1.0.0
|
||||
|
||||
First stable release. No changes since 0.3.0.
|
||||
|
||||
## 0.3.0
|
||||
|
||||
Added Interface suffix on exceptions
|
||||
|
||||
## 0.2.0
|
||||
|
||||
All exceptions are in `Psr\Http\Client` namespace
|
||||
|
||||
## 0.1.0
|
||||
|
||||
First release
|
||||
19
Server/vendor/psr/http-client/LICENSE
vendored
Normal file
19
Server/vendor/psr/http-client/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2017 PHP Framework Interoperability Group
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
12
Server/vendor/psr/http-client/README.md
vendored
Normal file
12
Server/vendor/psr/http-client/README.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
HTTP Client
|
||||
===========
|
||||
|
||||
This repository holds all the common code related to [PSR-18 (HTTP Client)][psr-url].
|
||||
|
||||
Note that this is not a HTTP Client implementation of its own. It is merely abstractions that describe the components of a HTTP Client.
|
||||
|
||||
The installable [package][package-url] and [implementations][implementation-url] are listed on Packagist.
|
||||
|
||||
[psr-url]: https://www.php-fig.org/psr/psr-18
|
||||
[package-url]: https://packagist.org/packages/psr/http-client
|
||||
[implementation-url]: https://packagist.org/providers/psr/http-client-implementation
|
||||
30
Server/vendor/psr/http-client/composer.json
vendored
Normal file
30
Server/vendor/psr/http-client/composer.json
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "psr/http-client",
|
||||
"description": "Common interface for HTTP clients",
|
||||
"keywords": ["psr", "psr-18", "http", "http-client"],
|
||||
"homepage": "https://github.com/php-fig/http-client",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/php-fig/http-client"
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.0 || ^8.0",
|
||||
"psr/http-message": "^1.0 || ^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Http\\Client\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Server/vendor/psr/http-client/src/ClientExceptionInterface.php
vendored
Normal file
10
Server/vendor/psr/http-client/src/ClientExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Client;
|
||||
|
||||
/**
|
||||
* Every HTTP client related exception MUST implement this interface.
|
||||
*/
|
||||
interface ClientExceptionInterface extends \Throwable
|
||||
{
|
||||
}
|
||||
20
Server/vendor/psr/http-client/src/ClientInterface.php
vendored
Normal file
20
Server/vendor/psr/http-client/src/ClientInterface.php
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Client;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
interface ClientInterface
|
||||
{
|
||||
/**
|
||||
* Sends a PSR-7 request and returns a PSR-7 response.
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*
|
||||
* @throws \Psr\Http\Client\ClientExceptionInterface If an error happens while processing the request.
|
||||
*/
|
||||
public function sendRequest(RequestInterface $request): ResponseInterface;
|
||||
}
|
||||
24
Server/vendor/psr/http-client/src/NetworkExceptionInterface.php
vendored
Normal file
24
Server/vendor/psr/http-client/src/NetworkExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Client;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Thrown when the request cannot be completed because of network issues.
|
||||
*
|
||||
* There is no response object as this exception is thrown when no response has been received.
|
||||
*
|
||||
* Example: the target host name can not be resolved or the connection failed.
|
||||
*/
|
||||
interface NetworkExceptionInterface extends ClientExceptionInterface
|
||||
{
|
||||
/**
|
||||
* Returns the request.
|
||||
*
|
||||
* The request object MAY be a different object from the one passed to ClientInterface::sendRequest()
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function getRequest(): RequestInterface;
|
||||
}
|
||||
24
Server/vendor/psr/http-client/src/RequestExceptionInterface.php
vendored
Normal file
24
Server/vendor/psr/http-client/src/RequestExceptionInterface.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Client;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Exception for when a request failed.
|
||||
*
|
||||
* Examples:
|
||||
* - Request is invalid (e.g. method is missing)
|
||||
* - Runtime request errors (e.g. the body stream is not seekable)
|
||||
*/
|
||||
interface RequestExceptionInterface extends ClientExceptionInterface
|
||||
{
|
||||
/**
|
||||
* Returns the request.
|
||||
*
|
||||
* The request object MAY be a different object from the one passed to ClientInterface::sendRequest()
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function getRequest(): RequestInterface;
|
||||
}
|
||||
21
Server/vendor/psr/http-factory/LICENSE
vendored
Normal file
21
Server/vendor/psr/http-factory/LICENSE
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 PHP-FIG
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
12
Server/vendor/psr/http-factory/README.md
vendored
Normal file
12
Server/vendor/psr/http-factory/README.md
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
HTTP Factories
|
||||
==============
|
||||
|
||||
This repository holds all interfaces related to [PSR-17 (HTTP Factories)][psr-url].
|
||||
|
||||
Note that this is not a HTTP Factory implementation of its own. It is merely interfaces that describe the components of a HTTP Factory.
|
||||
|
||||
The installable [package][package-url] and [implementations][implementation-url] are listed on Packagist.
|
||||
|
||||
[psr-url]: https://www.php-fig.org/psr/psr-17/
|
||||
[package-url]: https://packagist.org/packages/psr/http-factory
|
||||
[implementation-url]: https://packagist.org/providers/psr/http-factory-implementation
|
||||
35
Server/vendor/psr/http-factory/composer.json
vendored
Normal file
35
Server/vendor/psr/http-factory/composer.json
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "psr/http-factory",
|
||||
"description": "Common interfaces for PSR-7 HTTP message factories",
|
||||
"keywords": [
|
||||
"psr",
|
||||
"psr-7",
|
||||
"psr-17",
|
||||
"http",
|
||||
"factory",
|
||||
"message",
|
||||
"request",
|
||||
"response"
|
||||
],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.0.0",
|
||||
"psr/http-message": "^1.0 || ^2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Http\\Message\\": "src/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Server/vendor/psr/http-factory/src/RequestFactoryInterface.php
vendored
Normal file
18
Server/vendor/psr/http-factory/src/RequestFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Message;
|
||||
|
||||
interface RequestFactoryInterface
|
||||
{
|
||||
/**
|
||||
* Create a new request.
|
||||
*
|
||||
* @param string $method The HTTP method associated with the request.
|
||||
* @param UriInterface|string $uri The URI associated with the request. If
|
||||
* the value is a string, the factory MUST create a UriInterface
|
||||
* instance based on it.
|
||||
*
|
||||
* @return RequestInterface
|
||||
*/
|
||||
public function createRequest(string $method, $uri): RequestInterface;
|
||||
}
|
||||
18
Server/vendor/psr/http-factory/src/ResponseFactoryInterface.php
vendored
Normal file
18
Server/vendor/psr/http-factory/src/ResponseFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Message;
|
||||
|
||||
interface ResponseFactoryInterface
|
||||
{
|
||||
/**
|
||||
* Create a new response.
|
||||
*
|
||||
* @param int $code HTTP status code; defaults to 200
|
||||
* @param string $reasonPhrase Reason phrase to associate with status code
|
||||
* in generated response; if none is provided implementations MAY use
|
||||
* the defaults as suggested in the HTTP specification.
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function createResponse(int $code = 200, string $reasonPhrase = ''): ResponseInterface;
|
||||
}
|
||||
24
Server/vendor/psr/http-factory/src/ServerRequestFactoryInterface.php
vendored
Normal file
24
Server/vendor/psr/http-factory/src/ServerRequestFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Message;
|
||||
|
||||
interface ServerRequestFactoryInterface
|
||||
{
|
||||
/**
|
||||
* Create a new server request.
|
||||
*
|
||||
* Note that server-params are taken precisely as given - no parsing/processing
|
||||
* of the given values is performed, and, in particular, no attempt is made to
|
||||
* determine the HTTP method or URI, which must be provided explicitly.
|
||||
*
|
||||
* @param string $method The HTTP method associated with the request.
|
||||
* @param UriInterface|string $uri The URI associated with the request. If
|
||||
* the value is a string, the factory MUST create a UriInterface
|
||||
* instance based on it.
|
||||
* @param array $serverParams Array of SAPI parameters with which to seed
|
||||
* the generated request instance.
|
||||
*
|
||||
* @return ServerRequestInterface
|
||||
*/
|
||||
public function createServerRequest(string $method, $uri, array $serverParams = []): ServerRequestInterface;
|
||||
}
|
||||
45
Server/vendor/psr/http-factory/src/StreamFactoryInterface.php
vendored
Normal file
45
Server/vendor/psr/http-factory/src/StreamFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Message;
|
||||
|
||||
interface StreamFactoryInterface
|
||||
{
|
||||
/**
|
||||
* Create a new stream from a string.
|
||||
*
|
||||
* The stream SHOULD be created with a temporary resource.
|
||||
*
|
||||
* @param string $content String content with which to populate the stream.
|
||||
*
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function createStream(string $content = ''): StreamInterface;
|
||||
|
||||
/**
|
||||
* Create a stream from an existing file.
|
||||
*
|
||||
* The file MUST be opened using the given mode, which may be any mode
|
||||
* supported by the `fopen` function.
|
||||
*
|
||||
* The `$filename` MAY be any string supported by `fopen()`.
|
||||
*
|
||||
* @param string $filename Filename or stream URI to use as basis of stream.
|
||||
* @param string $mode Mode with which to open the underlying filename/stream.
|
||||
*
|
||||
* @return StreamInterface
|
||||
* @throws \RuntimeException If the file cannot be opened.
|
||||
* @throws \InvalidArgumentException If the mode is invalid.
|
||||
*/
|
||||
public function createStreamFromFile(string $filename, string $mode = 'r'): StreamInterface;
|
||||
|
||||
/**
|
||||
* Create a new stream from an existing resource.
|
||||
*
|
||||
* The stream MUST be readable and may be writable.
|
||||
*
|
||||
* @param resource $resource PHP resource to use as basis of stream.
|
||||
*
|
||||
* @return StreamInterface
|
||||
*/
|
||||
public function createStreamFromResource($resource): StreamInterface;
|
||||
}
|
||||
34
Server/vendor/psr/http-factory/src/UploadedFileFactoryInterface.php
vendored
Normal file
34
Server/vendor/psr/http-factory/src/UploadedFileFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Message;
|
||||
|
||||
interface UploadedFileFactoryInterface
|
||||
{
|
||||
/**
|
||||
* Create a new uploaded file.
|
||||
*
|
||||
* If a size is not provided it will be determined by checking the size of
|
||||
* the file.
|
||||
*
|
||||
* @see http://php.net/manual/features.file-upload.post-method.php
|
||||
* @see http://php.net/manual/features.file-upload.errors.php
|
||||
*
|
||||
* @param StreamInterface $stream Underlying stream representing the
|
||||
* uploaded file content.
|
||||
* @param int $size in bytes
|
||||
* @param int $error PHP file upload error
|
||||
* @param string $clientFilename Filename as provided by the client, if any.
|
||||
* @param string $clientMediaType Media type as provided by the client, if any.
|
||||
*
|
||||
* @return UploadedFileInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException If the file resource is not readable.
|
||||
*/
|
||||
public function createUploadedFile(
|
||||
StreamInterface $stream,
|
||||
int $size = null,
|
||||
int $error = \UPLOAD_ERR_OK,
|
||||
string $clientFilename = null,
|
||||
string $clientMediaType = null
|
||||
): UploadedFileInterface;
|
||||
}
|
||||
17
Server/vendor/psr/http-factory/src/UriFactoryInterface.php
vendored
Normal file
17
Server/vendor/psr/http-factory/src/UriFactoryInterface.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Message;
|
||||
|
||||
interface UriFactoryInterface
|
||||
{
|
||||
/**
|
||||
* Create a new URI.
|
||||
*
|
||||
* @param string $uri
|
||||
*
|
||||
* @return UriInterface
|
||||
*
|
||||
* @throws \InvalidArgumentException If the given URI cannot be parsed.
|
||||
*/
|
||||
public function createUri(string $uri = ''): UriInterface;
|
||||
}
|
||||
5
Server/vendor/psr/http-message/README.md
vendored
5
Server/vendor/psr/http-message/README.md
vendored
@@ -10,4 +10,7 @@ interface that describes a HTTP message. See the specification for more details.
|
||||
Usage
|
||||
-----
|
||||
|
||||
We'll certainly need some stuff in here.
|
||||
Before reading the usage guide we recommend reading the PSR-7 interfaces method list:
|
||||
|
||||
* [`PSR-7 Interfaces Method List`](docs/PSR7-Interfaces.md)
|
||||
* [`PSR-7 Usage Guide`](docs/PSR7-Usage.md)
|
||||
6
Server/vendor/psr/http-message/composer.json
vendored
6
Server/vendor/psr/http-message/composer.json
vendored
@@ -7,11 +7,11 @@
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
"php": "^7.2 || ^8.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -20,7 +20,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
130
Server/vendor/psr/http-message/docs/PSR7-Interfaces.md
vendored
Normal file
130
Server/vendor/psr/http-message/docs/PSR7-Interfaces.md
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
# Interfaces
|
||||
|
||||
The purpose of this list is to help in finding the methods when working with PSR-7. This can be considered as a cheatsheet for PSR-7 interfaces.
|
||||
|
||||
The interfaces defined in PSR-7 are the following:
|
||||
|
||||
| Class Name | Description |
|
||||
|---|---|
|
||||
| [Psr\Http\Message\MessageInterface](http://www.php-fig.org/psr/psr-7/#psrhttpmessagemessageinterface) | Representation of a HTTP message |
|
||||
| [Psr\Http\Message\RequestInterface](http://www.php-fig.org/psr/psr-7/#psrhttpmessagerequestinterface) | Representation of an outgoing, client-side request. |
|
||||
| [Psr\Http\Message\ServerRequestInterface](http://www.php-fig.org/psr/psr-7/#psrhttpmessageserverrequestinterface) | Representation of an incoming, server-side HTTP request. |
|
||||
| [Psr\Http\Message\ResponseInterface](http://www.php-fig.org/psr/psr-7/#psrhttpmessageresponseinterface) | Representation of an outgoing, server-side response. |
|
||||
| [Psr\Http\Message\StreamInterface](http://www.php-fig.org/psr/psr-7/#psrhttpmessagestreaminterface) | Describes a data stream |
|
||||
| [Psr\Http\Message\UriInterface](http://www.php-fig.org/psr/psr-7/#psrhttpmessageuriinterface) | Value object representing a URI. |
|
||||
| [Psr\Http\Message\UploadedFileInterface](http://www.php-fig.org/psr/psr-7/#psrhttpmessageuploadedfileinterface) | Value object representing a file uploaded through an HTTP request. |
|
||||
|
||||
## `Psr\Http\Message\MessageInterface` Methods
|
||||
|
||||
| Method Name | Description | Notes |
|
||||
|------------------------------------| ----------- | ----- |
|
||||
| `getProtocolVersion()` | Retrieve HTTP protocol version | 1.0 or 1.1 |
|
||||
| `withProtocolVersion($version)` | Returns new message instance with given HTTP protocol version | |
|
||||
| `getHeaders()` | Retrieve all HTTP Headers | [Request Header List](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields), [Response Header List](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_fields) |
|
||||
| `hasHeader($name)` | Checks if HTTP Header with given name exists | |
|
||||
| `getHeader($name)` | Retrieves a array with the values for a single header | |
|
||||
| `getHeaderLine($name)` | Retrieves a comma-separated string of the values for a single header | |
|
||||
| `withHeader($name, $value)` | Returns new message instance with given HTTP Header | if the header existed in the original instance, replaces the header value from the original message with the value provided when creating the new instance. |
|
||||
| `withAddedHeader($name, $value)` | Returns new message instance with appended value to given header | If header already exists value will be appended, if not a new header will be created |
|
||||
| `withoutHeader($name)` | Removes HTTP Header with given name| |
|
||||
| `getBody()` | Retrieves the HTTP Message Body | Returns object implementing `StreamInterface`|
|
||||
| `withBody(StreamInterface $body)` | Returns new message instance with given HTTP Message Body | |
|
||||
|
||||
|
||||
## `Psr\Http\Message\RequestInterface` Methods
|
||||
|
||||
Same methods as `Psr\Http\Message\MessageInterface` + the following methods:
|
||||
|
||||
| Method Name | Description | Notes |
|
||||
|------------------------------------| ----------- | ----- |
|
||||
| `getRequestTarget()` | Retrieves the message's request target | origin-form, absolute-form, authority-form, asterisk-form ([RFC7230](https://www.rfc-editor.org/rfc/rfc7230.txt)) |
|
||||
| `withRequestTarget($requestTarget)` | Return a new message instance with the specific request-target | |
|
||||
| `getMethod()` | Retrieves the HTTP method of the request. | GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE (defined in [RFC7231](https://tools.ietf.org/html/rfc7231)), PATCH (defined in [RFC5789](https://tools.ietf.org/html/rfc5789)) |
|
||||
| `withMethod($method)` | Returns a new message instance with the provided HTTP method | |
|
||||
| `getUri()` | Retrieves the URI instance | |
|
||||
| `withUri(UriInterface $uri, $preserveHost = false)` | Returns a new message instance with the provided URI | |
|
||||
|
||||
|
||||
## `Psr\Http\Message\ServerRequestInterface` Methods
|
||||
|
||||
Same methods as `Psr\Http\Message\RequestInterface` + the following methods:
|
||||
|
||||
| Method Name | Description | Notes |
|
||||
|------------------------------------| ----------- | ----- |
|
||||
| `getServerParams() ` | Retrieve server parameters | Typically derived from `$_SERVER` |
|
||||
| `getCookieParams()` | Retrieves cookies sent by the client to the server. | Typically derived from `$_COOKIES` |
|
||||
| `withCookieParams(array $cookies)` | Returns a new request instance with the specified cookies | |
|
||||
| `withQueryParams(array $query)` | Returns a new request instance with the specified query string arguments | |
|
||||
| `getUploadedFiles()` | Retrieve normalized file upload data | |
|
||||
| `withUploadedFiles(array $uploadedFiles)` | Returns a new request instance with the specified uploaded files | |
|
||||
| `getParsedBody()` | Retrieve any parameters provided in the request body | |
|
||||
| `withParsedBody($data)` | Returns a new request instance with the specified body parameters | |
|
||||
| `getAttributes()` | Retrieve attributes derived from the request | |
|
||||
| `getAttribute($name, $default = null)` | Retrieve a single derived request attribute | |
|
||||
| `withAttribute($name, $value)` | Returns a new request instance with the specified derived request attribute | |
|
||||
| `withoutAttribute($name)` | Returns a new request instance that without the specified derived request attribute | |
|
||||
|
||||
## `Psr\Http\Message\ResponseInterface` Methods:
|
||||
|
||||
Same methods as `Psr\Http\Message\MessageInterface` + the following methods:
|
||||
|
||||
| Method Name | Description | Notes |
|
||||
|------------------------------------| ----------- | ----- |
|
||||
| `getStatusCode()` | Gets the response status code. | |
|
||||
| `withStatus($code, $reasonPhrase = '')` | Returns a new response instance with the specified status code and, optionally, reason phrase. | |
|
||||
| `getReasonPhrase()` | Gets the response reason phrase associated with the status code. | |
|
||||
|
||||
## `Psr\Http\Message\StreamInterface` Methods
|
||||
|
||||
| Method Name | Description | Notes |
|
||||
|------------------------------------| ----------- | ----- |
|
||||
| `__toString()` | Reads all data from the stream into a string, from the beginning to end. | |
|
||||
| `close()` | Closes the stream and any underlying resources. | |
|
||||
| `detach()` | Separates any underlying resources from the stream. | |
|
||||
| `getSize()` | Get the size of the stream if known. | |
|
||||
| `eof()` | Returns true if the stream is at the end of the stream.| |
|
||||
| `isSeekable()` | Returns whether or not the stream is seekable. | |
|
||||
| `seek($offset, $whence = SEEK_SET)` | Seek to a position in the stream. | |
|
||||
| `rewind()` | Seek to the beginning of the stream. | |
|
||||
| `isWritable()` | Returns whether or not the stream is writable. | |
|
||||
| `write($string)` | Write data to the stream. | |
|
||||
| `isReadable()` | Returns whether or not the stream is readable. | |
|
||||
| `read($length)` | Read data from the stream. | |
|
||||
| `getContents()` | Returns the remaining contents in a string | |
|
||||
| `getMetadata($key = null)()` | Get stream metadata as an associative array or retrieve a specific key. | |
|
||||
|
||||
## `Psr\Http\Message\UriInterface` Methods
|
||||
|
||||
| Method Name | Description | Notes |
|
||||
|------------------------------------| ----------- | ----- |
|
||||
| `getScheme()` | Retrieve the scheme component of the URI. | |
|
||||
| `getAuthority()` | Retrieve the authority component of the URI. | |
|
||||
| `getUserInfo()` | Retrieve the user information component of the URI. | |
|
||||
| `getHost()` | Retrieve the host component of the URI. | |
|
||||
| `getPort()` | Retrieve the port component of the URI. | |
|
||||
| `getPath()` | Retrieve the path component of the URI. | |
|
||||
| `getQuery()` | Retrieve the query string of the URI. | |
|
||||
| `getFragment()` | Retrieve the fragment component of the URI. | |
|
||||
| `withScheme($scheme)` | Return an instance with the specified scheme. | |
|
||||
| `withUserInfo($user, $password = null)` | Return an instance with the specified user information. | |
|
||||
| `withHost($host)` | Return an instance with the specified host. | |
|
||||
| `withPort($port)` | Return an instance with the specified port. | |
|
||||
| `withPath($path)` | Return an instance with the specified path. | |
|
||||
| `withQuery($query)` | Return an instance with the specified query string. | |
|
||||
| `withFragment($fragment)` | Return an instance with the specified URI fragment. | |
|
||||
| `__toString()` | Return the string representation as a URI reference. | |
|
||||
|
||||
## `Psr\Http\Message\UploadedFileInterface` Methods
|
||||
|
||||
| Method Name | Description | Notes |
|
||||
|------------------------------------| ----------- | ----- |
|
||||
| `getStream()` | Retrieve a stream representing the uploaded file. | |
|
||||
| `moveTo($targetPath)` | Move the uploaded file to a new location. | |
|
||||
| `getSize()` | Retrieve the file size. | |
|
||||
| `getError()` | Retrieve the error associated with the uploaded file. | |
|
||||
| `getClientFilename()` | Retrieve the filename sent by the client. | |
|
||||
| `getClientMediaType()` | Retrieve the media type sent by the client. | |
|
||||
|
||||
> `RequestInterface`, `ServerRequestInterface`, `ResponseInterface` extend `MessageInterface` because the `Request` and the `Response` are `HTTP Messages`.
|
||||
> When using `ServerRequestInterface`, both `RequestInterface` and `Psr\Http\Message\MessageInterface` methods are considered.
|
||||
|
||||
159
Server/vendor/psr/http-message/docs/PSR7-Usage.md
vendored
Normal file
159
Server/vendor/psr/http-message/docs/PSR7-Usage.md
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
### PSR-7 Usage
|
||||
|
||||
All PSR-7 applications comply with these interfaces
|
||||
They were created to establish a standard between middleware implementations.
|
||||
|
||||
> `RequestInterface`, `ServerRequestInterface`, `ResponseInterface` extend `MessageInterface` because the `Request` and the `Response` are `HTTP Messages`.
|
||||
> When using `ServerRequestInterface`, both `RequestInterface` and `Psr\Http\Message\MessageInterface` methods are considered.
|
||||
|
||||
|
||||
The following examples will illustrate how basic operations are done in PSR-7.
|
||||
|
||||
##### Examples
|
||||
|
||||
|
||||
For this examples to work (at least) a PSR-7 implementation package is required. (eg: zendframework/zend-diactoros, guzzlehttp/psr7, slim/slim, etc)
|
||||
All PSR-7 implementations should have the same behaviour.
|
||||
|
||||
The following will be assumed:
|
||||
`$request` is an object of `Psr\Http\Message\RequestInterface` and
|
||||
|
||||
`$response` is an object implementing `Psr\Http\Message\RequestInterface`
|
||||
|
||||
|
||||
### Working with HTTP Headers
|
||||
|
||||
#### Adding headers to response:
|
||||
|
||||
```php
|
||||
$response->withHeader('My-Custom-Header', 'My Custom Message');
|
||||
```
|
||||
|
||||
#### Appending values to headers
|
||||
|
||||
```php
|
||||
$response->withAddedHeader('My-Custom-Header', 'The second message');
|
||||
```
|
||||
|
||||
#### Checking if header exists:
|
||||
|
||||
```php
|
||||
$request->hasHeader('My-Custom-Header'); // will return false
|
||||
$response->hasHeader('My-Custom-Header'); // will return true
|
||||
```
|
||||
|
||||
> Note: My-Custom-Header was only added in the Response
|
||||
|
||||
#### Getting comma-separated values from a header (also applies to request)
|
||||
|
||||
```php
|
||||
// getting value from request headers
|
||||
$request->getHeaderLine('Content-Type'); // will return: "text/html; charset=UTF-8"
|
||||
// getting value from response headers
|
||||
$response->getHeaderLine('My-Custom-Header'); // will return: "My Custom Message; The second message"
|
||||
```
|
||||
|
||||
#### Getting array of value from a header (also applies to request)
|
||||
```php
|
||||
// getting value from request headers
|
||||
$request->getHeader('Content-Type'); // will return: ["text/html", "charset=UTF-8"]
|
||||
// getting value from response headers
|
||||
$response->getHeader('My-Custom-Header'); // will return: ["My Custom Message", "The second message"]
|
||||
```
|
||||
|
||||
#### Removing headers from HTTP Messages
|
||||
```php
|
||||
// removing a header from Request, removing deprecated "Content-MD5" header
|
||||
$request->withoutHeader('Content-MD5');
|
||||
|
||||
// removing a header from Response
|
||||
// effect: the browser won't know the size of the stream
|
||||
// the browser will download the stream till it ends
|
||||
$response->withoutHeader('Content-Length');
|
||||
```
|
||||
|
||||
### Working with HTTP Message Body
|
||||
|
||||
When working with the PSR-7 there are two methods of implementation:
|
||||
#### 1. Getting the body separately
|
||||
|
||||
> This method makes the body handling easier to understand and is useful when repeatedly calling body methods. (You only call `getBody()` once). Using this method mistakes like `$response->write()` are also prevented.
|
||||
|
||||
```php
|
||||
$body = $response->getBody();
|
||||
// operations on body, eg. read, write, seek
|
||||
// ...
|
||||
// replacing the old body
|
||||
$response->withBody($body);
|
||||
// this last statement is optional as we working with objects
|
||||
// in this case the "new" body is same with the "old" one
|
||||
// the $body variable has the same value as the one in $request, only the reference is passed
|
||||
```
|
||||
|
||||
#### 2. Working directly on response
|
||||
|
||||
> This method is useful when only performing few operations as the `$request->getBody()` statement fragment is required
|
||||
|
||||
```php
|
||||
$response->getBody()->write('hello');
|
||||
```
|
||||
|
||||
### Getting the body contents
|
||||
|
||||
The following snippet gets the contents of a stream contents.
|
||||
> Note: Streams must be rewinded, if content was written into streams, it will be ignored when calling `getContents()` because the stream pointer is set to the last character, which is `\0` - meaning end of stream.
|
||||
```php
|
||||
$body = $response->getBody();
|
||||
$body->rewind(); // or $body->seek(0);
|
||||
$bodyText = $body->getContents();
|
||||
```
|
||||
> Note: If `$body->seek(1)` is called before `$body->getContents()`, the first character will be ommited as the starting pointer is set to `1`, not `0`. This is why using `$body->rewind()` is recommended.
|
||||
|
||||
### Append to body
|
||||
|
||||
```php
|
||||
$response->getBody()->write('Hello'); // writing directly
|
||||
$body = $request->getBody(); // which is a `StreamInterface`
|
||||
$body->write('xxxxx');
|
||||
```
|
||||
|
||||
### Prepend to body
|
||||
Prepending is different when it comes to streams. The content must be copied before writing the content to be prepended.
|
||||
The following example will explain the behaviour of streams.
|
||||
|
||||
```php
|
||||
// assuming our response is initially empty
|
||||
$body = $repsonse->getBody();
|
||||
// writing the string "abcd"
|
||||
$body->write('abcd');
|
||||
|
||||
// seeking to start of stream
|
||||
$body->seek(0);
|
||||
// writing 'ef'
|
||||
$body->write('ef'); // at this point the stream contains "efcd"
|
||||
```
|
||||
|
||||
#### Prepending by rewriting separately
|
||||
|
||||
```php
|
||||
// assuming our response body stream only contains: "abcd"
|
||||
$body = $response->getBody();
|
||||
$body->rewind();
|
||||
$contents = $body->getContents(); // abcd
|
||||
// seeking the stream to beginning
|
||||
$body->rewind();
|
||||
$body->write('ef'); // stream contains "efcd"
|
||||
$body->write($contents); // stream contains "efabcd"
|
||||
```
|
||||
|
||||
> Note: `getContents()` seeks the stream while reading it, therefore if the second `rewind()` method call was not present the stream would have resulted in `abcdefabcd` because the `write()` method appends to stream if not preceeded by `rewind()` or `seek(0)`.
|
||||
|
||||
#### Prepending by using contents as a string
|
||||
```php
|
||||
$body = $response->getBody();
|
||||
$body->rewind();
|
||||
$contents = $body->getContents(); // efabcd
|
||||
$contents = 'ef'.$contents;
|
||||
$body->rewind();
|
||||
$body->write($contents);
|
||||
```
|
||||
@@ -23,7 +23,7 @@ interface MessageInterface
|
||||
*
|
||||
* @return string HTTP protocol version.
|
||||
*/
|
||||
public function getProtocolVersion();
|
||||
public function getProtocolVersion(): string;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified HTTP protocol version.
|
||||
@@ -38,7 +38,7 @@ interface MessageInterface
|
||||
* @param string $version HTTP protocol version
|
||||
* @return static
|
||||
*/
|
||||
public function withProtocolVersion($version);
|
||||
public function withProtocolVersion(string $version): MessageInterface;
|
||||
|
||||
/**
|
||||
* Retrieves all message header values.
|
||||
@@ -65,7 +65,7 @@ interface MessageInterface
|
||||
* key MUST be a header name, and each value MUST be an array of strings
|
||||
* for that header.
|
||||
*/
|
||||
public function getHeaders();
|
||||
public function getHeaders(): array;
|
||||
|
||||
/**
|
||||
* Checks if a header exists by the given case-insensitive name.
|
||||
@@ -75,7 +75,7 @@ interface MessageInterface
|
||||
* name using a case-insensitive string comparison. Returns false if
|
||||
* no matching header name is found in the message.
|
||||
*/
|
||||
public function hasHeader($name);
|
||||
public function hasHeader(string $name): bool;
|
||||
|
||||
/**
|
||||
* Retrieves a message header value by the given case-insensitive name.
|
||||
@@ -91,7 +91,7 @@ interface MessageInterface
|
||||
* header. If the header does not appear in the message, this method MUST
|
||||
* return an empty array.
|
||||
*/
|
||||
public function getHeader($name);
|
||||
public function getHeader(string $name): array;
|
||||
|
||||
/**
|
||||
* Retrieves a comma-separated string of the values for a single header.
|
||||
@@ -112,7 +112,7 @@ interface MessageInterface
|
||||
* concatenated together using a comma. If the header does not appear in
|
||||
* the message, this method MUST return an empty string.
|
||||
*/
|
||||
public function getHeaderLine($name);
|
||||
public function getHeaderLine(string $name): string;
|
||||
|
||||
/**
|
||||
* Return an instance with the provided value replacing the specified header.
|
||||
@@ -129,7 +129,7 @@ interface MessageInterface
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException for invalid header names or values.
|
||||
*/
|
||||
public function withHeader($name, $value);
|
||||
public function withHeader(string $name, $value): MessageInterface;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified header appended with the given value.
|
||||
@@ -147,7 +147,7 @@ interface MessageInterface
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException for invalid header names or values.
|
||||
*/
|
||||
public function withAddedHeader($name, $value);
|
||||
public function withAddedHeader(string $name, $value): MessageInterface;
|
||||
|
||||
/**
|
||||
* Return an instance without the specified header.
|
||||
@@ -161,14 +161,14 @@ interface MessageInterface
|
||||
* @param string $name Case-insensitive header field name to remove.
|
||||
* @return static
|
||||
*/
|
||||
public function withoutHeader($name);
|
||||
public function withoutHeader(string $name): MessageInterface;
|
||||
|
||||
/**
|
||||
* Gets the body of the message.
|
||||
*
|
||||
* @return StreamInterface Returns the body as a stream.
|
||||
*/
|
||||
public function getBody();
|
||||
public function getBody(): StreamInterface;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified message body.
|
||||
@@ -183,5 +183,5 @@ interface MessageInterface
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException When the body is not valid.
|
||||
*/
|
||||
public function withBody(StreamInterface $body);
|
||||
public function withBody(StreamInterface $body): MessageInterface;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ interface RequestInterface extends MessageInterface
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRequestTarget();
|
||||
public function getRequestTarget(): string;
|
||||
|
||||
/**
|
||||
* Return an instance with the specific request-target.
|
||||
@@ -55,17 +55,18 @@ interface RequestInterface extends MessageInterface
|
||||
*
|
||||
* @link http://tools.ietf.org/html/rfc7230#section-5.3 (for the various
|
||||
* request-target forms allowed in request messages)
|
||||
* @param mixed $requestTarget
|
||||
* @param string $requestTarget
|
||||
* @return static
|
||||
*/
|
||||
public function withRequestTarget($requestTarget);
|
||||
public function withRequestTarget(string $requestTarget): RequestInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the HTTP method of the request.
|
||||
*
|
||||
* @return string Returns the request method.
|
||||
*/
|
||||
public function getMethod();
|
||||
public function getMethod(): string;
|
||||
|
||||
/**
|
||||
* Return an instance with the provided HTTP method.
|
||||
@@ -82,7 +83,7 @@ interface RequestInterface extends MessageInterface
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException for invalid HTTP methods.
|
||||
*/
|
||||
public function withMethod($method);
|
||||
public function withMethod(string $method): RequestInterface;
|
||||
|
||||
/**
|
||||
* Retrieves the URI instance.
|
||||
@@ -93,7 +94,7 @@ interface RequestInterface extends MessageInterface
|
||||
* @return UriInterface Returns a UriInterface instance
|
||||
* representing the URI of the request.
|
||||
*/
|
||||
public function getUri();
|
||||
public function getUri(): UriInterface;
|
||||
|
||||
/**
|
||||
* Returns an instance with the provided URI.
|
||||
@@ -125,5 +126,5 @@ interface RequestInterface extends MessageInterface
|
||||
* @param bool $preserveHost Preserve the original state of the Host header.
|
||||
* @return static
|
||||
*/
|
||||
public function withUri(UriInterface $uri, $preserveHost = false);
|
||||
public function withUri(UriInterface $uri, bool $preserveHost = false): RequestInterface;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ interface ResponseInterface extends MessageInterface
|
||||
*
|
||||
* @return int Status code.
|
||||
*/
|
||||
public function getStatusCode();
|
||||
public function getStatusCode(): int;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified status code and, optionally, reason phrase.
|
||||
@@ -49,7 +49,7 @@ interface ResponseInterface extends MessageInterface
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException For invalid status code arguments.
|
||||
*/
|
||||
public function withStatus($code, $reasonPhrase = '');
|
||||
public function withStatus(int $code, string $reasonPhrase = ''): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Gets the response reason phrase associated with the status code.
|
||||
@@ -64,5 +64,5 @@ interface ResponseInterface extends MessageInterface
|
||||
* @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
|
||||
* @return string Reason phrase; must return an empty string if none present.
|
||||
*/
|
||||
public function getReasonPhrase();
|
||||
public function getReasonPhrase(): string;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getServerParams();
|
||||
public function getServerParams(): array;
|
||||
|
||||
/**
|
||||
* Retrieve cookies.
|
||||
@@ -63,7 +63,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCookieParams();
|
||||
public function getCookieParams(): array;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified cookies.
|
||||
@@ -82,7 +82,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
* @param array $cookies Array of key/value pairs representing cookies.
|
||||
* @return static
|
||||
*/
|
||||
public function withCookieParams(array $cookies);
|
||||
public function withCookieParams(array $cookies): ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Retrieve query string arguments.
|
||||
@@ -96,7 +96,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getQueryParams();
|
||||
public function getQueryParams(): array;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified query string arguments.
|
||||
@@ -120,7 +120,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
* $_GET.
|
||||
* @return static
|
||||
*/
|
||||
public function withQueryParams(array $query);
|
||||
public function withQueryParams(array $query): ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Retrieve normalized file upload data.
|
||||
@@ -134,7 +134,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
* @return array An array tree of UploadedFileInterface instances; an empty
|
||||
* array MUST be returned if no data is present.
|
||||
*/
|
||||
public function getUploadedFiles();
|
||||
public function getUploadedFiles(): array;
|
||||
|
||||
/**
|
||||
* Create a new instance with the specified uploaded files.
|
||||
@@ -147,7 +147,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException if an invalid structure is provided.
|
||||
*/
|
||||
public function withUploadedFiles(array $uploadedFiles);
|
||||
public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Retrieve any parameters provided in the request body.
|
||||
@@ -194,7 +194,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
* @throws \InvalidArgumentException if an unsupported argument type is
|
||||
* provided.
|
||||
*/
|
||||
public function withParsedBody($data);
|
||||
public function withParsedBody($data): ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Retrieve attributes derived from the request.
|
||||
@@ -207,7 +207,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
*
|
||||
* @return array Attributes derived from the request.
|
||||
*/
|
||||
public function getAttributes();
|
||||
public function getAttributes(): array;
|
||||
|
||||
/**
|
||||
* Retrieve a single derived request attribute.
|
||||
@@ -224,7 +224,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
* @param mixed $default Default value to return if the attribute does not exist.
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAttribute($name, $default = null);
|
||||
public function getAttribute(string $name, $default = null);
|
||||
|
||||
/**
|
||||
* Return an instance with the specified derived request attribute.
|
||||
@@ -241,7 +241,7 @@ interface ServerRequestInterface extends RequestInterface
|
||||
* @param mixed $value The value of the attribute.
|
||||
* @return static
|
||||
*/
|
||||
public function withAttribute($name, $value);
|
||||
public function withAttribute(string $name, $value): ServerRequestInterface;
|
||||
|
||||
/**
|
||||
* Return an instance that removes the specified derived request attribute.
|
||||
@@ -257,5 +257,5 @@ interface ServerRequestInterface extends RequestInterface
|
||||
* @param string $name The attribute name.
|
||||
* @return static
|
||||
*/
|
||||
public function withoutAttribute($name);
|
||||
public function withoutAttribute(string $name): ServerRequestInterface;
|
||||
}
|
||||
|
||||
@@ -25,14 +25,14 @@ interface StreamInterface
|
||||
* @see http://php.net/manual/en/language.oop5.magic.php#object.tostring
|
||||
* @return string
|
||||
*/
|
||||
public function __toString();
|
||||
public function __toString(): string;
|
||||
|
||||
/**
|
||||
* Closes the stream and any underlying resources.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function close();
|
||||
public function close(): void;
|
||||
|
||||
/**
|
||||
* Separates any underlying resources from the stream.
|
||||
@@ -48,7 +48,7 @@ interface StreamInterface
|
||||
*
|
||||
* @return int|null Returns the size in bytes if known, or null if unknown.
|
||||
*/
|
||||
public function getSize();
|
||||
public function getSize(): ?int;
|
||||
|
||||
/**
|
||||
* Returns the current position of the file read/write pointer
|
||||
@@ -56,21 +56,21 @@ interface StreamInterface
|
||||
* @return int Position of the file pointer
|
||||
* @throws \RuntimeException on error.
|
||||
*/
|
||||
public function tell();
|
||||
public function tell(): int;
|
||||
|
||||
/**
|
||||
* Returns true if the stream is at the end of the stream.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function eof();
|
||||
public function eof(): bool;
|
||||
|
||||
/**
|
||||
* Returns whether or not the stream is seekable.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSeekable();
|
||||
public function isSeekable(): bool;
|
||||
|
||||
/**
|
||||
* Seek to a position in the stream.
|
||||
@@ -84,7 +84,7 @@ interface StreamInterface
|
||||
* SEEK_END: Set position to end-of-stream plus offset.
|
||||
* @throws \RuntimeException on failure.
|
||||
*/
|
||||
public function seek($offset, $whence = SEEK_SET);
|
||||
public function seek(int $offset, int $whence = SEEK_SET): void;
|
||||
|
||||
/**
|
||||
* Seek to the beginning of the stream.
|
||||
@@ -96,14 +96,14 @@ interface StreamInterface
|
||||
* @link http://www.php.net/manual/en/function.fseek.php
|
||||
* @throws \RuntimeException on failure.
|
||||
*/
|
||||
public function rewind();
|
||||
public function rewind(): void;
|
||||
|
||||
/**
|
||||
* Returns whether or not the stream is writable.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isWritable();
|
||||
public function isWritable(): bool;
|
||||
|
||||
/**
|
||||
* Write data to the stream.
|
||||
@@ -112,14 +112,14 @@ interface StreamInterface
|
||||
* @return int Returns the number of bytes written to the stream.
|
||||
* @throws \RuntimeException on failure.
|
||||
*/
|
||||
public function write($string);
|
||||
public function write(string $string): int;
|
||||
|
||||
/**
|
||||
* Returns whether or not the stream is readable.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isReadable();
|
||||
public function isReadable(): bool;
|
||||
|
||||
/**
|
||||
* Read data from the stream.
|
||||
@@ -131,7 +131,7 @@ interface StreamInterface
|
||||
* if no bytes are available.
|
||||
* @throws \RuntimeException if an error occurs.
|
||||
*/
|
||||
public function read($length);
|
||||
public function read(int $length): string;
|
||||
|
||||
/**
|
||||
* Returns the remaining contents in a string
|
||||
@@ -140,7 +140,7 @@ interface StreamInterface
|
||||
* @throws \RuntimeException if unable to read or an error occurs while
|
||||
* reading.
|
||||
*/
|
||||
public function getContents();
|
||||
public function getContents(): string;
|
||||
|
||||
/**
|
||||
* Get stream metadata as an associative array or retrieve a specific key.
|
||||
@@ -149,10 +149,10 @@ interface StreamInterface
|
||||
* stream_get_meta_data() function.
|
||||
*
|
||||
* @link http://php.net/manual/en/function.stream-get-meta-data.php
|
||||
* @param string $key Specific metadata to retrieve.
|
||||
* @param string|null $key Specific metadata to retrieve.
|
||||
* @return array|mixed|null Returns an associative array if no key is
|
||||
* provided. Returns a specific key value if a key is provided and the
|
||||
* value is found, or null if the key is not found.
|
||||
*/
|
||||
public function getMetadata($key = null);
|
||||
public function getMetadata(?string $key = null);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ interface UploadedFileInterface
|
||||
* @throws \RuntimeException in cases when no stream is available or can be
|
||||
* created.
|
||||
*/
|
||||
public function getStream();
|
||||
public function getStream(): StreamInterface;
|
||||
|
||||
/**
|
||||
* Move the uploaded file to a new location.
|
||||
@@ -62,7 +62,7 @@ interface UploadedFileInterface
|
||||
* @throws \RuntimeException on any error during the move operation, or on
|
||||
* the second or subsequent call to the method.
|
||||
*/
|
||||
public function moveTo($targetPath);
|
||||
public function moveTo(string $targetPath): void;
|
||||
|
||||
/**
|
||||
* Retrieve the file size.
|
||||
@@ -73,7 +73,7 @@ interface UploadedFileInterface
|
||||
*
|
||||
* @return int|null The file size in bytes or null if unknown.
|
||||
*/
|
||||
public function getSize();
|
||||
public function getSize(): ?int;
|
||||
|
||||
/**
|
||||
* Retrieve the error associated with the uploaded file.
|
||||
@@ -89,7 +89,7 @@ interface UploadedFileInterface
|
||||
* @see http://php.net/manual/en/features.file-upload.errors.php
|
||||
* @return int One of PHP's UPLOAD_ERR_XXX constants.
|
||||
*/
|
||||
public function getError();
|
||||
public function getError(): int;
|
||||
|
||||
/**
|
||||
* Retrieve the filename sent by the client.
|
||||
@@ -104,7 +104,7 @@ interface UploadedFileInterface
|
||||
* @return string|null The filename sent by the client or null if none
|
||||
* was provided.
|
||||
*/
|
||||
public function getClientFilename();
|
||||
public function getClientFilename(): ?string;
|
||||
|
||||
/**
|
||||
* Retrieve the media type sent by the client.
|
||||
@@ -119,5 +119,5 @@ interface UploadedFileInterface
|
||||
* @return string|null The media type sent by the client or null if none
|
||||
* was provided.
|
||||
*/
|
||||
public function getClientMediaType();
|
||||
public function getClientMediaType(): ?string;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Http\Message;
|
||||
|
||||
/**
|
||||
@@ -37,7 +38,7 @@ interface UriInterface
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-3.1
|
||||
* @return string The URI scheme.
|
||||
*/
|
||||
public function getScheme();
|
||||
public function getScheme(): string;
|
||||
|
||||
/**
|
||||
* Retrieve the authority component of the URI.
|
||||
@@ -57,7 +58,7 @@ interface UriInterface
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-3.2
|
||||
* @return string The URI authority, in "[user-info@]host[:port]" format.
|
||||
*/
|
||||
public function getAuthority();
|
||||
public function getAuthority(): string;
|
||||
|
||||
/**
|
||||
* Retrieve the user information component of the URI.
|
||||
@@ -74,7 +75,7 @@ interface UriInterface
|
||||
*
|
||||
* @return string The URI user information, in "username[:password]" format.
|
||||
*/
|
||||
public function getUserInfo();
|
||||
public function getUserInfo(): string;
|
||||
|
||||
/**
|
||||
* Retrieve the host component of the URI.
|
||||
@@ -87,7 +88,7 @@ interface UriInterface
|
||||
* @see http://tools.ietf.org/html/rfc3986#section-3.2.2
|
||||
* @return string The URI host.
|
||||
*/
|
||||
public function getHost();
|
||||
public function getHost(): string;
|
||||
|
||||
/**
|
||||
* Retrieve the port component of the URI.
|
||||
@@ -104,7 +105,7 @@ interface UriInterface
|
||||
*
|
||||
* @return null|int The URI port.
|
||||
*/
|
||||
public function getPort();
|
||||
public function getPort(): ?int;
|
||||
|
||||
/**
|
||||
* Retrieve the path component of the URI.
|
||||
@@ -131,7 +132,7 @@ interface UriInterface
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-3.3
|
||||
* @return string The URI path.
|
||||
*/
|
||||
public function getPath();
|
||||
public function getPath(): string;
|
||||
|
||||
/**
|
||||
* Retrieve the query string of the URI.
|
||||
@@ -153,7 +154,7 @@ interface UriInterface
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-3.4
|
||||
* @return string The URI query string.
|
||||
*/
|
||||
public function getQuery();
|
||||
public function getQuery(): string;
|
||||
|
||||
/**
|
||||
* Retrieve the fragment component of the URI.
|
||||
@@ -171,7 +172,7 @@ interface UriInterface
|
||||
* @see https://tools.ietf.org/html/rfc3986#section-3.5
|
||||
* @return string The URI fragment.
|
||||
*/
|
||||
public function getFragment();
|
||||
public function getFragment(): string;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified scheme.
|
||||
@@ -188,7 +189,7 @@ interface UriInterface
|
||||
* @return static A new instance with the specified scheme.
|
||||
* @throws \InvalidArgumentException for invalid or unsupported schemes.
|
||||
*/
|
||||
public function withScheme($scheme);
|
||||
public function withScheme(string $scheme): UriInterface;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified user information.
|
||||
@@ -204,7 +205,7 @@ interface UriInterface
|
||||
* @param null|string $password The password associated with $user.
|
||||
* @return static A new instance with the specified user information.
|
||||
*/
|
||||
public function withUserInfo($user, $password = null);
|
||||
public function withUserInfo(string $user, ?string $password = null): UriInterface;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified host.
|
||||
@@ -218,7 +219,7 @@ interface UriInterface
|
||||
* @return static A new instance with the specified host.
|
||||
* @throws \InvalidArgumentException for invalid hostnames.
|
||||
*/
|
||||
public function withHost($host);
|
||||
public function withHost(string $host): UriInterface;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified port.
|
||||
@@ -237,7 +238,7 @@ interface UriInterface
|
||||
* @return static A new instance with the specified port.
|
||||
* @throws \InvalidArgumentException for invalid ports.
|
||||
*/
|
||||
public function withPort($port);
|
||||
public function withPort(?int $port): UriInterface;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified path.
|
||||
@@ -261,7 +262,7 @@ interface UriInterface
|
||||
* @return static A new instance with the specified path.
|
||||
* @throws \InvalidArgumentException for invalid paths.
|
||||
*/
|
||||
public function withPath($path);
|
||||
public function withPath(string $path): UriInterface;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified query string.
|
||||
@@ -278,7 +279,7 @@ interface UriInterface
|
||||
* @return static A new instance with the specified query string.
|
||||
* @throws \InvalidArgumentException for invalid query strings.
|
||||
*/
|
||||
public function withQuery($query);
|
||||
public function withQuery(string $query): UriInterface;
|
||||
|
||||
/**
|
||||
* Return an instance with the specified URI fragment.
|
||||
@@ -294,7 +295,7 @@ interface UriInterface
|
||||
* @param string $fragment The fragment to use with the new instance.
|
||||
* @return static A new instance with the specified fragment.
|
||||
*/
|
||||
public function withFragment($fragment);
|
||||
public function withFragment(string $fragment): UriInterface;
|
||||
|
||||
/**
|
||||
* Return the string representation as a URI reference.
|
||||
@@ -319,5 +320,5 @@ interface UriInterface
|
||||
* @see http://tools.ietf.org/html/rfc3986#section-4.1
|
||||
* @return string
|
||||
*/
|
||||
public function __toString();
|
||||
public function __toString(): string;
|
||||
}
|
||||
|
||||
19
Server/vendor/psr/log/LICENSE
vendored
Normal file
19
Server/vendor/psr/log/LICENSE
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2012 PHP Framework Interoperability Group
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
58
Server/vendor/psr/log/README.md
vendored
Normal file
58
Server/vendor/psr/log/README.md
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
PSR Log
|
||||
=======
|
||||
|
||||
This repository holds all interfaces/classes/traits related to
|
||||
[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md).
|
||||
|
||||
Note that this is not a logger of its own. It is merely an interface that
|
||||
describes a logger. See the specification for more details.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
```bash
|
||||
composer require psr/log
|
||||
```
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
If you need a logger, you can use the interface like this:
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class Foo
|
||||
{
|
||||
private $logger;
|
||||
|
||||
public function __construct(LoggerInterface $logger = null)
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function doSomething()
|
||||
{
|
||||
if ($this->logger) {
|
||||
$this->logger->info('Doing work');
|
||||
}
|
||||
|
||||
try {
|
||||
$this->doSomethingElse();
|
||||
} catch (Exception $exception) {
|
||||
$this->logger->error('Oh no!', array('exception' => $exception));
|
||||
}
|
||||
|
||||
// do something useful
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
You can then pick one of the implementations of the interface to get a logger.
|
||||
|
||||
If you want to implement the interface, you can require this package and
|
||||
implement `Psr\Log\LoggerInterface` in your code. Please read the
|
||||
[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md)
|
||||
for details.
|
||||
26
Server/vendor/psr/log/composer.json
vendored
Normal file
26
Server/vendor/psr/log/composer.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "psr/log",
|
||||
"description": "Common interface for logging libraries",
|
||||
"keywords": ["psr", "psr-3", "log"],
|
||||
"homepage": "https://github.com/php-fig/log",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "https://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.0.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Log\\": "src"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Server/vendor/psr/log/src/AbstractLogger.php
vendored
Normal file
15
Server/vendor/psr/log/src/AbstractLogger.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Log;
|
||||
|
||||
/**
|
||||
* This is a simple Logger implementation that other Loggers can inherit from.
|
||||
*
|
||||
* It simply delegates all log-level-specific methods to the `log` method to
|
||||
* reduce boilerplate code that a simple Logger that does the same thing with
|
||||
* messages regardless of the error level has to implement.
|
||||
*/
|
||||
abstract class AbstractLogger implements LoggerInterface
|
||||
{
|
||||
use LoggerTrait;
|
||||
}
|
||||
7
Server/vendor/psr/log/src/InvalidArgumentException.php
vendored
Normal file
7
Server/vendor/psr/log/src/InvalidArgumentException.php
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Log;
|
||||
|
||||
class InvalidArgumentException extends \InvalidArgumentException
|
||||
{
|
||||
}
|
||||
18
Server/vendor/psr/log/src/LogLevel.php
vendored
Normal file
18
Server/vendor/psr/log/src/LogLevel.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Log;
|
||||
|
||||
/**
|
||||
* Describes log levels.
|
||||
*/
|
||||
class LogLevel
|
||||
{
|
||||
const EMERGENCY = 'emergency';
|
||||
const ALERT = 'alert';
|
||||
const CRITICAL = 'critical';
|
||||
const ERROR = 'error';
|
||||
const WARNING = 'warning';
|
||||
const NOTICE = 'notice';
|
||||
const INFO = 'info';
|
||||
const DEBUG = 'debug';
|
||||
}
|
||||
14
Server/vendor/psr/log/src/LoggerAwareInterface.php
vendored
Normal file
14
Server/vendor/psr/log/src/LoggerAwareInterface.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Log;
|
||||
|
||||
/**
|
||||
* Describes a logger-aware instance.
|
||||
*/
|
||||
interface LoggerAwareInterface
|
||||
{
|
||||
/**
|
||||
* Sets a logger instance on the object.
|
||||
*/
|
||||
public function setLogger(LoggerInterface $logger): void;
|
||||
}
|
||||
22
Server/vendor/psr/log/src/LoggerAwareTrait.php
vendored
Normal file
22
Server/vendor/psr/log/src/LoggerAwareTrait.php
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Log;
|
||||
|
||||
/**
|
||||
* Basic Implementation of LoggerAwareInterface.
|
||||
*/
|
||||
trait LoggerAwareTrait
|
||||
{
|
||||
/**
|
||||
* The logger instance.
|
||||
*/
|
||||
protected ?LoggerInterface $logger = null;
|
||||
|
||||
/**
|
||||
* Sets a logger.
|
||||
*/
|
||||
public function setLogger(LoggerInterface $logger): void
|
||||
{
|
||||
$this->logger = $logger;
|
||||
}
|
||||
}
|
||||
97
Server/vendor/psr/log/src/LoggerInterface.php
vendored
Normal file
97
Server/vendor/psr/log/src/LoggerInterface.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Log;
|
||||
|
||||
/**
|
||||
* Describes a logger instance.
|
||||
*
|
||||
* The message MUST be a string or object implementing __toString().
|
||||
*
|
||||
* The message MAY contain placeholders in the form: {foo} where foo
|
||||
* will be replaced by the context data in key "foo".
|
||||
*
|
||||
* The context array can contain arbitrary data. The only assumption that
|
||||
* can be made by implementors is that if an Exception instance is given
|
||||
* to produce a stack trace, it MUST be in a key named "exception".
|
||||
*
|
||||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
|
||||
* for the full interface specification.
|
||||
*/
|
||||
interface LoggerInterface
|
||||
{
|
||||
/**
|
||||
* System is unusable.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function emergency(string|\Stringable $message, array $context = []): void;
|
||||
|
||||
/**
|
||||
* Action must be taken immediately.
|
||||
*
|
||||
* Example: Entire website down, database unavailable, etc. This should
|
||||
* trigger the SMS alerts and wake you up.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function alert(string|\Stringable $message, array $context = []): void;
|
||||
|
||||
/**
|
||||
* Critical conditions.
|
||||
*
|
||||
* Example: Application component unavailable, unexpected exception.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function critical(string|\Stringable $message, array $context = []): void;
|
||||
|
||||
/**
|
||||
* Runtime errors that do not require immediate action but should typically
|
||||
* be logged and monitored.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function error(string|\Stringable $message, array $context = []): void;
|
||||
|
||||
/**
|
||||
* Exceptional occurrences that are not errors.
|
||||
*
|
||||
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
||||
* that are not necessarily wrong.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function warning(string|\Stringable $message, array $context = []): void;
|
||||
|
||||
/**
|
||||
* Normal but significant events.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function notice(string|\Stringable $message, array $context = []): void;
|
||||
|
||||
/**
|
||||
* Interesting events.
|
||||
*
|
||||
* Example: User logs in, SQL logs.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function info(string|\Stringable $message, array $context = []): void;
|
||||
|
||||
/**
|
||||
* Detailed debug information.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*/
|
||||
public function debug(string|\Stringable $message, array $context = []): void;
|
||||
|
||||
/**
|
||||
* Logs with an arbitrary level.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*
|
||||
* @throws \Psr\Log\InvalidArgumentException
|
||||
*/
|
||||
public function log($level, string|\Stringable $message, array $context = []): void;
|
||||
}
|
||||
98
Server/vendor/psr/log/src/LoggerTrait.php
vendored
Normal file
98
Server/vendor/psr/log/src/LoggerTrait.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Log;
|
||||
|
||||
/**
|
||||
* This is a simple Logger trait that classes unable to extend AbstractLogger
|
||||
* (because they extend another class, etc) can include.
|
||||
*
|
||||
* It simply delegates all log-level-specific methods to the `log` method to
|
||||
* reduce boilerplate code that a simple Logger that does the same thing with
|
||||
* messages regardless of the error level has to implement.
|
||||
*/
|
||||
trait LoggerTrait
|
||||
{
|
||||
/**
|
||||
* System is unusable.
|
||||
*/
|
||||
public function emergency(string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::EMERGENCY, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Action must be taken immediately.
|
||||
*
|
||||
* Example: Entire website down, database unavailable, etc. This should
|
||||
* trigger the SMS alerts and wake you up.
|
||||
*/
|
||||
public function alert(string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::ALERT, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Critical conditions.
|
||||
*
|
||||
* Example: Application component unavailable, unexpected exception.
|
||||
*/
|
||||
public function critical(string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::CRITICAL, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runtime errors that do not require immediate action but should typically
|
||||
* be logged and monitored.
|
||||
*/
|
||||
public function error(string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::ERROR, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Exceptional occurrences that are not errors.
|
||||
*
|
||||
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
||||
* that are not necessarily wrong.
|
||||
*/
|
||||
public function warning(string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::WARNING, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normal but significant events.
|
||||
*/
|
||||
public function notice(string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::NOTICE, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interesting events.
|
||||
*
|
||||
* Example: User logs in, SQL logs.
|
||||
*/
|
||||
public function info(string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::INFO, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detailed debug information.
|
||||
*/
|
||||
public function debug(string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
$this->log(LogLevel::DEBUG, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs with an arbitrary level.
|
||||
*
|
||||
* @param mixed $level
|
||||
*
|
||||
* @throws \Psr\Log\InvalidArgumentException
|
||||
*/
|
||||
abstract public function log($level, string|\Stringable $message, array $context = []): void;
|
||||
}
|
||||
26
Server/vendor/psr/log/src/NullLogger.php
vendored
Normal file
26
Server/vendor/psr/log/src/NullLogger.php
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Psr\Log;
|
||||
|
||||
/**
|
||||
* This Logger can be used to avoid conditional log calls.
|
||||
*
|
||||
* Logging should always be optional, and if no logger is provided to your
|
||||
* library creating a NullLogger instance to have something to throw logs at
|
||||
* is a good way to avoid littering your code with `if ($this->logger) { }`
|
||||
* blocks.
|
||||
*/
|
||||
class NullLogger extends AbstractLogger
|
||||
{
|
||||
/**
|
||||
* Logs with an arbitrary level.
|
||||
*
|
||||
* @param mixed[] $context
|
||||
*
|
||||
* @throws \Psr\Log\InvalidArgumentException
|
||||
*/
|
||||
public function log($level, string|\Stringable $message, array $context = []): void
|
||||
{
|
||||
// noop
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user