Revert "改名"

This reverts commit fdf58326
This commit is contained in:
2022-01-08 18:49:08 +08:00
parent 7165a67294
commit 97cd1a0ebf
33 changed files with 169 additions and 172 deletions
+9 -18
View File
@@ -10,26 +10,18 @@ declare(strict_types=1);
namespace Kiri\Abstracts;
use Note\Note as SNote;
use Database\Connection;
use Exception;
use Http\Handler\Router;
use Kiri\Events\OnBeforeCommandExecute;
use Server\Server;
use Kafka\KafkaProvider;
use Kiri\Async;
use Kiri\{Async, Kiri};
use Kiri\Annotation\Annotation as SAnnotation;
use Kiri\Cache\Redis;
use Kiri\Di\LocalService;
use Kiri\Error\ErrorHandler;
use Kiri\Error\Logger;
use Kiri\Events\EventProvider;
use Kiri\Exception\InitException;
use Kiri\Exception\NotFindClassException;
use Kiri\Kiri;
use Kiri\Error\{ErrorHandler, Logger};
use Kiri\Exception\{InitException, NotFindClassException};
use ReflectionException;
use Server\ServerManager;
use Server\Contract\OnTaskInterface;
use Server\Tasker\AsyncTaskExecute;
use Server\{Contract\OnTaskInterface, Server, ServerManager, Tasker\AsyncTaskExecute};
use Swoole\Table;
/**
@@ -392,12 +384,12 @@ abstract class BaseApplication extends Component
/**
* @return SNote
* @return SAnnotation
* @throws
*/
public function getNote(): SNote
public function getAnnotation(): SAnnotation
{
return $this->get('note');
return $this->get('Annotation');
}
@@ -411,7 +403,6 @@ abstract class BaseApplication extends Component
}
/**
* @param $array
*/
@@ -450,7 +441,7 @@ abstract class BaseApplication extends Component
'error' => ['class' => ErrorHandler::class],
'config' => ['class' => Config::class],
'logger' => ['class' => Logger::class],
'note' => ['class' => SNote::class],
'Annotation' => ['class' => SAnnotation::class],
'databases' => ['class' => Connection::class],
'jwt' => ['class' => Jwt::class],
'async' => ['class' => Async::class],
+2 -7
View File
@@ -4,14 +4,11 @@
namespace Kiri\Abstracts;
use Note\Note as SNote;
use Kiri\Annotation\Annotation as SAnnotation;
use Database\Connection;
use Database\DatabasesProviders;
use Http\Handler\Client\Client;
use Http\Handler\Client\Curl;
use Http\Handler\Router;
use Server\Server;
use Kiri\Crontab\Producer;
use Kiri\Async;
use Kiri\Error\Logger;
use Kiri\Jwt\JWTAuth;
@@ -25,11 +22,9 @@ use Kiri\Jwt\JWTAuth;
* @property Async $async
* @property Logger $logger
* @property JWTAuth $jwt
* @property SNote $annotation
* @property SAnnotation $annotation
* @property BaseGoto $goto
* @property Client $client
* @property Connection $databases
* @property Curl $curl
*/
trait TraitApplication
{
+9 -16
View File
@@ -13,25 +13,22 @@ namespace Kiri;
use Closure;
use Database\DatabasesProviders;
use Exception;
use Kiri\Abstracts\BaseApplication;
use Kiri\Abstracts\Config;
use Kiri\Abstracts\Kernel;
use Kiri\Abstracts\{BaseApplication, Config, Kernel};
use Kiri\Crontab\CrontabProviders;
use Kiri\Events\OnAfterCommandExecute;
use Kiri\Events\OnBeforeCommandExecute;
use Kiri\Exception\NotFindClassException;
use Kiri\Events\{OnAfterCommandExecute, OnBeforeCommandExecute};
use Kiri\FileListen\HotReload;
use ReflectionException;
use Server\ServerProviders;
use stdClass;
use Swoole\Process;
use Swoole\Timer;
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\{Application as ConsoleApplication,
Command\Command,
Input\ArgvInput,
Input\InputInterface,
Output\ConsoleOutput,
Output\OutputInterface
};
/**
* Class Init
@@ -213,7 +210,6 @@ class Application extends BaseApplication
}
/**
* @param $argv
* @return array
@@ -224,7 +220,6 @@ class Application extends BaseApplication
}
/**
* @throws ReflectionException
* @throws Exception
@@ -244,8 +239,6 @@ class Application extends BaseApplication
}
/**
* @param $className
* @param null $abstracts
+1 -1
View File
@@ -17,7 +17,7 @@ use Kiri\Events\EventProvider;
use Kiri\Exception\ConfigException;
use Kiri\Kiri;
use Kiri\Pool\Redis as PoolRedis;
use Note\Inject;
use Kiri\Annotation\Inject;
use Server\Events\OnWorkerExit;
use Swoole\Timer;
+6 -6
View File
@@ -9,7 +9,7 @@ declare(strict_types=1);
namespace Kiri\Di;
use Note\Inject;
use Kiri\Annotation\Inject;
use Closure;
use Exception;
use Kiri\Abstracts\Logger;
@@ -197,7 +197,7 @@ class Container implements ContainerInterface
*/
public function propertyInject(ReflectionClass $reflect, $object): mixed
{
foreach (NoteManager::getPropertyNote($reflect) as $property => $inject) {
foreach (AnnotationManager::getPropertyAnnotation($reflect) as $property => $inject) {
/** @var Inject $inject */
$inject->execute($object, $property);
}
@@ -212,7 +212,7 @@ class Container implements ContainerInterface
*/
public function getMethodAttribute($className, $method = null): array
{
$methods = NoteManager::getMethodNote($this->getReflect($className));
$methods = AnnotationManager::getMethodAnnotation($this->getReflect($className));
if (!empty($method)) {
return $methods[$method] ?? [];
}
@@ -227,7 +227,7 @@ class Container implements ContainerInterface
*/
public function getClassReflectionProperty(string $class, string $property = null): ReflectionProperty|null|array
{
$lists = NoteManager::getProperty($this->getReflect($class));
$lists = AnnotationManager::getProperty($this->getReflect($class));
if (empty($lists)) {
return null;
}
@@ -266,7 +266,7 @@ class Container implements ContainerInterface
if ($reflect->isAbstract() || $reflect->isTrait() || $reflect->isInterface()) {
return $this->_reflection[$class] = $reflect;
}
$construct = NoteManager::resolveTarget($reflect);
$construct = AnnotationManager::resolveTarget($reflect);
if (!empty($construct) && $construct->getNumberOfParameters() > 0) {
$this->_constructs[$class] = $construct;
}
@@ -284,7 +284,7 @@ class Container implements ContainerInterface
if (is_string($class)) {
$class = $this->getReflect($class);
}
return NoteManager::getMethods($class);
return AnnotationManager::getMethods($class);
}
+22 -22
View File
@@ -7,14 +7,14 @@ use ReflectionAttribute;
use ReflectionClass;
use ReflectionProperty;
class NoteManager
class AnnotationManager
{
private static array $_classTarget = [];
private static array $_classMethodNote = [];
private static array $_classMethodAnnotation = [];
private static array $_classMethod = [];
private static array $_classPropertyNote = [];
private static array $_classPropertyAnnotation = [];
private static array $_classProperty = [];
private static array $_mapping = [];
@@ -25,9 +25,9 @@ class NoteManager
public static function clear()
{
static::$_classTarget = [];
static::$_classMethodNote = [];
static::$_classMethodAnnotation = [];
static::$_classMethod = [];
static::$_classPropertyNote = [];
static::$_classPropertyAnnotation = [];
static::$_classProperty = [];
static::$_mapping = [];
}
@@ -36,7 +36,7 @@ class NoteManager
/**
* @param ReflectionClass $class
*/
public static function setTargetNote(ReflectionClass $class)
public static function setTargetAnnotation(ReflectionClass $class)
{
$className = $class->getName();
if (!isset(static::$_classTarget[$className])) {
@@ -111,7 +111,7 @@ class NoteManager
* @param mixed $class
* @return array
*/
public static function getTargetNote(mixed $class): array
public static function getTargetAnnotation(mixed $class): array
{
if (!is_string($class)) {
$class = $class::class;
@@ -123,20 +123,20 @@ class NoteManager
/**
* @param ReflectionClass $class
*/
public static function setMethodNote(ReflectionClass $class)
public static function setMethodAnnotation(ReflectionClass $class)
{
$className = $class->getName();
static::$_classMethodNote[$className] = static::$_classMethod[$className] = [];
static::$_classMethodAnnotation[$className] = static::$_classMethod[$className] = [];
foreach ($class->getMethods() as $ReflectionMethod) {
static::$_classMethod[$className][$ReflectionMethod->getName()] = $ReflectionMethod;
static::$_classMethodNote[$className][$ReflectionMethod->getName()] = [];
static::$_classMethodAnnotation[$className][$ReflectionMethod->getName()] = [];
foreach ($ReflectionMethod->getAttributes() as $attribute) {
if (!class_exists($attribute->getName())) {
continue;
}
$instance = $attribute->newInstance();
static::$_classMethodNote[$className][$ReflectionMethod->getName()][] = $instance;
static::$_classMethodAnnotation[$className][$ReflectionMethod->getName()][] = $instance;
self::setMappingMethod($attribute, $className, $ReflectionMethod->getName(), $instance);
}
@@ -159,9 +159,9 @@ class NoteManager
* @param ReflectionClass $class
* @return array
*/
#[Pure] public static function getMethodNote(ReflectionClass $class): array
#[Pure] public static function getMethodAnnotation(ReflectionClass $class): array
{
return static::$_classMethodNote[$class->getName()] ?? [];
return static::$_classMethodAnnotation[$class->getName()] ?? [];
}
@@ -171,9 +171,9 @@ class NoteManager
*/
public static function resolveTarget(ReflectionClass $reflect): ?\ReflectionMethod
{
NoteManager::setPropertyNote($reflect);
NoteManager::setTargetNote($reflect);
NoteManager::setMethodNote($reflect);
AnnotationManager::setPropertyAnnotation($reflect);
AnnotationManager::setTargetAnnotation($reflect);
AnnotationManager::setMethodAnnotation($reflect);
return $reflect->getConstructor();
}
@@ -182,10 +182,10 @@ class NoteManager
/**
* @param ReflectionClass $class
*/
public static function setPropertyNote(ReflectionClass $class)
public static function setPropertyAnnotation(ReflectionClass $class)
{
$className = $class->getName();
static::$_classProperty[$className] = static::$_classPropertyNote[$className] = [];
static::$_classProperty[$className] = static::$_classPropertyAnnotation[$className] = [];
foreach ($class->getProperties(ReflectionProperty::IS_PRIVATE | ReflectionProperty::IS_PUBLIC |
ReflectionProperty::IS_PROTECTED) as $ReflectionMethod) {
static::$_classProperty[$className][$ReflectionMethod->getName()] = $ReflectionMethod;
@@ -196,7 +196,7 @@ class NoteManager
$instance = $attribute->newInstance();
static::$_classPropertyNote[$className][$ReflectionMethod->getName()] = $instance;
static::$_classPropertyAnnotation[$className][$ReflectionMethod->getName()] = $instance;
self::setMappingProperty($attribute, $className, $ReflectionMethod->getName(), $instance);
}
@@ -250,7 +250,7 @@ class NoteManager
* @param string $method
* @return mixed
*/
public static function getPropertyByNote(string $attribute, string $class, string $method): mixed
public static function getPropertyByAnnotation(string $attribute, string $class, string $method): mixed
{
$class = self::getAttributeTrees($attribute, $class);
if (empty($class) || !isset($class['property'])) {
@@ -294,9 +294,9 @@ class NoteManager
* @param ReflectionClass $class
* @return array
*/
#[Pure] public static function getPropertyNote(ReflectionClass $class): array
#[Pure] public static function getPropertyAnnotation(ReflectionClass $class): array
{
return static::$_classPropertyNote[$class->getName()] ?? [];
return static::$_classPropertyAnnotation[$class->getName()] ?? [];
}
+1 -1
View File
@@ -13,7 +13,7 @@ use Exception;
use Kiri\Abstracts\Component;
use Kiri\Core\Json;
use Kiri\Kiri;
use Note\Inject;
use Kiri\Annotation\Inject;
use Psr\Log\LoggerInterface;
use Throwable;
+1 -1
View File
@@ -8,7 +8,7 @@ use Kiri\Core\Json;
use Kiri\Error\Logger;
use Kiri\Exception\ConfigException;
use Kiri\Kiri;
use Note\Inject;
use Kiri\Annotation\Inject;
use Swoole\Coroutine;
use Swoole\Process;
use Swoole\Timer;
+4 -4
View File
@@ -7,7 +7,7 @@ namespace Kiri;
error_reporting(0);
use Note\Note;
use Kiri\Annotation\Annotation;
use Database\Collection;
use Database\ModelInterface;
use Exception;
@@ -159,12 +159,12 @@ class Kiri
/**
* @return Note
* @return Annotation
* @throws Exception
*/
public static function getNote(): Note
public static function getAnnotation(): Annotation
{
return static::app()->getNote();
return static::app()->getAnnotation();
}
+1 -1
View File
@@ -44,7 +44,7 @@ class Runtime extends Command
public function execute(InputInterface $input, OutputInterface $output): int
{
// TODO: Implement onHandler() method.
$annotation = Kiri::app()->getNote();
$annotation = Kiri::app()->getAnnotation();
$runtime = storage(static::CACHE_NAME);
$config = storage(static::CONFIG_NAME);