This commit is contained in:
2023-10-24 17:22:29 +08:00
parent 982e9d66bc
commit 115d228158
9 changed files with 14 additions and 15 deletions
+7 -6
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Kiri\Router\Constrict; namespace Kiri\Router\Constrict;
use Psr\Http\Message\StreamInterface; use Psr\Http\Message\StreamInterface;
use RuntimeException;
class Stream implements StreamInterface class Stream implements StreamInterface
{ {
@@ -93,7 +94,7 @@ class Stream implements StreamInterface
* Returns the current position of the file read/write pointer * Returns the current position of the file read/write pointer
* *
* @return int Position of the file pointer * @return int Position of the file pointer
* @throws \RuntimeException on error. * @throws RuntimeException on error.
*/ */
public function tell(): int public function tell(): int
{ {
@@ -133,7 +134,7 @@ class Stream implements StreamInterface
* PHP $whence values for `fseek()`. SEEK_SET: Set position equal to * PHP $whence values for `fseek()`. SEEK_SET: Set position equal to
* offset bytes SEEK_CUR: Set position to current location plus offset * offset bytes SEEK_CUR: Set position to current location plus offset
* SEEK_END: Set position to end-of-stream plus offset. * SEEK_END: Set position to end-of-stream plus offset.
* @throws \RuntimeException on failure. * @throws RuntimeException on failure.
*/ */
public function seek(int $offset, int $whence = SEEK_SET): void public function seek(int $offset, int $whence = SEEK_SET): void
{ {
@@ -149,7 +150,7 @@ class Stream implements StreamInterface
* If the stream is not seekable, this method will raise an exception; * If the stream is not seekable, this method will raise an exception;
* otherwise, it will perform a seek(0). * otherwise, it will perform a seek(0).
* *
* @throws \RuntimeException on failure. * @throws RuntimeException on failure.
* @link http://www.php.net/manual/en/function.fseek.php * @link http://www.php.net/manual/en/function.fseek.php
* @see seek() * @see seek()
*/ */
@@ -178,7 +179,7 @@ class Stream implements StreamInterface
* *
* @param string $string The string that is to be written. * @param string $string The string that is to be written.
* @return int Returns the number of bytes written to the stream. * @return int Returns the number of bytes written to the stream.
* @throws \RuntimeException on failure. * @throws RuntimeException on failure.
*/ */
public function write(string $string): int public function write(string $string): int
{ {
@@ -215,7 +216,7 @@ class Stream implements StreamInterface
* call returns fewer bytes. * call returns fewer bytes.
* @return string Returns the data read from the stream, or an empty string * @return string Returns the data read from the stream, or an empty string
* if no bytes are available. * if no bytes are available.
* @throws \RuntimeException if an error occurs. * @throws RuntimeException if an error occurs.
*/ */
public function read(int $length): string public function read(int $length): string
{ {
@@ -231,7 +232,7 @@ class Stream implements StreamInterface
* Returns the remaining contents in a string * Returns the remaining contents in a string
* *
* @return string * @return string
* @throws \RuntimeException if unable to read or an error occurs while * @throws RuntimeException if unable to read or an error occurs while
* reading. * reading.
*/ */
public function getContents(): string public function getContents(): string
-2
View File
@@ -5,8 +5,6 @@ namespace Kiri\Router;
use Closure; use Closure;
use Exception; use Exception;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use ReflectionClass; use ReflectionClass;
use ReflectionException; use ReflectionException;
use ReflectionMethod; use ReflectionMethod;
-1
View File
@@ -3,7 +3,6 @@
namespace Kiri\Router\Format; namespace Kiri\Router\Format;
use Kiri\Router\Constrict\Stream; use Kiri\Router\Constrict\Stream;
use Kiri\Router\ContentType;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
class OtherFormat implements IFormat class OtherFormat implements IFormat
+2 -1
View File
@@ -8,7 +8,8 @@ class ResponseFormat implements IFormat
{ {
/** /**
* @inheritDoc * @param $result
* @return ResponseInterface
*/ */
public function call($result): ResponseInterface public function call($result): ResponseInterface
{ {
+5
View File
@@ -7,6 +7,11 @@ interface ValidatorInterface
{ {
/**
* @param object $class
* @param string $name
* @return bool
*/
public function dispatch(object $class, string $name): bool; public function dispatch(object $class, string $name): bool;
} }
-1
View File
@@ -3,7 +3,6 @@ declare(strict_types=1);
namespace Kiri\Router; namespace Kiri\Router;
use Kiri\Di\Context;
use Kiri\Router\Base\AuthorizationInterface; use Kiri\Router\Base\AuthorizationInterface;
use Kiri\Router\Base\ExceptionHandlerDispatcher; use Kiri\Router\Base\ExceptionHandlerDispatcher;
use Psr\Http\Message\RequestInterface; use Psr\Http\Message\RequestInterface;
-2
View File
@@ -4,9 +4,7 @@ declare(strict_types=1);
namespace Kiri\Router; namespace Kiri\Router;
use InvalidArgumentException; use InvalidArgumentException;
use Kiri\Di\Context;
use Kiri\Di\Interface\ResponseEmitterInterface; use Kiri\Di\Interface\ResponseEmitterInterface;
use Kiri\Router\Constrict\ConstrictResponse;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface; use Psr\Http\Message\StreamInterface;
use ReflectionException; use ReflectionException;
-1
View File
@@ -8,7 +8,6 @@ use Exception;
use Kiri; use Kiri;
use Kiri\Router\Base\Middleware as MiddlewareManager; use Kiri\Router\Base\Middleware as MiddlewareManager;
use Kiri\Router\Constrict\RequestMethod; use Kiri\Router\Constrict\RequestMethod;
use Kiri\Server\Events\OnWorkerStart;
use ReflectionException; use ReflectionException;
/** /**
-1
View File
@@ -36,7 +36,6 @@ class StreamResponse extends Response
$response->write($body->read($this->limit)); $response->write($body->read($this->limit));
} }
$response->end(); $response->end();
// event(new OnAfterRequest());
} }
} }