當前位置: 首頁>>代碼示例>>PHP>>正文


PHP spl_autoload_functions函數代碼示例

本文整理匯總了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);
        }
    }
開發者ID:naknak,項目名稱:symfony,代碼行數:28,代碼來源:DebugUniversalClassLoader.php

示例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'));
 }
開發者ID:skyshow,項目名稱:government,代碼行數:27,代碼來源:Runder.class.php

示例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';
 }
開發者ID:spress,項目名稱:spress,代碼行數:7,代碼來源:SiteBuildCommandTest.php

示例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;
     };
 }
開發者ID:phpcq,項目名稱:autoload-validation,代碼行數:29,代碼來源:FilesValidator.php

示例5: testAutoloader

 /**
  * testAutoloader
  *
  * @since 2.1.0
  */
 public function testAutoloader()
 {
     /* result */
     $result = spl_autoload_functions();
     /* compare */
     $this->assertInternalType('array', $result);
 }
開發者ID:ITw3,項目名稱:redaxscript,代碼行數:12,代碼來源:AutoloaderTest.php

示例6: testAutoloader

 /**
  * testAutoloader
  *
  * @since 2.1.0
  */
 public function testAutoloader()
 {
     /* actual */
     $actual = spl_autoload_functions();
     /* compare */
     $this->assertInternalType('array', $actual);
 }
開發者ID:amanpreetsinghmalhotra,項目名稱:redaxscript,代碼行數:12,代碼來源:AutoloaderTest.php

示例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;
         }
     }
 }
開發者ID:joneschrisan,項目名稱:yar,代碼行數:31,代碼來源:autoloader.php

示例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;
     }
 }
開發者ID:platonicsolution,項目名稱:local-server,代碼行數:33,代碼來源:Autoload.php

示例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';
     }
 }
開發者ID:ernie400,項目名稱:DocxMerge,代碼行數:7,代碼來源:DocxMerge.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;
 }
開發者ID:BozzaCoon,項目名稱:SPHERE-Framework,代碼行數:36,代碼來源:Bridge.php

示例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);
 }
開發者ID:sanderjongsma,項目名稱:mageFaker,代碼行數:37,代碼來源:Observer.php

示例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;
     }
 }
開發者ID:cabrerabywaters,項目名稱:magentoSunshine,代碼行數:31,代碼來源:Autoload.php

示例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'));
 }
開發者ID:nvdnkpr,項目名稱:symfony-demo,代碼行數:12,代碼來源:GlobalClassLoader.php

示例14: testUnregister

 public function testUnregister()
 {
     Autoloader::register();
     $numOfAutoloaders = count(spl_autoload_functions());
     Autoloader::unregister();
     $this->assertCount($numOfAutoloaders - 1, spl_autoload_functions());
 }
開發者ID:bitpay,項目名稱:php-client,代碼行數:7,代碼來源:AutoloaderTest.php

示例15: disableAutoload

 /**
  * Turns autoloading off.
  */
 protected function disableAutoload()
 {
     $this->autoloadList = spl_autoload_functions();
     foreach ($this->autoloadList as $function) {
         spl_autoload_unregister($function);
     }
 }
開發者ID:JerryCR,項目名稱:php-2,代碼行數:10,代碼來源:DefaultTest.php


注:本文中的spl_autoload_functions函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。