改名
This commit is contained in:
@@ -9,7 +9,6 @@ use Exception;
|
|||||||
use ReflectionClass;
|
use ReflectionClass;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Snowflake\Abstracts\BaseObject;
|
use Snowflake\Abstracts\BaseObject;
|
||||||
use Snowflake\Exception\NotFindClassException;
|
|
||||||
use Snowflake\Snowflake;
|
use Snowflake\Snowflake;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
@@ -48,6 +47,7 @@ class Loader extends BaseObject
|
|||||||
* @param string $class
|
* @param string $class
|
||||||
* @param string $property
|
* @param string $property
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public function getProperty(string $class, string $property = ''): mixed
|
public function getProperty(string $class, string $property = ''): mixed
|
||||||
{
|
{
|
||||||
@@ -67,7 +67,6 @@ class Loader extends BaseObject
|
|||||||
* @param string $class
|
* @param string $class
|
||||||
* @param object $handler
|
* @param object $handler
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws NotFindClassException
|
|
||||||
* @throws ReflectionException
|
* @throws ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@@ -138,7 +137,9 @@ class Loader extends BaseObject
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$replace = $this->getReflect($path, $namespace);
|
$replace = $this->getReflect($path, $namespace);
|
||||||
|
if (!$replace->getAttributes(Target::class)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->appendFileToDirectory($path->getRealPath(), $replace->getName());
|
$this->appendFileToDirectory($path->getRealPath(), $replace->getName());
|
||||||
|
|
||||||
static::$_classes[] = $replace->getName();
|
static::$_classes[] = $replace->getName();
|
||||||
@@ -152,7 +153,6 @@ class Loader extends BaseObject
|
|||||||
* @param DirectoryIterator $path
|
* @param DirectoryIterator $path
|
||||||
* @param string $namespace
|
* @param string $namespace
|
||||||
* @return ReflectionClass|null
|
* @return ReflectionClass|null
|
||||||
* @throws ReflectionException
|
|
||||||
*/
|
*/
|
||||||
private function getReflect(DirectoryIterator $path, string $namespace): ?ReflectionClass
|
private function getReflect(DirectoryIterator $path, string $namespace): ?ReflectionClass
|
||||||
{
|
{
|
||||||
|
|||||||
+4
-10
@@ -107,7 +107,9 @@ 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->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);
|
||||||
@@ -161,7 +163,6 @@ 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
|
||||||
{
|
{
|
||||||
@@ -177,7 +178,6 @@ 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,14 +210,11 @@ 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);
|
||||||
@@ -232,7 +229,6 @@ 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
|
||||||
{
|
{
|
||||||
@@ -247,7 +243,6 @@ 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
|
||||||
{
|
{
|
||||||
@@ -346,7 +341,6 @@ 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
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user