diff --git a/framework/yii/YiiBase.php b/framework/yii/YiiBase.php index cb2380a..2f2bf61 100644 --- a/framework/yii/YiiBase.php +++ b/framework/yii/YiiBase.php @@ -9,7 +9,6 @@ namespace yii; use yii\base\Exception; use yii\base\InvalidConfigException; use yii\base\InvalidParamException; -use yii\base\UnknownClassException; use yii\log\Logger; /** @@ -69,11 +68,6 @@ class YiiBase */ public static $classMap = array(); /** - * @var boolean whether to search PHP include_path when autoloading unknown classes. - * You may want to turn this off if you are also using autoloaders from other libraries. - */ - public static $enableIncludePath = false; - /** * @var \yii\console\Application|\yii\web\Application the application instance */ public static $app; @@ -338,12 +332,8 @@ class YiiBase * 3. If the class is named in PEAR style (e.g. `PHPUnit_Framework_TestCase`), * it will attempt to include the file associated with the corresponding path alias * (e.g. `@PHPUnit/Framework/TestCase.php`); - * 4. Search PHP include_path for the actual class file if [[enableIncludePath]] is true; - * 5. Return false so that other autoloaders have chance to include the class file. * - * @param string $className the fully qualified class name without leading \ - * @return boolean whether the class has been loaded successfully - * @throws UnknownClassException if the class does not exist in the class file + * @param string $className the fully qualified class name without a leading backslash "\" */ public static function autoload($className) { @@ -352,6 +342,7 @@ class YiiBase if ($classFile[0] === '@') { $classFile = static::getAlias($classFile); } + include($classFile); } else { // follow PSR-0 to determine the class file if (($pos = strrpos($className, '\\')) !== false) { @@ -367,27 +358,9 @@ class YiiBase $fullPath = static::getAlias('@' . $path, false); if ($fullPath !== false && is_file($fullPath)) { $classFile = $fullPath; + include($classFile); } } - - // search include_path - if (!isset($classFile) && self::$enableIncludePath && ($fullPath = stream_resolve_include_path($path)) !== false) { - $classFile = $fullPath; - } - - if (!isset($classFile)) { - // return false to let other autoloaders to try loading the class - return false; - } - } - - include($classFile); - - if (class_exists($className, false) || interface_exists($className, false) || - function_exists('trait_exists') && trait_exists($className, false)) { - return true; - } else { - throw new UnknownClassException("Unable to find '$className' in file: $classFile"); } } diff --git a/framework/yii/base/UnknownClassException.php b/framework/yii/base/UnknownClassException.php deleted file mode 100644 index 7b893d4..0000000 --- a/framework/yii/base/UnknownClassException.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @since 2.0 - */ -class UnknownClassException extends Exception -{ - /** - * @return string the user-friendly name of this exception - */ - public function getName() - { - return \Yii::t('yii', 'Unknown Class'); - } -} diff --git a/framework/yii/classes.php b/framework/yii/classes.php index 367cc9a..3c56749 100644 --- a/framework/yii/classes.php +++ b/framework/yii/classes.php @@ -37,7 +37,6 @@ return array( 'yii\base\Request' => YII_PATH . '/base/Request.php', 'yii\base\Response' => YII_PATH . '/base/Response.php', 'yii\base\Theme' => YII_PATH . '/base/Theme.php', - 'yii\base\UnknownClassException' => YII_PATH . '/base/UnknownClassException.php', 'yii\base\UnknownMethodException' => YII_PATH . '/base/UnknownMethodException.php', 'yii\base\UnknownPropertyException' => YII_PATH . '/base/UnknownPropertyException.php', 'yii\base\UserException' => YII_PATH . '/base/UserException.php',