This commit is contained in:
2021-08-04 16:58:10 +08:00
parent 49ffb1386e
commit a04b4447b2
2 changed files with 10 additions and 5 deletions
-1
View File
@@ -229,7 +229,6 @@ class ServerManager extends Abstracts\Server
*/ */
private function addNewListener(string $type, string $host, int $port, int $mode, array $settings = []) private function addNewListener(string $type, string $host, int $port, int $mode, array $settings = [])
{ {
var_dump(func_get_args());
echo sprintf("\033[36m[" . date('Y-m-d H:i:s') . "]\033[0m $type service %s::%d start.", $host, $port) . PHP_EOL; echo sprintf("\033[36m[" . date('Y-m-d H:i:s') . "]\033[0m $type service %s::%d start.", $host, $port) . PHP_EOL;
/** @var Server\Port $service */ /** @var Server\Port $service */
$this->ports[$port] = $this->server->addlistener($host, $port, $mode); $this->ports[$port] = $this->server->addlistener($host, $port, $mode);
+10 -4
View File
@@ -107,9 +107,7 @@ class Container extends BaseObject
private function resolve($class, $constrict, $config): object private function resolve($class, $constrict, $config): object
{ {
$reflect = $this->resolveDependencies($class); $reflect = $this->resolveDependencies($class);
if ($reflect->isAbstract() || !$reflect->isInstantiable()) {
throw new ReflectionException('Class ' . $class . ' cannot be instantiated');
}
$object = $this->newInstance($reflect, $constrict); $object = $this->newInstance($reflect, $constrict);
$this->propertyInject($reflect, $object); $this->propertyInject($reflect, $object);
@@ -163,6 +161,7 @@ class Container extends BaseObject
* @param $className * @param $className
* @param $method * @param $method
* @return array * @return array
* @throws ReflectionException
*/ */
public function getMethodAttribute($className, $method = null): array public function getMethodAttribute($className, $method = null): array
{ {
@@ -178,6 +177,7 @@ class Container extends BaseObject
* @param string $class * @param string $class
* @param string|null $property * @param string|null $property
* @return ReflectionProperty|ReflectionProperty[]|null * @return ReflectionProperty|ReflectionProperty[]|null
* @throws ReflectionException
*/ */
public function getClassReflectionProperty(string $class, string $property = null): ReflectionProperty|null|array public function getClassReflectionProperty(string $class, string $property = null): ReflectionProperty|null|array
{ {
@@ -210,11 +210,14 @@ class Container extends BaseObject
/** /**
* @param $class * @param $class
* @return ReflectionClass * @return ReflectionClass
* @throws ReflectionException
*/ */
private function resolveDependencies($class): ReflectionClass private function resolveDependencies($class): ReflectionClass
{ {
$reflect = new ReflectionClass($class); $reflect = new ReflectionClass($class);
if ($reflect->isAbstract() || !$reflect->isInstantiable()) {
throw new ReflectionException('Class ' . $class . ' cannot be instantiated');
}
$this->setPropertyNote($reflect); $this->setPropertyNote($reflect);
$this->setTargetNote($reflect); $this->setTargetNote($reflect);
$this->setMethodNote($reflect); $this->setMethodNote($reflect);
@@ -229,6 +232,7 @@ class Container extends BaseObject
/** /**
* @param ReflectionClass|string $class * @param ReflectionClass|string $class
* @return ReflectionMethod[] * @return ReflectionMethod[]
* @throws ReflectionException
*/ */
public function getReflectMethods(ReflectionClass|string $class): array public function getReflectMethods(ReflectionClass|string $class): array
{ {
@@ -243,6 +247,7 @@ class Container extends BaseObject
* @param ReflectionClass|string $class * @param ReflectionClass|string $class
* @param string $method * @param string $method
* @return ReflectionMethod|null * @return ReflectionMethod|null
* @throws ReflectionException
*/ */
public function getReflectMethod(ReflectionClass|string $class, string $method): ?ReflectionMethod public function getReflectMethod(ReflectionClass|string $class, string $method): ?ReflectionMethod
{ {
@@ -341,6 +346,7 @@ class Container extends BaseObject
/** /**
* @param $class * @param $class
* @return ReflectionClass|null * @return ReflectionClass|null
* @throws ReflectionException
*/ */
public function getReflect($class): ?ReflectionClass public function getReflect($class): ?ReflectionClass
{ {