This commit is contained in:
2021-09-29 17:32:56 +08:00
parent db56419dbc
commit 47be3285c5
7 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ namespace PHPSTORM_META {
use Kiri\Di\Container;
override(Container::get(0), map('@'));
override(Container::newObject(0), map('@'));
override(Container::create(0), map('@'));
// override(\Hyperf\Utils\Context::get(0), map('@'));
// override(\make(0), map('@'));
override(\di(0), map('@'));
+1 -1
View File
@@ -460,7 +460,7 @@ class ServerManager
*/
private function getNewInstance(string $class): object
{
return $this->container->newObject($class);
return $this->container->create($class);
}
+1 -1
View File
@@ -131,7 +131,7 @@ class Container extends BaseObject implements ContainerInterface
* @return object
* @throws
*/
public function newObject($class, array $constrict = [], array $config = []): object
public function create($class, array $constrict = [], array $config = []): object
{
return $this->resolve($class, $constrict, $config);
}
+1 -1
View File
@@ -180,7 +180,7 @@ class Kiri
} else if (is_array($className) && isset($className['class'])) {
$class = $className['class'];
unset($className['class']);
return static::$container->newObject($class, $construct, $className);
return static::$container->create($class, $construct, $className);
} else if (is_callable($className, TRUE)) {
return call_user_func($className, $construct);
} else {
+1 -1
View File
@@ -109,7 +109,7 @@ class Connection extends Component
public function create($coroutineName, $config): Closure
{
return static function () use ($coroutineName, $config) {
return Kiri::getDi()->newObject(PDO::class, [
return Kiri::getDi()->create(PDO::class, [
$config['database'], $config['cds'], $config['username'], $config['password'], $config['charset'] ?? 'utf8mb4'
]);
};
+1 -1
View File
@@ -50,7 +50,7 @@ class Redis extends Component
public function create(string $name, mixed $config): Closure
{
return static function () use ($name, $config) {
return Kiri::getDi()->newObject(\Kiri\Cache\Base\Redis::class, [
return Kiri::getDi()->create(\Kiri\Cache\Base\Redis::class, [
$config['host'], (int)$config['port'], $config['databases'] ?? 0,
$config['auth'], $config['prefix'] ?? '', $config['timeout'] ?? 30,
$config['read_timeout'] ?? 30
+1 -1
View File
@@ -94,7 +94,7 @@ use ReflectionProperty;
{
if (!Kiri::app()->has($this->value)) {
if (!empty($this->construct)) {
return Kiri::getDi()->newObject($this->value, $this->construct);
return Kiri::getDi()->create($this->value, $this->construct);
}
return Kiri::getDi()->get($this->value);
} else {