Autoloader cache static constructor

@return Gdn_Autoloader_Map
189281
public static function Load($MapType, $ContextType, $MapRootLocation, $Options) {
      return new Gdn_Autoloader_Map($MapType, $ContextType, $MapRootLocation, $Options);
   }
83674
public function getLoader()
    {
        if (null === $this->loader) {
            if (strpos('@PHP-BIN@', '@PHP-BIN') === 0) {
                $base = dirname(__FILE__) . '/';
                set_include_path($base . PATH_SEPARATOR . get_include_path());
            } else {
                $base = '@PEAR-DIR@/Phrozn/';
            }

            //Autoload candidates.
            $dirs = array($base . '..', getcwd());

            foreach ($dirs as $dir) {
                $file = $dir . '/vendor/autoload.php';
                if (file_exists($file)) {
                    $this->loader = include $file;
                    break;
                }
            }

            if (null === $this->loader) {
                throw new \RuntimeException("Unable to locate autoloader.");
            }
        }

        return $this->loader;
    }
732399
private function getFixtureLoader()
    {
        $container = $this->kernel->getContainer();

        $loader = class_exists('Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader')
            ? new DataFixturesLoader($container)
            : (class_exists('Doctrine\Bundle\FixturesBundle\Common\DataFixtures\Loader')
                ? new DoctrineFixturesLoader($container)
                : new SymfonyFixturesLoader($container));

        return $loader;
    }
280313
public function cache()
    {
        if (null === $this->cache) {
            $this->cache = new WebDriver_Cache($this);
        }
        return $this->cache;
    }
702961
public function getAutoloader()
    {
        if (!isset($this->autoloader)) {
            $this->autoloader = new Autoloader(new FileLocator($this->getPath()), $this->getInflector());
        }

        return $this->autoloader;
    }
153074
public static function init()
    {
        if (!self::$mocks_cache_path) {
            $mocks_cache_path = (string)static::getEnvironment('SOFT_MOCKS_CACHE_PATH');
            if (!$mocks_cache_path) {
                $mocks_cache_path = '/tmp/mocks/';
            }
            self::setMocksCachePath($mocks_cache_path);
        }
        // todo constant will be removed in next major release, because it's like project path.
        if (!defined('SOFTMOCKS_ROOT_PATH')) {
            /**
             * @deprecated use \Badoo\SoftMocks::setProjectPath() instead
             * @see \Badoo\SoftMocks::setProjectPath()
             */
            define('SOFTMOCKS_ROOT_PATH', '/');
        }

        if (!empty(static::getEnvironment('SOFT_MOCKS_DEBUG'))) {
            self::$debug = true;
        }

        self::$func_mocks['call_user_func_array'] = [
            'args' => '', 'code' => 'return \\' . self::class . '::call($params[0], $params[1]);',
        ];
        self::$func_mocks['call_user_func'] = [
            'args' => '', 'code' => '$func = array_shift($params); return \\' . self::class . '::call($func, $params);',
        ];
        self::$func_mocks['is_callable'] = [
            'args' => '$arg', 'code' => 'return \\' . self::class . '::isCallable($arg);',
        ];
        self::$func_mocks['function_exists'] = [
            'args' => '$arg', 'code' => 'return \\' . self::class . '::isCallable($arg);',
        ];
        self::$func_mocks['constant'] = [
            'args' => '$constant', 'code' => 'return \\' . self::class . '::getConst("", $constant);',
        ];
        self::$func_mocks['defined'] = [
            'args' => '$constant', 'code' => 'return \\' . self::class . '::constDefined($constant);',
        ];
        self::$func_mocks['debug_backtrace'] = [
            'args' => '',
            'code' => function () {
                $params = func_get_args();

                $limit = 0;
                $provide_object = true;
                $ignore_args = false;

                if (isset($params[0])) {
                    if ($params[0] === false) {
                        $provide_object = false;
                    } else if ($params[0] === true) {
                        $provide_object = true;
                    } else {
                        $provide_object = $params[0] & DEBUG_BACKTRACE_PROVIDE_OBJECT;
                        $ignore_args = $params[0] & DEBUG_BACKTRACE_IGNORE_ARGS;
                    }
                }
                if (isset($params[1])) {
                    $limit = $params[1];
                }

                $result = debug_backtrace();

                // remove our part of backtrace
                while (count($result) > 0) {
                    if (isset($result[0]['class']) && $result[0]['class'] === self::class
                        && isset($result[0]['function']) && $result[0]['function'] === 'callFunction') {
                        array_shift($result);
                        break;
                    }

                    array_shift($result);
                }

                // remove calls that occur inside our file
                $result = array_values(
                    array_filter(
                        $result,
                        function ($el) { return !isset($el['file']) || $el['file'] !== __FILE__; }
                    )
                );

                $unset_indices = [];

                // replace paths
                foreach ($result as $i => &$p) {
                    if (isset($p["file"])) {
                        $p["file"] = self::replaceFilename($p["file"], true);
                        if ($p["file"] && $p["file"][0] !== '/') {
                            $p["file"] = SOFTMOCKS_ROOT_PATH . $p['file'];
                        }
                    }

                    if (isset($p['class']) && $p['class'] == self::class && isset($p['args'])) {
                        $args = $p['args'];

                        if ($p['function'] === 'callFunction') {
                            unset($p['class']);
                            unset($p['type']);
                            $p['function'] = $args[1];
                            $p['args'] = $args[2];
                            $unset_indices[] = $i - 1; // reflection adds another line in trace that is not needed
                        } else if ($p['function'] === 'callMethod') {
                            $p['object'] = $args[0];
                            $p['class'] = get_class($args[0]);
                            $p['function'] = $args[1];
                            $p['args'] = $args[2];
                            $p['type'] = '->';
                            $unset_indices[] = $i - 1; // reflection adds another line in trace that is not needed
                        } else if ($p['function'] === 'callStaticMethod') {
                            $p['class'] = $args[0];
                            $p['function'] = $args[1];
                            $p['args'] = $args[2];
                            $p['type'] = '::';
                            $unset_indices[] = $i - 1; // reflection adds another line in trace that is not needed
                        }
                    }

                    if ($ignore_args) {
                        unset($p['args']);
                    }

                    if (!$provide_object) {
                        unset($p['object']);
                    }
                }

                foreach ($unset_indices as $i) {
                    unset($result[$i]);
                }

                $result = array_values($result);

                if (!$limit) {
                    return $result;
                }

                $limited_result = [];
                for ($i = 0; $i < $limit; $i++) {
                    $limited_result[] = $result[$i];
                }

                return $limited_result;
            },
        ];

        self::$internal_func_mocks = [];
        foreach (self::$func_mocks as $func => $mock) {
            self::$internal_func_mocks[$func] = $mock;
        }

        $functions = get_defined_functions();
        foreach ($functions['internal'] as $func) {
            self::$internal_functions[$func] = true;
        }

        self::ignoreFiles(get_included_files());
        self::injectIntoPhpunit();
        self::initProjectPath();
    }
