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
bb2274ea
Commit
bb2274ea
authored
Aug 18, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
re-added Exception about wrong class name to autoloader
helps reducing weird error messages.
parent
5e759790
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
4 deletions
+42
-4
YiiBase.php
framework/yii/YiiBase.php
+17
-4
UnknownClassException.php
framework/yii/base/UnknownClassException.php
+25
-0
No files found.
framework/yii/YiiBase.php
View file @
bb2274ea
...
@@ -9,6 +9,7 @@ namespace yii;
...
@@ -9,6 +9,7 @@ namespace yii;
use
yii\base\Exception
;
use
yii\base\Exception
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidParamException
;
use
yii\base\InvalidParamException
;
use
yii\base\UnknownClassException
;
use
yii\log\Logger
;
use
yii\log\Logger
;
/**
/**
...
@@ -333,7 +334,11 @@ class YiiBase
...
@@ -333,7 +334,11 @@ class YiiBase
* it will attempt to include the file associated with the corresponding path alias
* it will attempt to include the file associated with the corresponding path alias
* (e.g. `@PHPUnit/Framework/TestCase.php`);
* (e.g. `@PHPUnit/Framework/TestCase.php`);
*
*
* This autoloader allows loading classes that follow the [PSR-0 standard](http://www.php-fig.org/psr/0/).
* Therefor a path alias has to be defined for each top-level namespace.
*
* @param string $className the fully qualified class name without a leading backslash "\"
* @param string $className the fully qualified class name without a leading backslash "\"
* @throws UnknownClassException if the class does not exist in the class file
*/
*/
public
static
function
autoload
(
$className
)
public
static
function
autoload
(
$className
)
{
{
...
@@ -342,7 +347,6 @@ class YiiBase
...
@@ -342,7 +347,6 @@ class YiiBase
if
(
$classFile
[
0
]
===
'@'
)
{
if
(
$classFile
[
0
]
===
'@'
)
{
$classFile
=
static
::
getAlias
(
$classFile
);
$classFile
=
static
::
getAlias
(
$classFile
);
}
}
include
(
$classFile
);
}
else
{
}
else
{
// follow PSR-0 to determine the class file
// follow PSR-0 to determine the class file
if
((
$pos
=
strrpos
(
$className
,
'\\'
))
!==
false
)
{
if
((
$pos
=
strrpos
(
$className
,
'\\'
))
!==
false
)
{
...
@@ -354,13 +358,22 @@ class YiiBase
...
@@ -354,13 +358,22 @@ class YiiBase
}
}
// try loading via path alias
// try loading via path alias
if
(
strpos
(
$path
,
'/'
)
!==
false
)
{
if
(
strpos
(
$path
,
'/'
)
===
false
)
{
return
;
}
else
{
$classFile
=
static
::
getAlias
(
'@'
.
$path
,
false
);
$classFile
=
static
::
getAlias
(
'@'
.
$path
,
false
);
if
(
$classFile
!==
false
&&
is_file
(
$classFile
))
{
if
(
$classFile
===
false
||
!
is_file
(
$classFile
))
{
include
(
$classFile
)
;
return
;
}
}
}
}
}
}
include
(
$classFile
);
if
(
!
class_exists
(
$className
,
false
)
&&
!
interface_exists
(
$className
,
false
)
&&
(
!
function_exists
(
'trait_exists'
)
||
!
trait_exists
(
$className
,
false
)))
{
throw
new
UnknownClassException
(
"Unable to find '
$className
' in file:
$classFile
"
);
}
}
}
/**
/**
...
...
framework/yii/base/UnknownClassException.php
0 → 100644
View file @
bb2274ea
<?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 using 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'
);
}
}
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