改名
This commit is contained in:
+13
-10
@@ -47,6 +47,8 @@ class Container extends BaseObject
|
||||
*/
|
||||
private array $_reflection = [];
|
||||
|
||||
private array $_reflectionProperty = [];
|
||||
|
||||
|
||||
private array $_property = [];
|
||||
|
||||
@@ -68,7 +70,7 @@ class Container extends BaseObject
|
||||
* @throws ReflectionException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function get($class, $constrict = [], $config = []): mixed
|
||||
public function get($class, array $constrict = [], array $config = []): mixed
|
||||
{
|
||||
if (isset($this->_singletons[$class])) {
|
||||
return $this->_singletons[$class];
|
||||
@@ -198,10 +200,10 @@ class Container extends BaseObject
|
||||
*/
|
||||
public function getClassProperty(string $class, string $property = null): ReflectionProperty|null|array
|
||||
{
|
||||
if (!isset($this->_property[$class])) {
|
||||
if (!isset($this->_reflectionProperty[$class])) {
|
||||
return null;
|
||||
}
|
||||
$properties = $this->_property[$class];
|
||||
$properties = $this->_reflectionProperty[$class];
|
||||
if (!empty($property)) {
|
||||
return $properties[$property] ?? null;
|
||||
}
|
||||
@@ -246,24 +248,25 @@ class Container extends BaseObject
|
||||
|
||||
/**
|
||||
* @param ReflectionClass $reflectionClass
|
||||
* @return $this
|
||||
* @return void
|
||||
*/
|
||||
private function scanProperty(ReflectionClass $reflectionClass): static
|
||||
private function scanProperty(ReflectionClass $reflectionClass): void
|
||||
{
|
||||
$lists = $reflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
|
||||
$properties = $reflectionClass->getProperties(ReflectionProperty::IS_PUBLIC |
|
||||
ReflectionProperty::IS_PRIVATE | ReflectionProperty::IS_PROTECTED
|
||||
);
|
||||
|
||||
$className = $reflectionClass->getName();
|
||||
foreach ($lists as $list) {
|
||||
$targets = $list->getAttributes(Inject::class);
|
||||
foreach ($properties as $property) {
|
||||
$targets = $property->getAttributes(Inject::class);
|
||||
if (count($targets) < 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->_property[$className][$list->getName()] = $targets[0]->newInstance();
|
||||
$this->_reflectionProperty[$className][$property->getName()] = $property;
|
||||
|
||||
$this->_property[$className][$property->getName()] = $targets[0]->newInstance();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -87,7 +87,7 @@ class Event extends BaseObject
|
||||
* @param bool $isAppend
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function on($name, $callback, $parameter = [], $isAppend = false)
|
||||
public static function on($name, $callback, array $parameter = [], bool $isAppend = false)
|
||||
{
|
||||
if (!isset(static::$_events[$name])) {
|
||||
static::$_events[$name] = [];
|
||||
@@ -204,7 +204,7 @@ class Event extends BaseObject
|
||||
* @return bool
|
||||
* @throws Exception
|
||||
*/
|
||||
public function dispatch($name, $params = [], $scope = null): bool
|
||||
public function dispatch($name, array $params = [], $scope = null): bool
|
||||
{
|
||||
return static::trigger($name, $params, $scope);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user