164806
public function load()
	{
		if( $this->cacheType() === "data" )
		{
			$ref = new \ReflectionClass($this);
			$cache_name = Str::snake($ref->getShortName());
			$cache_data = $this->cacheData();

			if( isset($cache_data["id"]) )
			{
				$id = $cache_data["id"];
				unset($cache_data["id"]);
			}
			else
			{
				$id = $cache_data;
			}

			$cache = new Cache( $id, "plugin/" . $cache_name, $cache_data );
			if( $cache->ready() )
			{
				$this->plugin_data = $cache->import();
			}
			else
			{
				$this->loadPluginData();
				$cache->export($this->plugin_data);
			}
		}
		else
		{
			$this->loadPluginData();
		}

		return $this;
	}
59230
public static function factory()
    {
        $self = new static();
        $self->downloader = new Plugins\Csv\Downloader();
        $self->outputter  = new Plugins\Csv\Outputter();
        $self->writer     = new Plugins\Csv\Writer();

        return $self;
    }
1294183
protected static function getCachedInstance()
    {
        $class = get_called_class();
        if (self::$instances === null || !isset(self::$instances[$class])) {
            return null;
        }
        return self::$instances[$class];
    }
1219569
private function _configure()
    {
        \Twig_Autoloader::register();

        $loader         =  new \Twig_Loader_Filesystem($this->_basePath);

        $cache_path = defined('CACHE_PATH') ? CACHE_PATH : 'cache';
        $this->_twig = new \Twig_Environment($loader,
            array(
                'debug'      => true,
                'autoreload' => false,
                'autoescape' => true,
                'cache'      => $cache_path,
            ));
        $this->_twig->getExtension('core')->setNumberFormat(2, '.', ',');
        //$this->_twig->addFilter(
            //'nonce',
            //new \Twig_Filter_Function(function($str) {
                //$app=$GLOBALS['app'];
                //if (strpos($str, '?') !== false) {
                    //return $str.'&rand_token='.$app->getSessionManager()->getActiveSession()->getAttribute('nonce');
                //}
                //return $str.'?rand_token='.$app->getSessionManager()->getActiveSession()->getAttribute('nonce');
        //})
        //);
        $this->_twig->addFilter(
            'truncate',
            new \Twig_Filter_Function('StringFilter::truncate')
        );
        $this->_twig->addFilter(
            'isToday',
            new \Twig_Filter_Function('DateFilter::isToday')
        );
        $this->_twig->addFilter(
            'isTomorrow',
            new \Twig_Filter_Function('DateFilter::isTomorrow')
        );
        $this->_twig->addFilter(
            'isLater',
            new \Twig_Filter_Function('DateFilter::isLater')
        );

    }
