eee
This commit is contained in:
@@ -3,14 +3,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Delete extends AbstractRequestMethod implements InjectRouteInterface
|
||||
class Delete extends AbstractRequestMethod implements InjectMethodInterface
|
||||
{
|
||||
|
||||
|
||||
@@ -24,14 +22,13 @@ class Delete extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
$controller = \Kiri::getDi()->makeReflection($class);
|
||||
$controller = \Kiri::getDi()->get($class);
|
||||
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
|
||||
+5
-10
@@ -3,16 +3,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Exception;
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Router\OptionsController;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Get extends AbstractRequestMethod implements InjectRouteInterface
|
||||
class Get extends AbstractRequestMethod implements InjectMethodInterface
|
||||
{
|
||||
|
||||
|
||||
@@ -26,14 +22,13 @@ class Get extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
$controller = \Kiri::getDi()->makeReflection($class);
|
||||
$controller = \Kiri::getDi()->get($class);
|
||||
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
|
||||
@@ -5,13 +5,11 @@ namespace Kiri\Router\Annotate;
|
||||
|
||||
use Kiri;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Head extends AbstractRequestMethod implements InjectRouteInterface
|
||||
class Head extends AbstractRequestMethod implements InjectMethodInterface
|
||||
{
|
||||
|
||||
|
||||
@@ -25,14 +23,13 @@ class Head extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
$controller = Kiri::getDi()->makeReflection($class);
|
||||
$controller = Kiri::getDi()->get($class);
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
|
||||
@@ -4,11 +4,10 @@ declare(strict_types=1);
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use ReflectionClass;
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)]
|
||||
class Interceptor implements InjectRouteInterface
|
||||
class Interceptor implements InjectMethodInterface
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
@@ -17,11 +16,11 @@ class Interceptor implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
use Kiri\Router\Base\Middleware as MiddlewareManager;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use ReflectionClass;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Middleware implements InjectRouteInterface
|
||||
class Middleware implements InjectMethodInterface
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -20,15 +19,15 @@ class Middleware implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
$middlewareManager = \Kiri::getDi()->get(MiddlewareManager::class);
|
||||
|
||||
$middlewareManager->set($class->getName(), $method, $this->middleware);
|
||||
$middlewareManager->set($class, $method, $this->middleware);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@ namespace Kiri\Router\Annotate;
|
||||
|
||||
use Kiri;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionClass;
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Options extends AbstractRequestMethod implements InjectRouteInterface
|
||||
class Options extends AbstractRequestMethod implements InjectMethodInterface
|
||||
{
|
||||
|
||||
|
||||
@@ -29,9 +28,9 @@ class Options extends AbstractRequestMethod implements InjectRouteInterface
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
$controller = Kiri::getDi()->makeReflection($class);
|
||||
$controller = Kiri::getDi()->get($class);
|
||||
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
|
||||
@@ -5,13 +5,11 @@ namespace Kiri\Router\Annotate;
|
||||
|
||||
use Kiri;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Post extends AbstractRequestMethod implements InjectRouteInterface
|
||||
class Post extends AbstractRequestMethod implements InjectMethodInterface
|
||||
{
|
||||
|
||||
|
||||
@@ -25,15 +23,14 @@ class Post extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
$controller = Kiri::getDi()->makeReflection($class);
|
||||
$controller = Kiri::getDi()->get($class);
|
||||
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
|
||||
@@ -5,12 +5,14 @@ namespace Kiri\Router\Annotate;
|
||||
|
||||
use Kiri;
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionClass;
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Put extends AbstractRequestMethod implements InjectRouteInterface
|
||||
class Put extends AbstractRequestMethod implements InjectMethodInterface
|
||||
{
|
||||
|
||||
|
||||
@@ -24,14 +26,13 @@ class Put extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param object $class
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
$controller = Kiri::getDi()->makeReflection($class);
|
||||
$controller = Kiri::getDi()->get($class);
|
||||
// TODO: Implement dispatch() method.
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
namespace Kiri\Router\Annotate;
|
||||
|
||||
use Kiri\Router\Constrict\RequestMethod;
|
||||
use Kiri\Router\Interface\InjectRouteInterface;
|
||||
use Kiri\Router\Router;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Route extends AbstractRequestMethod implements InjectRouteInterface
|
||||
class Route extends AbstractRequestMethod implements InjectMethodInterface
|
||||
{
|
||||
|
||||
|
||||
@@ -24,15 +22,13 @@ class Route extends AbstractRequestMethod implements InjectRouteInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
$controller = \Kiri::getDi()->makeReflection($class);
|
||||
// TODO: Implement dispatch() method.
|
||||
$controller = \Kiri::getDi()->get($class);
|
||||
$path = '/' . ltrim($this->path, '/');
|
||||
if (!empty($this->version)) {
|
||||
$path = '/' . trim($this->version) . $path;
|
||||
|
||||
+5
-41
@@ -3,11 +3,11 @@
|
||||
namespace Kiri\Router\Aspect;
|
||||
|
||||
|
||||
use Kiri\Di\Interface\InjectProxyInterface;
|
||||
use Kiri\Di\Interface\InjectMethodInterface;
|
||||
use PhpParser\ParserFactory;
|
||||
|
||||
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::TARGET_CLASS)]
|
||||
class Aspect implements InjectProxyInterface
|
||||
#[\Attribute(\Attribute::TARGET_METHOD)]
|
||||
class Aspect implements InjectMethodInterface
|
||||
{
|
||||
|
||||
|
||||
@@ -20,48 +20,12 @@ class Aspect implements InjectProxyInterface
|
||||
|
||||
|
||||
/**
|
||||
* @param string $fileName
|
||||
* @param object $class
|
||||
* @param string $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch(string $fileName, object $class, string $method): void
|
||||
public function dispatch(string $class, string $method): void
|
||||
{
|
||||
// TODO: Implement dispatch() method.
|
||||
try {
|
||||
$parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7);
|
||||
$ast = $parser->parse(file_get_contents($fileName));
|
||||
|
||||
$cacheFile = storage('proxy_functions.php');
|
||||
if (!file_exists($cacheFile)) {
|
||||
file_put_contents($cacheFile, '<?php' . PHP_EOL);
|
||||
}
|
||||
|
||||
$functionName = str_replace('\\', '_', $class::class) . '_' . $method;
|
||||
$code = $this->generateClourse($functionName) . PHP_EOL;
|
||||
|
||||
file_put_contents($cacheFile, $code, FILE_APPEND);
|
||||
} catch (\Throwable $throwable) {
|
||||
die(throwable($throwable));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function generateClourse($functionName): string
|
||||
{
|
||||
return <<<PHP
|
||||
if (!function_exists($functionName)) {
|
||||
|
||||
/**
|
||||
* @param mixed \$message
|
||||
* @param string \$method
|
||||
* @throws Exception
|
||||
*/
|
||||
function $functionName(mixed \$message, string \$method = 'app')
|
||||
{
|
||||
}
|
||||
}
|
||||
PHP;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Kiri\Router\Interface;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
interface InjectRouteInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $class
|
||||
* @param string $method
|
||||
* @return void
|
||||
*/
|
||||
public function dispatch(ReflectionClass $class, string $method): void;
|
||||
|
||||
}
|
||||
@@ -7,7 +7,6 @@ use Kiri\Di\Inject\Config;
|
||||
use Kiri\Di\Inject\Container;
|
||||
use Kiri\Di\Interface\InjectParameterInterface;
|
||||
use Kiri\Router\Base\Middleware;
|
||||
use Kiri\Router\Validator\RequestFilter\RequestFilterInterface;
|
||||
use Kiri\Router\Validator\Types\ArrayProxy;
|
||||
use Kiri\Router\Validator\Types\BoolProxy;
|
||||
use Kiri\Router\Validator\Types\FloatProxy;
|
||||
@@ -19,8 +18,11 @@ use Kiri\Server\ServerInterface;
|
||||
use ReflectionNamedType;
|
||||
use ReflectionProperty;
|
||||
use ReflectionUnionType;
|
||||
use function inject;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_PARAMETER)]
|
||||
class BindForm implements InjectParameterInterface
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace Kiri\Router\Validator;
|
||||
|
||||
use Kiri;
|
||||
use Kiri\Router\Interface\ValidatorInterface;
|
||||
use Kiri\Router\Validator\RequestFilter\BetweenValidatorFilter;
|
||||
use Kiri\Router\Validator\RequestFilter\InValidatorFilter;
|
||||
use Kiri\Router\Validator\RequestFilter\LengthValidatorFilter;
|
||||
|
||||
Reference in New Issue
Block a user