yiisoft/yii — pull request #1297 by danapplegate (2012-08-27 21:27:42+00:00)
Title: Update autoload function in compliance with psr-0 standard

From the [psr-0 specification](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md):

> # Mandatory
> ...
> * Each "\_" character in the CLASS NAME is converted to a
`DIRECTORY_SEPARATOR`. The "\_" character has no special meaning in the
namespace.

Currently, Yii's autoloading functionality only recognizes class names as being namespaced when a backslash character is present. This breaks autoloading for older-style namespaced libraries, such as the Zend Framework v1.x. The only workaround is to then manually include the files, as seen in [this Yii docs guide](http://www.yiiframework.com/doc/guide/1.1/en/extension.integration).

This commit modifies the non-namespaced autoloader code to first attempt loading the bare class name from the include path. If that fails, and the class name has underscores present, the autoloader replaces those underscores with directory separators and tries again. Additionally, the namespace autoloader code is modified to replace underscores in the base class name with directory separators, in compliance with the psr-0 standard.