|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
namespace Qii\Autoloader;
|
|
|
|
|
|
+use Qii\Exceptions\CallUndefinedClass;
|
|
|
use Qii\Exceptions\FileNotFound;
|
|
|
|
|
|
/**
|
|
@@ -276,7 +277,6 @@ class Psr4
|
|
|
/**
|
|
|
* 通过类名加载文件
|
|
|
* @param string $class 类名
|
|
|
- * @return string 文件路径
|
|
|
* @throws FileNotFound
|
|
|
*/
|
|
|
public function loadFileByClass($class)
|
|
@@ -456,6 +456,9 @@ class Psr4
|
|
|
public function instance()
|
|
|
{
|
|
|
$args = func_get_args();
|
|
|
+ if (empty($args)) {
|
|
|
+ throw new InvalidParams("Param is null");
|
|
|
+ }
|
|
|
$class = array_shift($args);
|
|
|
$className = $this->getClassName($class);
|
|
|
//如果实例化的参数发生变化,就重新实例化
|
|
@@ -466,7 +469,7 @@ class Psr4
|
|
|
self::$_loadedClassParams[$className] = $paramsHash;
|
|
|
|
|
|
if (!class_exists($className, false)) {
|
|
|
- throw new \Qii\Exceptions\CallUndefinedClass(\Qii::i('1105', $className), __LINE__);
|
|
|
+ throw new CallUndefinedClass(\Qii::i('1105', $className), __LINE__);
|
|
|
}
|
|
|
$refClass = new \ReflectionClass($className);
|
|
|
self::$_loadedClass[$className] = $instance = $refClass->newInstanceArgs($args);
|