979907
public function old_getAutoload()
    {
        $autoload   = $this->rawItem('autoload');
        $psr4       = $autoload['psr-4'] ?: [];
        $namespace  = $this->take('package')->namespace;
        if (!array_key_exists($namespace, $psr4)) {
            $psr4 = [$namespace . '\\' => $this->take('package')->src] + $psr4;
            $autoload['psr-4'] = $psr4;
            $this->setItem('autoload', $autoload);
        }

        return $autoload;
    }
783003
public static function initialize()
	{
		if (static::$initialized)
		{
			throw new RuntimeException('Container can only be initialized once');
		}

		// get the Dependency Container instance
		$dic = static::getDic();

		\Config::load('dependency', true);

		// setup the autoloader if none was set yet
		try
		{
			$loader = $dic->resolve('autoloader');

			if ($loader instanceof \Fuel\Core\Autoloader)
			{
				throw new ResolveException;
			}
		}
		catch (ResolveException $e)
		{
			// Check whether there is a VENDORPATH
			if ( ! defined('VENDORPATH'))
			{
				throw new RuntimeException('Container must be initialized in Fuel context');
			}

			// fetch the composer autoloader instance
			$loader = require VENDORPATH.'autoload.php';

			// allow the framework to access the composer autoloader
			$dic->inject('autoloader', $loader);
		}

		// get all defined namespaces
		$prefixes = array_merge($loader->getPrefixes(), $loader->getPrefixesPsr4());

		// scan all composer packages loaded for the presence of FuelServiceProviders
		foreach ($prefixes as $namespace => $paths)
		{
			// does this package define a service provider
			if (class_exists($class = trim($namespace,'\\').'\\Providers\\FuelServiceProvider'))
			{
				// register it with the DiC
				$dic->registerService(new $class);
			}
		}

		// register service providers defined in config
		foreach (\Config::get('dependency.services', []) as $service)
		{
			$service = new $service;

			$dic->registerService($service);
		}

		// register resources defined in config
		foreach (\Config::get('dependency.resources', []) as $identifier => $resource)
		{
			$dic->register($identifier, $resource);
		}

		// register singleton resources defined in config
		foreach (\Config::get('dependency.singletons', []) as $identifier => $singleton)
		{
			$dic->registerSingleton($identifier, $singleton);
		}

		// register extensions defined in config
		foreach (\Config::get('dependency.extensions', []) as $identifier => $extension)
		{
			$dic->extension($identifier, $extension);
		}

		// mark we're initialized
		static::$initialized = true;
	}
850150
private function defaultCache()
    {
        if (extension_loaded('apcu') && class_exists('\\Cache\\Adapter\\Apcu\\ApcuCachePool')) {
            return new \Cache\Adapter\Apcu\ApcuCachePool();
        } elseif (extension_loaded('apc') && class_exists('\\Cache\\Adapter\\Apc\\ApcCachePool')) {
            return new \Cache\Adapter\Apc\ApcCachePool();
        }
        return null;
    }
718805
public function getMetadataCacheDriver()
    {
        if (!$this->metadataCacheDriver instanceof CacheProvider) {
            $metadataCacheDriver = $this->getOption('metadata_cache_driver');

            if (!$metadataCacheDriver instanceof CacheProvider) {
                $metadataCacheDriver = CacheBuilder::build();
            }

            if ($metadataCacheDriver->getNamespace() === '') {
                $metadataCacheDriver->setNamespace((string) $this->getOption('metadata_cache_namespace'));
            }

            $this->metadataCacheDriver = $metadataCacheDriver;
        }

        return $this->metadataCacheDriver;
    }
738693
public function getLoader()
    {
        if (!($this->loader instanceof DictLoaderInterface)) {
            $dataDir = dirname(__DIR__).'/data/';

            $loaderName = $this->loader;
            $this->loader = new $loaderName($dataDir);
        }

        return $this->loader;
    }
372871
public function getCache()
    {
        if (!isset($this->config['cache'])) {
            throw new InvalidArgumentException('A "cache" file system must be set.');
        }

        if (is_string($this->config['cache'])) {
            return new Filesystem(
                new Local($this->config['cache'])
            );
        }

        return $this->config['cache'];
    }
1107343
public function cache_driver()
	{
		if ( ! $this->_cache)
		{
			$adapter = new DCache_Adapter\File(
				realpath(__DIR__.'../../../'.static::CACHE_DIR)
			);
			$adapter->setOption('ttl', static::CACHE_LIFETIME);
			$this->_cache = new DCache\Cache($adapter);
		}

		return $this->_cache;
	}