diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index 19d477e2..5ab7132b 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -154,7 +154,7 @@ class Annotation extends Component */ public function injectProperty(object $class) { - $this->_loader->injectProperty(get_class($class), $class); + $this->_loader->injectProperty($class::class, $class); } diff --git a/Annotation/Loader.php b/Annotation/Loader.php index a2b81d38..6224f36e 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -405,7 +405,7 @@ class Loader extends BaseObject $value->execute([$annotations['handler']]); } - $_className = get_class($annotations['handler']); + $_className = $annotations['handler']::class; foreach ($annotations['methods'] as $name => $attribute) { foreach ($attribute as $value) { if ($value instanceof Relation) { diff --git a/Annotation/LocalService.php b/Annotation/LocalService.php index 2edc4892..dfa70673 100644 --- a/Annotation/LocalService.php +++ b/Annotation/LocalService.php @@ -42,7 +42,7 @@ use Snowflake\Snowflake; */ public function execute(array $handler): mixed { - $class = ['class' => get_class($handler[0])]; + $class = ['class' => $handler[0]::class]; if (!empty($this->args)) { $class = array_merge($class, $this->args); } diff --git a/Annotation/Route/Filter.php b/Annotation/Route/Filter.php index 0d9b3518..fdd5731b 100644 --- a/Annotation/Route/Filter.php +++ b/Annotation/Route/Filter.php @@ -39,7 +39,7 @@ use Snowflake\Snowflake; /** @var HttpFilter $filter */ $filter = Snowflake::app()->get('filter'); - $filter->register(get_class($class), $method, $this->rules); + $filter->register($class::class, $method, $this->rules); return $handler; } diff --git a/HttpServer/Events/OnTask.php b/HttpServer/Events/OnTask.php index 07ef8f07..2ec8c931 100644 --- a/HttpServer/Events/OnTask.php +++ b/HttpServer/Events/OnTask.php @@ -113,7 +113,7 @@ class OnTask extends Callback if (is_object($params)) { $params = get_object_vars($params); } - $finish['class'] = get_class($serialize); + $finish['class'] = $serialize::class; $finish['params'] = $params; $finish['status'] = 'success'; $finish['info'] = $serialize->onHandler(); diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 0c6ae567..7445776e 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -111,7 +111,7 @@ class Node extends HttpService if (!($controller instanceof Controller)) { return $this; } - $this->annotationInject(get_class($controller), $action); + $this->annotationInject($controller::class, $action); } if (!empty($this->handler)) { $this->callback = Reduce::reduce($this->createDispatch(), $this->annotation()); diff --git a/Rpc/Producer.php b/Rpc/Producer.php index 2cd3fcbe..6b7acfc6 100644 --- a/Rpc/Producer.php +++ b/Rpc/Producer.php @@ -36,7 +36,7 @@ class Producer extends Component */ public function addProducer(string $name, array $handler, array $node) { - $this->classAlias[get_class($handler[0])] = $name; + $this->classAlias[$handler[0]::class] = $name; $this->consumers[$name] = $handler[0]; @@ -50,7 +50,7 @@ class Producer extends Component */ public function addConsumer(string $cmd, array $handler) { - $class = get_class($handler[0]); + $class = $handler[0]::class; if (!isset($this->classAlias[$class])) { return; diff --git a/System/Abstracts/BaseObject.php b/System/Abstracts/BaseObject.php index 6a836d88..356d398e 100644 --- a/System/Abstracts/BaseObject.php +++ b/System/Abstracts/BaseObject.php @@ -81,7 +81,7 @@ class BaseObject implements Configure $this->{$method}($value); } else { $this->error('set ' . $name . ' not exists ' . get_called_class()); - throw new Exception('The set name ' . $name . ' not find in class ' . get_class($this)); + throw new Exception('The set name ' . $name . ' not find in class ' . static::class); } } @@ -97,7 +97,7 @@ class BaseObject implements Configure if (method_exists($this, $method)) { return $this->$method(); } else { - throw new Exception('The get name ' . $name . ' not find in class ' . get_class($this)); + throw new Exception('The get name ' . $name . ' not find in class ' . static::class); } } diff --git a/System/Aop.php b/System/Aop.php index e40847a6..e71d301d 100644 --- a/System/Aop.php +++ b/System/Aop.php @@ -30,7 +30,7 @@ class Aop extends Component public function aop_add(array $handler, string $aspect) { [$class, $method] = $handler; - $alias = get_class($class) . '::' . $method; + $alias = $class::class . '::' . $method; if (!isset($this->_aop[$alias])) { $this->_aop[$alias] = []; } @@ -54,7 +54,7 @@ class Aop extends Component if ($handler instanceof \Closure) { return call_user_func($handler, ...$params); } - $aopName = get_class($handler[0]) . '::' . $handler[1]; + $aopName = $handler[0]::class . '::' . $handler[1]; if (!isset($this->_aop[$aopName])) { return $this->notFound($handler, $params); } diff --git a/System/Di/Container.php b/System/Di/Container.php index 4900ca2e..063cd04b 100644 --- a/System/Di/Container.php +++ b/System/Di/Container.php @@ -279,7 +279,7 @@ class Container extends BaseObject if (is_array($class) && isset($class['class'])) { $class = $class['class']; } else if (is_object($class)) { - $class = get_class($class); + $class = $class::class; } unset( $this->_reflection[$class], $this->_singletons[$class], diff --git a/System/Di/Service.php b/System/Di/Service.php index fccfe15b..2f2fe416 100644 --- a/System/Di/Service.php +++ b/System/Di/Service.php @@ -140,7 +140,7 @@ class Service extends Component public function remove($id): bool { $component = $this->_components[$id]; - $className = get_class($component); + $className = $component::class; unset($component, $this->_components[$id]); unset($this->_definition[$id]); diff --git a/System/Error/LoggerAspect.php b/System/Error/LoggerAspect.php index bb888619..37925973 100644 --- a/System/Error/LoggerAspect.php +++ b/System/Error/LoggerAspect.php @@ -45,7 +45,7 @@ class LoggerAspect implements IAspect private function print_runtime($startTime) { - $className = get_class($this->handler[0]); + $className = $this->handler[0]::class; $methodName = $this->handler[1]; $runTime = round(microtime(true) - $startTime, 6); diff --git a/function.php b/function.php index 035ac4cc..eb99bf67 100644 --- a/function.php +++ b/function.php @@ -827,7 +827,7 @@ if (!function_exists('jTraceEx')) { if (!$seen) $seen = array(); $trace = $e->getTrace(); $prev = $e->getPrevious(); - $result[] = sprintf('%s%s: %s', $starter, get_class($e), $e->getMessage()); + $result[] = sprintf('%s%s: %s', $starter, $e::class, $e->getMessage()); $file = $e->getFile(); $line = $e->getLine(); while (true) {