Skip to content

Optimize namespace #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/core/Server/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Reflection;
use ReflectionClass;
use ReflectionExtension;
use ReflectionFunction;
use ReflectionMethod;
use Swoole\Coroutine;
use Swoole\Http\Request;
use Swoole\Http\Response;
Expand Down Expand Up @@ -133,10 +135,7 @@ function ($server, $msg) {
$server->addCommand(
'server_setting',
$accepted_process_types,
function ($server, $msg) {
/**
* @var Server $server
*/
function (Server $server, $msg) {
$setting = $server->setting;
$setting['mode'] = $server->mode;
$setting['host'] = $server->host;
Expand Down Expand Up @@ -256,7 +255,7 @@ function ($server, $msg) {
$extensions = get_loaded_extensions();
$list = [];
foreach ($extensions as $key => $extension) {
$ext = new \ReflectionExtension($extension);
$ext = new ReflectionExtension($extension);
$list[$key] = [
'id' => ++$key,
'name' => $extension,
Expand Down Expand Up @@ -644,7 +643,7 @@ public static function handlerGetClassInfo($server, $msg)
}

if (!empty($json['class_name'])) {
if (!class_exists($json['class_name'], false)) {
if (!class_exists($json['class_name'], false) && !interface_exists($json['class_name'], false)) {
return self::json("{$json['class_name']} not exists", 4003);
}
$name = $json['class_name'];
Expand Down Expand Up @@ -720,7 +719,7 @@ public static function handlerGetClassInfo($server, $msg)
foreach ($data as $k => $v) {
$name = $v->getName();
$line = $v->getStartLine();
$modifiers = \Reflection::getModifierNames($v->getModifiers());
$modifiers = Reflection::getModifierNames($v->getModifiers());
if ($v->isStatic()) {
$static[] = [
'name' => $name,
Expand Down Expand Up @@ -782,13 +781,13 @@ public static function handlerGetFunctionInfo($server, $msg)
if (!method_exists($className, $functionName)) {
return self::json("{$className}->{$functionName} not exists", 4004);
}
$ref = new \ReflectionMethod($className, $functionName);
$ref = new ReflectionMethod($className, $functionName);
$isStatic = $ref->isStatic();
} else {
if (!function_exists($functionName)) {
return self::json("{$functionName} not exists", 4004);
}
$ref = new \ReflectionFunction($functionName);
$ref = new ReflectionFunction($functionName);
}

$result = [
Expand Down Expand Up @@ -921,7 +920,7 @@ public static function handlerGetDefinedFunctions($server, $msg)
$arr['internal'] = $functions['internal'];

foreach ($functions['user'] as $function_name) {
$function = new \ReflectionFunction($function_name);
$function = new ReflectionFunction($function_name);
$filename = $function->getFileName();
$line = $function->getStartLine();
$arr['user'][] = [
Expand Down