Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
f576add9
Commit
f576add9
authored
Aug 11, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #744: simplified Yii autoloader.
parent
ce4f37a1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
56 deletions
+3
-56
YiiBase.php
framework/yii/YiiBase.php
+3
-30
UnknownClassException.php
framework/yii/base/UnknownClassException.php
+0
-25
classes.php
framework/yii/classes.php
+0
-1
No files found.
framework/yii/YiiBase.php
View file @
f576add9
...
...
@@ -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
"
);
}
}
...
...
framework/yii/base/UnknownClassException.php
deleted
100644 → 0
View file @
ce4f37a1
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\base
;
/**
* UnknownClassException represents an exception caused by accessing an unknown class.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @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'
);
}
}
framework/yii/classes.php
View file @
f576add9
...
...
@@ -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'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment