本文整理汇总了PHP中spl_autoload_functions函数的典型用法代码示例。如果您正苦于以下问题:PHP spl_autoload_functions函数的具体用法?PHP spl_autoload_functions怎么用?PHP spl_autoload_functions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spl_autoload_functions函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enable
/**
* Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones.
*/
static public function enable()
{
if (!is_array($functions = spl_autoload_functions())) {
return;
}
foreach ($functions as $function) {
spl_autoload_unregister($function);
}
foreach ($functions as $function) {
if (is_array($function) && $function[0] instanceof UniversalClassLoader) {
$loader = new static();
$loader->registerNamespaceFallbacks($function[0]->getNamespaceFallbacks());
$loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks());
$loader->registerNamespaces($function[0]->getNamespaces());
$loader->registerPrefixes($function[0]->getPrefixes());
$loader->useIncludePath($function[0]->getUseIncludePath());
$function[0] = $loader;
}
spl_autoload_register($function);
}
}
示例2: reautoload
public static function reautoload($paths = array(), $ext = '.class.php')
{
if (is_string($paths)) {
$paths = array($paths);
}
foreach ($paths as $path) {
self::add_autoload_path($path, $ext);
}
// unregister old
//spl_autoload_unregister(array('Think', 'autoload'));
/*
Array ( [0] => Array (
[0] => Think [1] => autoload )
[1] => Array ( [0] => (object) [1] => autoload )
[2] => import )
*/
// check loaded?
if ($aLoadedFuncs = spl_autoload_functions()) {
foreach ($aLoadedFuncs as $f) {
if ($f && is_array($f) && is_string($f[0]) && $f[0] == __CLASS__ && $f[1] == 'autoload') {
return;
}
}
}
// register Runder::autoload
spl_autoload_register(array(__CLASS__, 'autoload'));
}
示例3: setUp
public function setUp()
{
$autoloaders = spl_autoload_functions();
$this->app = new Application($autoloaders[0][0]);
$this->app->registerStandardCommands();
$this->sourceDir = __DIR__ . '/../../src/Core/Tests/fixtures/project';
}
示例4: getLoader
/**
* {@inheritDoc}
*/
public function getLoader()
{
$this->validate();
$previous = spl_autoload_functions();
foreach ($this->information as $path) {
if ($path = realpath($this->prependPathWithBaseDir($path))) {
require $path;
}
}
$found = array();
$after = spl_autoload_functions();
foreach ($after as $loader) {
if (!in_array($loader, $previous)) {
spl_autoload_unregister($loader);
$found[] = $loader;
}
}
return function ($class) use($found) {
foreach ($found as $loader) {
if (call_user_func($loader, $class)) {
return true;
}
}
return null;
};
}
示例5: testAutoloader
/**
* testAutoloader
*
* @since 2.1.0
*/
public function testAutoloader()
{
/* result */
$result = spl_autoload_functions();
/* compare */
$this->assertInternalType('array', $result);
}
示例6: testAutoloader
/**
* testAutoloader
*
* @since 2.1.0
*/
public function testAutoloader()
{
/* actual */
$actual = spl_autoload_functions();
/* compare */
$this->assertInternalType('array', $actual);
}
示例7: register
public static function register($prepend = false)
{
$error = false;
if (self::$autoloader_set) {
trigger_error("Auto loader already set", E_USER_NOTICE);
} else {
self::add_path(__DIR__ . DIRECTORY_SEPARATOR . "..");
$class_extensions = spl_autoload_extensions();
if (strpos($class_extensions, ".php") === false) {
spl_autoload_extensions($class_extensions . ",.php");
}
if (is_array(spl_autoload_functions()) && in_array("spl_autoload", spl_autoload_functions())) {
trigger_error("Auto loader already set", E_USER_NOTICE);
} else {
if (PHP_VERSION_ID < 50300) {
if (!spl_autoload_register("spl_autoload")) {
$error = true;
}
} else {
if (!spl_autoload_register("spl_autoload", true, $prepend)) {
$error = true;
}
}
}
if ($error) {
trigger_error("Could not add autoloader to the queue", E_USER_NOTICE);
} else {
self::$autoloader_set = true;
}
}
}
示例8: register2
public static function register2($stopProcessing = false)
{
if (!$stopProcessing && !self::$_registered) {
$rewriter = new Aitoc_Aitsys_Model_Rewriter();
$rewriter->preRegisterAutoloader();
// unregistering all autoloaders to make our performing first
$autoloaders = spl_autoload_functions();
$firstAutoloader = $autoloaders[0];
// EXTENDWARE CHANGE
if ($autoloaders && is_array($autoloaders) && !empty($autoloaders)) {
foreach ($autoloaders as $autoloader) {
spl_autoload_unregister($autoloader);
}
}
// EXTENDWARE CHANGE
if (is_callable($firstAutoloader)) {
spl_autoload_register($firstAutoloader, false);
}
// register our autoloader
spl_autoload_register(array(self::instance(), 'autoload'), false);
// register 1.3.1 and older autoloader
if (version_compare(Mage::getVersion(), '1.3.1', 'le')) {
spl_autoload_register(array(self::instance(), 'performStandardAutoload'), true);
}
// register back all unregistered autoloaders
if ($autoloaders && is_array($autoloaders) && !empty($autoloaders)) {
foreach ($autoloaders as $autoloader) {
spl_autoload_register($autoloader, is_array($autoloader) && $autoloader[0] instanceof Varien_Autoload);
}
}
self::$_registered = true;
}
}
示例9: __construct
public function __construct()
{
//Make sure autoloader is loaded
if (version_compare(PHP_VERSION, '5.1.2', '>=') and !spl_autoload_functions() || !in_array('DocxMergeAutoload', spl_autoload_functions())) {
require dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DocxMerge' . DIRECTORY_SEPARATOR . 'DocxMergeAutoload.php';
}
}
示例10: registerLoader
/**
* @return IBridgeInterface
*/
public function registerLoader()
{
/**
* Prevent multiple Loader-Instance
*/
$Loader = spl_autoload_functions();
if (is_array($Loader)) {
array_walk($Loader, function (&$Loader) {
if (is_array($Loader)) {
$Stack = $Loader[0];
} else {
$Stack = $Loader;
}
if ($Stack instanceof Bridge) {
if ($Stack->getLoaderHash() == $this->getLoaderHash()) {
$Loader = false;
}
}
}, $this);
$Loader = in_array(false, $Loader);
} else {
// @codeCoverageIgnoreStart
$Loader = false;
// @codeCoverageIgnoreEnd
}
/**
* Register Loader-Instance
*/
if (!$Loader) {
spl_autoload_register(array($this, 'loadSourceFile'), true, false);
}
return $this;
}
示例11: setAutoload
/**
* set the faker autoloader
*/
public function setAutoload()
{
require_once Mage::getBaseDir('lib') . DS . 'Zend' . DS . 'Loader.php';
$autoLoader = Zend_Loader_Autoloader::getInstance();
// get all Varien autoloaders an unregister them
$autoloader_callbacks = spl_autoload_functions();
$original_autoload = null;
foreach ($autoloader_callbacks as $callback) {
if (is_array($callback) && $callback[0] instanceof Varien_Autoload) {
$original_autoload = $callback;
}
}
spl_autoload_unregister($original_autoload);
// the faker autoloader
function fakerLoader($className)
{
$className = ltrim($className, '\\');
$fileName = '';
if ($lastNsPos = strripos($className, '\\')) {
$namespace = substr($className, 0, $lastNsPos);
$className = substr($className, $lastNsPos + 1);
$fileName = lcfirst(str_replace('\\', DS, $namespace) . DS);
}
$fileName = Mage::getBaseDir('lib') . DS . 'fzaninotto' . DS . $fileName . DS . $className . '.php';
if (file_exists($fileName)) {
require_once $fileName;
return true;
}
return false;
}
$autoLoader->pushAutoloader('fakerLoader', 'Faker\\');
// re-add the original autoloader
$autoLoader->pushAutoloader($original_autoload);
}
示例12: register
public static function register($stopProcessing = false)
{
if (Mage::getConfig()->getNode('default/aitsys/rewriter_status') != 1) {
self::$_registered = true;
return;
}
if (!$stopProcessing && !self::$_registered) {
$rewriter = new Aitoc_Aitsys_Model_Rewriter();
$rewriter->preRegisterAutoloader();
// unregistering all autoloaders to make our performing first
$autoloaders = spl_autoload_functions();
if ($autoloaders && is_array($autoloaders) && !empty($autoloaders)) {
foreach ($autoloaders as $autoloader) {
spl_autoload_unregister($autoloader);
}
}
// register our autoloader
spl_autoload_register(array(self::instance(), 'autoload'), false);
// register 1.3.1 and older autoloader
if (version_compare(Mage::getVersion(), '1.3.1', 'le')) {
spl_autoload_register(array(self::instance(), 'performStandardAutoload'), true);
}
// register back all unregistered autoloaders
if ($autoloaders && is_array($autoloaders) && !empty($autoloaders)) {
foreach ($autoloaders as $autoloader) {
spl_autoload_register($autoloader, is_array($autoloader) && $autoloader[0] instanceof Varien_Autoload);
}
}
self::$_registered = true;
}
}
示例13: register
/**
* Installs this class loader on the SPL autoload stack as the only class loader.
*
* @throws DoctrineException If the SPL autoload stack already contains other autoloaders.
*/
public function register()
{
if (spl_autoload_functions() !== false) {
throw new DoctrineException("Autoload stack is not empty. GlobalClassLoader does not work " . "in an autoload stack.");
}
spl_autoload_register(array($this, 'loadClass'));
}
示例14: testUnregister
public function testUnregister()
{
Autoloader::register();
$numOfAutoloaders = count(spl_autoload_functions());
Autoloader::unregister();
$this->assertCount($numOfAutoloaders - 1, spl_autoload_functions());
}
示例15: disableAutoload
/**
* Turns autoloading off.
*/
protected function disableAutoload()
{
$this->autoloadList = spl_autoload_functions();
foreach ($this->autoloadList as $function) {
spl_autoload_unregister($function);
}
}