diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 4722f48..0000000 --- a/.editorconfig +++ /dev/null @@ -1,32 +0,0 @@ -root = true - -# 对所有文件生效 -[*] -charset = utf-8 -indent_style = space -indent_size = 4 -end_of_line = lf -insert_final_newline = true -trim_trailing_whitespace = true - -# 对后缀名为 md 的文件生效 -[*.md] -trim_trailing_whitespace = false - -[*.css] -indent_size = 2 - -[*.html] -indent_size = 2 - -[*.js] -indent_size = 2 - -[*.json] -indent_size = 2 - -[*.tag] -indent_size = 2 - -[views/*.php] -indent_size = 2 diff --git a/README.md b/README.md index e8855d6..63eb902 100644 --- a/README.md +++ b/README.md @@ -92,4 +92,4 @@ class MyResponse extends Response { ## License -[MIT](License) +[MIT](LICENSE) diff --git a/composer.json b/composer.json index 996dfcb..2d4267d 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ }, "autoload": { "psr-4": { - "PhpComp\\Http\\" : "src/" + "PhpComp\\Http\\Message\\" : "src/" } }, "suggest": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5090500..02c3cf7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,7 +8,6 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" stopOnFailure="false" - syntaxCheck="false" > diff --git a/src/Body.php b/src/Body.php index 8ca3a85..c32d0a6 100644 --- a/src/Body.php +++ b/src/Body.php @@ -6,9 +6,9 @@ * Time: 18:02 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; -use Inhere\Http\Component\TempStream; +use PhpComp\Http\Message\Component\TempStream; /** * Body diff --git a/src/Component/Collection.php b/src/Component/Collection.php index 2b74de2..7caf891 100644 --- a/src/Component/Collection.php +++ b/src/Component/Collection.php @@ -6,11 +6,11 @@ * Time: 下午2:04 */ -namespace Inhere\Http\Component; +namespace PhpComp\Http\Message\Component; /** * Class Collection - * @package Inhere\Http\Component + * @package PhpComp\Http\Message\Component */ class Collection extends \ArrayObject { diff --git a/src/Component/Environment.php b/src/Component/Environment.php index d768799..ed1b33e 100644 --- a/src/Component/Environment.php +++ b/src/Component/Environment.php @@ -7,12 +7,12 @@ * File: Environment.php */ -namespace Inhere\Http\Component; +namespace PhpComp\Http\Message\Component; /** * mock 环境信息 * Class Environment - * @package Inhere\Http\Component + * @package PhpComp\Http\Message\Component */ class Environment extends Collection { @@ -35,7 +35,7 @@ public static function mock(array $userData = []): self 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.8', 'HTTP_ACCEPT_CHARSET' => 'utf-8;q=0.7,*;q=0.3', - 'HTTP_USER_AGENT' => 'Slim Framework', + 'HTTP_USER_AGENT' => 'MY Framework', 'REMOTE_ADDR' => '127.0.0.1', 'REQUEST_TIME' => \time(), 'REQUEST_TIME_FLOAT' => \microtime(true), diff --git a/src/Component/InputStream.php b/src/Component/InputStream.php index 58e0a7e..80fa0c4 100644 --- a/src/Component/InputStream.php +++ b/src/Component/InputStream.php @@ -6,13 +6,13 @@ * Time: 下午12:29 */ -namespace Inhere\Http\Component; +namespace PhpComp\Http\Message\Component; -use Inhere\Http\Stream; +use PhpComp\Http\Message\Stream; /** * Class InputStream - * @package Inhere\Http\Component + * @package PhpComp\Http\Message\Component */ class InputStream extends Stream { diff --git a/src/Component/MemoryStream.php b/src/Component/MemoryStream.php index 5d994e5..496509c 100644 --- a/src/Component/MemoryStream.php +++ b/src/Component/MemoryStream.php @@ -6,13 +6,13 @@ * Time: 22:25 */ -namespace Inhere\Http\Component; +namespace PhpComp\Http\Message\Component; -use Inhere\Http\Stream; +use PhpComp\Http\Message\Stream; /** * Class MemoryStream - * @package Inhere\Http\Component + * @package PhpComp\Http\Message\Component */ class MemoryStream extends Stream { diff --git a/src/Component/TempStream.php b/src/Component/TempStream.php index e2f8f3a..598b798 100644 --- a/src/Component/TempStream.php +++ b/src/Component/TempStream.php @@ -6,13 +6,13 @@ * Time: 下午12:29 */ -namespace Inhere\Http\Component; +namespace PhpComp\Http\Message\Component; -use Inhere\Http\Stream; +use PhpComp\Http\Message\Stream; /** * Class TempStream - * @package Inhere\Http + * @package PhpComp\Http\Message */ class TempStream extends Stream { diff --git a/src/Cookies.php b/src/Cookies.php index 6c24501..31905da 100644 --- a/src/Cookies.php +++ b/src/Cookies.php @@ -8,13 +8,13 @@ * @from slim3 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; -use Inhere\Http\Component\Collection; +use PhpComp\Http\Message\Component\Collection; /** * Class Cookies - * @package Inhere\Http + * @package PhpComp\Http\Message * * Cookies: * diff --git a/src/Headers.php b/src/Headers.php index 0e12e98..172441f 100644 --- a/src/Headers.php +++ b/src/Headers.php @@ -6,13 +6,13 @@ * Time: 19:02 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; -use Inhere\Http\Component\Collection; +use PhpComp\Http\Message\Component\Collection; /** * Class Headers - * @package Inhere\Http + * @package PhpComp\Http\Message */ class Headers extends Collection { diff --git a/src/HttpFactory.php b/src/HttpFactory.php index 07ccf50..41e4f1c 100644 --- a/src/HttpFactory.php +++ b/src/HttpFactory.php @@ -6,10 +6,10 @@ * Time: 13:20 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; -use Inhere\Http\Component\Collection; -use Inhere\Http\Request\RequestBody; +use PhpComp\Http\Message\Component\Collection; +use PhpComp\Http\Message\Request\RequestBody; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -19,7 +19,7 @@ /** * Class HttpFactory - * @package Inhere\Http + * @package PhpComp\Http\Message * @link https://github.com/php-fig/fig-standards/blob/master/proposed/http-factory/http-factory.md */ class HttpFactory @@ -204,7 +204,8 @@ public static function createUploadedFile( int $error = \UPLOAD_ERR_OK, string $clientFilename = null, string $clientMediaType = null - ): UploadedFileInterface { + ): UploadedFileInterface + { return new UploadedFile($file, $clientFilename, $clientMediaType, $size, $error); } @@ -316,7 +317,7 @@ public static function createHeadersFromArray($env): Headers /** * If HTTP_AUTHORIZATION does not exist tries to get it from * getallheaders() when available. - * @param Collection $env The Slim application Collection + * @param Collection $env The application Collection * @return Collection */ public static function determineAuthorization($env): Collection diff --git a/src/HttpUtil.php b/src/HttpUtil.php index 127f7b0..90bc53c 100644 --- a/src/HttpUtil.php +++ b/src/HttpUtil.php @@ -6,13 +6,13 @@ * Time: 15:24 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; use Psr\Http\Message\ResponseInterface; /** * Class HttpUtil - * @package Inhere\Http + * @package PhpComp\Http\Message */ class HttpUtil { diff --git a/src/Message.php b/src/Message.php index 5476c66..8a0dad2 100644 --- a/src/Message.php +++ b/src/Message.php @@ -6,9 +6,9 @@ * Time: 13:12 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; -use Inhere\Http\Traits\MessageTrait; +use PhpComp\Http\Message\Traits\MessageTrait; use Psr\Http\Message\MessageInterface; /** diff --git a/src/Request.php b/src/Request.php index a68ac1e..1ade017 100644 --- a/src/Request.php +++ b/src/Request.php @@ -7,11 +7,11 @@ * @ref Slim 3 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; -use Inhere\Http\Request\RequestBody; -use Inhere\Http\Traits\RequestHeadersTrait; -use Inhere\Http\Traits\RequestTrait; +use PhpComp\Http\Message\Request\RequestBody; +use PhpComp\Http\Message\Traits\RequestHeadersTrait; +use PhpComp\Http\Message\Traits\RequestTrait; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; @@ -47,7 +47,8 @@ public function __construct( StreamInterface $body = null, string $protocol = 'HTTP', string $protocolVersion = '1.1' - ) { + ) + { $this->initialize($protocol, $protocolVersion, $headers, $body ?: new RequestBody()); $this->initializeRequest($uri, $method); diff --git a/src/Request/ExtendedRequest.php b/src/Request/ExtendedRequest.php index b08b6a1..b5fc610 100644 --- a/src/Request/ExtendedRequest.php +++ b/src/Request/ExtendedRequest.php @@ -6,14 +6,14 @@ * Time: 下午11:43 */ -namespace Inhere\Http\Request; +namespace PhpComp\Http\Message\Request; -use Inhere\Http\ServerRequest; -use Inhere\Http\Traits\ExtendedRequestTrait; +use PhpComp\Http\Message\ServerRequest; +use PhpComp\Http\Message\Traits\ExtendedRequestTrait; /** * Class ExtendedRequest - * @package Inhere\Http\Request + * @package PhpComp\Http\Message\Request */ class ExtendedRequest extends ServerRequest { diff --git a/src/Request/RequestBody.php b/src/Request/RequestBody.php index c9ac3d4..fee54ab 100644 --- a/src/Request/RequestBody.php +++ b/src/Request/RequestBody.php @@ -6,14 +6,14 @@ * Time: 14:31 */ -namespace Inhere\Http\Request; +namespace PhpComp\Http\Message\Request; -use Inhere\Http\Stream; +use PhpComp\Http\Message\Stream; /** * Class RequestBody * Provides a PSR-7 implementation of a reusable raw request body - * @package Inhere\Http\Request + * @package PhpComp\Http\Message\Request */ class RequestBody extends Stream { diff --git a/src/Response.php b/src/Response.php index 5b71e6f..e6e3923 100644 --- a/src/Response.php +++ b/src/Response.php @@ -7,17 +7,17 @@ * @from Slim 3 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; -use Inhere\Http\Traits\CookiesTrait; -use Inhere\Http\Traits\MessageTrait; +use PhpComp\Http\Message\Traits\CookiesTrait; +use PhpComp\Http\Message\Traits\MessageTrait; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; /** * Class Response * response for handshake - * @package Inhere\Http + * @package PhpComp\Http\Message * @property int $status * @property string $statusMsg * @@ -138,7 +138,8 @@ public static function make( StreamInterface $body = null, string $protocol = 'HTTP', string $protocolVersion = '1.1' - ): Response { + ): Response + { return new static($status, $headers, $cookies, $body, $protocol, $protocolVersion); } @@ -159,7 +160,8 @@ public function __construct( StreamInterface $body = null, string $protocol = 'HTTP', string $protocolVersion = '1.1' - ) { + ) + { $this->setCookies($cookies); $this->initialize($protocol, $protocolVersion, $headers, $body ?: new Body()); diff --git a/src/Response/ExtendedResponse.php b/src/Response/ExtendedResponse.php index f5fdc0d..01555ef 100644 --- a/src/Response/ExtendedResponse.php +++ b/src/Response/ExtendedResponse.php @@ -6,14 +6,14 @@ * Time: 下午11:43 */ -namespace Inhere\Http\Response; +namespace PhpComp\Http\Message\Response; -use Inhere\Http\Response; -use Inhere\Http\Traits\ExtendedResponseTrait; +use PhpComp\Http\Message\Response; +use PhpComp\Http\Message\Traits\ExtendedResponseTrait; /** * Class ExtendedResponse - * @package Inhere\Http\Response + * @package PhpComp\Http\Message\Response */ class ExtendedResponse extends Response { diff --git a/src/Response/InjectContentTypeTrait.php b/src/Response/InjectContentTypeTrait.php index 2250efb..7860ee2 100644 --- a/src/Response/InjectContentTypeTrait.php +++ b/src/Response/InjectContentTypeTrait.php @@ -6,11 +6,11 @@ * Time: 下午12:25 */ -namespace Inhere\Http\Response; +namespace PhpComp\Http\Message\Response; /** * Trait InjectContentTypeTrait - * @package Inhere\Http\Response + * @package PhpComp\Http\Message\Response * @from https://github.com/zendframework/zend-diactoros/blob/master/src/Response/InjectContentTypeTrait.php */ trait InjectContentTypeTrait diff --git a/src/Response/JsonResponse.php b/src/Response/JsonResponse.php index 1d2b43b..51d74f0 100644 --- a/src/Response/JsonResponse.php +++ b/src/Response/JsonResponse.php @@ -6,11 +6,11 @@ * Time: 下午12:32 */ -namespace Inhere\Http\Response; +namespace PhpComp\Http\Message\Response; -use Inhere\Http\Response; -use Inhere\Http\Stream; -use Inhere\Http\Component\TempStream; +use PhpComp\Http\Message\Component\TempStream; +use PhpComp\Http\Message\Response; +use PhpComp\Http\Message\Stream; /** * JSON response. @@ -19,7 +19,7 @@ * serializes the data to JSON, sets a status code of 200 and sets the * Content-Type header to application/json. * - * @package Inhere\Http\Response + * @package PhpComp\Http\Message\Response * @from zendFramework */ class JsonResponse extends Response @@ -72,7 +72,8 @@ public function __construct( int $status = 200, array $headers = [], $encodingOptions = self::DEFAULT_JSON_FLAGS - ) { + ) + { $this->setPayload($data); $this->encodingOptions = $encodingOptions; $json = $this->jsonEncode($data, $this->encodingOptions); diff --git a/src/Response/TextResponse.php b/src/Response/TextResponse.php index 8166a9f..f7b373d 100644 --- a/src/Response/TextResponse.php +++ b/src/Response/TextResponse.php @@ -6,10 +6,10 @@ * Time: 下午12:24 */ -namespace Inhere\Http\Response; +namespace PhpComp\Http\Message\Response; -use Inhere\Http\Response; -use Inhere\Http\Component\TempStream; +use PhpComp\Http\Message\Component\TempStream; +use PhpComp\Http\Message\Response; use Psr\Http\Message\StreamInterface; /** @@ -19,7 +19,7 @@ * by default, sets a status code of 200 and sets the Content-Type header to * text/plain. * - * @package Inhere\Http\Response + * @package PhpComp\Http\Message\Response * @from zendFramework */ class TextResponse extends Response diff --git a/src/ServerRequest.php b/src/ServerRequest.php index 2310817..3e54182 100644 --- a/src/ServerRequest.php +++ b/src/ServerRequest.php @@ -7,13 +7,13 @@ * @ref Slim 3 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; -use Inhere\Http\Component\Collection; -use Inhere\Http\Request\RequestBody; -use Inhere\Http\Traits\CookiesTrait; -use Inhere\Http\Traits\RequestHeadersTrait; -use Inhere\Http\Traits\RequestTrait; +use PhpComp\Http\Message\Component\Collection; +use PhpComp\Http\Message\Request\RequestBody; +use PhpComp\Http\Message\Traits\CookiesTrait; +use PhpComp\Http\Message\Traits\RequestHeadersTrait; +use PhpComp\Http\Message\Traits\RequestTrait; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UriInterface; @@ -137,7 +137,8 @@ public function __construct( array $uploadedFiles = [], string $protocol = 'HTTP', string $protocolVersion = '1.1' - ) { + ) + { $this->setCookies($cookies); $this->initialize($protocol, $protocolVersion, $headers, $body ?: new RequestBody()); $this->initializeRequest($uri, $method); diff --git a/src/Stream.php b/src/Stream.php index 8e94535..839ada2 100644 --- a/src/Stream.php +++ b/src/Stream.php @@ -1,13 +1,13 @@ protocol = $protocol ?: 'http'; $this->protocolVersion = $protocolVersion ?: '1.1'; diff --git a/src/Traits/RequestHeadersTrait.php b/src/Traits/RequestHeadersTrait.php index 3b875c6..07da2a7 100644 --- a/src/Traits/RequestHeadersTrait.php +++ b/src/Traits/RequestHeadersTrait.php @@ -6,13 +6,13 @@ * Time: 16:22 */ -namespace Inhere\Http\Traits; +namespace PhpComp\Http\Message\Traits; /** * Trait RequestHeadersTrait - * @package Inhere\Http\Traits + * @package PhpComp\Http\Message\Traits * - * @property \Inhere\Http\Headers $headers + * @property \PhpComp\Http\Message\Headers $headers */ trait RequestHeadersTrait { diff --git a/src/Traits/RequestTrait.php b/src/Traits/RequestTrait.php index f977773..5aca96f 100644 --- a/src/Traits/RequestTrait.php +++ b/src/Traits/RequestTrait.php @@ -6,14 +6,14 @@ * Time: 下午12:44 */ -namespace Inhere\Http\Traits; +namespace PhpComp\Http\Message\Traits; -use Inhere\Http\Uri; +use PhpComp\Http\Message\Uri; use Psr\Http\Message\UriInterface; /** * Trait RequestTrait - * @package Inhere\Http\Traits + * @package PhpComp\Http\Message\Traits */ trait RequestTrait { @@ -173,7 +173,7 @@ public function isMethod($method): bool { return $this->getMethod() === strtoupper($method); } - + /** * request method is OPTIONS? */ @@ -181,7 +181,7 @@ public function isOptions(): bool { return $this->isMethod('OPTIONS'); } - + /** * request method is GET? */ @@ -205,7 +205,7 @@ public function isPut(): bool { return $this->isMethod('PUT'); } - + /** * request method is PATCH? */ @@ -213,7 +213,7 @@ public function isPatch(): bool { return $this->isMethod('PATCH'); } - + /** * request method is DELETE? */ @@ -221,7 +221,7 @@ public function isDelete(): bool { return $this->isMethod('DELETE'); } - + /** * @param $method * @return RequestTrait diff --git a/src/UploadedFile.php b/src/UploadedFile.php index 0669865..ecd956d 100644 --- a/src/UploadedFile.php +++ b/src/UploadedFile.php @@ -6,7 +6,7 @@ * Time: 17:58 */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; use Psr\Http\Message\StreamInterface; use Psr\Http\Message\UploadedFileInterface; @@ -141,7 +141,8 @@ public function __construct( int $size = null, int $error = \UPLOAD_ERR_OK, $sapi = false - ) { + ) + { $this->file = $file; $this->name = $name; $this->type = $type; diff --git a/src/Uri.php b/src/Uri.php index a952a79..133dcd1 100644 --- a/src/Uri.php +++ b/src/Uri.php @@ -7,13 +7,13 @@ * @from Slim-Http */ -namespace Inhere\Http; +namespace PhpComp\Http\Message; use Psr\Http\Message\UriInterface; /** * Class Uri - * @package Inhere\Http + * @package PhpComp\Http\Message */ class Uri implements UriInterface { @@ -86,7 +86,8 @@ public function __construct( $fragment = '', $user = '', $password = '' - ) { + ) + { $this->scheme = $scheme ? $this->filterScheme($scheme) : ''; $this->host = $host; $this->port = $this->filterPort($port); diff --git a/test/BodyTest.php b/test/BodyTest.php index 0b48906..4832057 100644 --- a/test/BodyTest.php +++ b/test/BodyTest.php @@ -6,15 +6,15 @@ * Time: 上午12:04 */ -namespace Inhere\Http\Test; +namespace PhpComp\Http\Message\Test; -use Inhere\Http\Body; +use PhpComp\Http\Message\Body; use PHPUnit\Framework\TestCase; use Psr\Http\Message\StreamInterface; /** * Class BodyTest - * @package Inhere\Http\Test + * @package PhpComp\Http\Message\Test */ class BodyTest extends TestCase { diff --git a/test/ClassCreateTest.php b/test/ClassCreateTest.php index d7613b3..ec804cf 100644 --- a/test/ClassCreateTest.php +++ b/test/ClassCreateTest.php @@ -6,13 +6,13 @@ * Time: 22:43 */ -namespace Inhere\Http\Test; +namespace PhpComp\Http\Message\Test; -use Inhere\Http\Body; -use Inhere\Http\Request; -use Inhere\Http\Response; -use Inhere\Http\ServerRequest; -use Inhere\Http\Uri; +use PhpComp\Http\Message\Body; +use PhpComp\Http\Message\Request; +use PhpComp\Http\Message\Response; +use PhpComp\Http\Message\ServerRequest; +use PhpComp\Http\Message\Uri; use PHPUnit\Framework\TestCase; use Psr\Http\Message\{ ServerRequestInterface, StreamInterface, ResponseInterface, RequestInterface, UriInterface @@ -20,7 +20,7 @@ /** * Class ClassCreateTest - * @package Inhere\Http\Test + * @package PhpComp\Http\Message\Test */ class ClassCreateTest extends TestCase { diff --git a/test/RequestTest.php b/test/RequestTest.php index e9bca2a..a08447d 100644 --- a/test/RequestTest.php +++ b/test/RequestTest.php @@ -6,15 +6,15 @@ * Time: 22:05 */ -namespace Inhere\Http\Test; +namespace PhpComp\Http\Message\Test; -use Inhere\Http\Request; +use PhpComp\Http\Message\Request; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; /** * Class RequestTest - * @package Inhere\Http\Test + * @package PhpComp\Http\Message\Test */ class RequestTest extends TestCase { diff --git a/test/ResponseTest.php b/test/ResponseTest.php index c3c16af..1344bac 100644 --- a/test/ResponseTest.php +++ b/test/ResponseTest.php @@ -6,15 +6,15 @@ * Time: 22:05 */ -namespace Inhere\Http\Test; +namespace PhpComp\Http\Message\Test; -use Inhere\Http\Response; +use PhpComp\Http\Message\Response; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; /** * Class ResponseTest - * @package Inhere\Http\Test + * @package PhpComp\Http\Message\Test */ class ResponseTest extends TestCase { diff --git a/test/ServerRequestTest.php b/test/ServerRequestTest.php index 7cad8fe..e720550 100644 --- a/test/ServerRequestTest.php +++ b/test/ServerRequestTest.php @@ -6,15 +6,15 @@ * Time: 22:05 */ -namespace Inhere\Http\Test; +namespace PhpComp\Http\Message\Test; -use Inhere\Http\ServerRequest; +use PhpComp\Http\Message\ServerRequest; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; /** * Class RequestTest - * @package Inhere\Http\Test + * @package PhpComp\Http\Message\Test */ class ServerRequestTest extends TestCase { diff --git a/test/boot.php b/test/boot.php index 7ed16e4..68a2820 100644 --- a/test/boot.php +++ b/test/boot.php @@ -8,8 +8,8 @@ $inhereDir = dirname(__DIR__, 2); $map = [ - 'Inhere\Http\Test\\' => __DIR__, - 'Inhere\Http\\' => dirname(__DIR__) . '/src', + 'PhpComp\Http\Message\Test\\' => __DIR__, + 'PhpComp\Http\Message\\' => dirname(__DIR__) . '/src', ]; spl_autoload_register(function ($class) use ($map) {