Compile a hack function.

@param callable $loader   The loader function.

@param string   $hackName The name of the hack.

@return \Closure
189759
private function compileHack($loader, $hackName)
    {
        $logger = $this->logger;

        return function ($class) use ($loader, $hackName, $logger) {
            if (call_user_func($loader, $class)) {
                $logger->debug(
                    'Custom class loader hack {hackName} loaded {class}.',
                    array(
                        'hackName' => $hackName,
                        'class'    => $class
                    )
                );

                return $hackName;
            }

            if (EnumeratingClassLoader::isLoaded($class)) {
                $logger->warning(
                    'Hack {hackName} appears to have loaded {class} but did return null. It SHOULD return true.',
                    array('hackName' => $hackName, 'class' => $class)
                );

                return $hackName;
            }

            return null;
        };
    }
1109805
public function helper($name, $args = [])
    {
        $args = func_get_args();
        $name = array_shift($args);
        if (isset($this->helpers[$name]) && is_callable($this->helpers[$name])) {
            return call_user_func_array($this->helpers[$name], $args);
        } elseif (($helper = [Helper::class, $name]) && is_callable($helper)) {
            return call_user_func_array($helper, $args);
        }

        throw new \RuntimeException(sprintf('undefined helper "%s" in %s line %d', $name, static::NAME, $this->getLineTrace()));
    }
546244
private function fileLineGenerator(string $fileName, callable $formatter = null)
    {
        $f = fopen($fileName, 'r');
        try {
            while ($line = fgets($f)) {
                if(!is_null($formatter)){
                    yield call_user_func($formatter, $line);
                }
                else {
                    yield $line;
                }
            }
        } finally {
            fclose($f);
        }
    }
903533
public static function create(array $loaders = [])
    {
        if (empty($loaders)) {
            $extractor = null;

            if (class_exists(PropertyInfoExtractor::class)) {
                $extractors = $typeExtractors = [new ReflectionExtractor()];

                if (class_exists(ClassReflector::class)) {
                    array_unshift($typeExtractors, new PhpDocExtractor());
                }

                $extractor = new PropertyInfoExtractor($extractors, $typeExtractors, [], $extractors);
            }

            $loaders = [new ReflectionClassMetadataLoader($extractor)];

            if (class_exists(AnnotationReader::class)) {
                $loaders[] = new AnnotationClassMetadataLoader(new AnnotationReader());
            }
        }

        return new static(count($loaders) > 1 ? new ChainClassMetadataLoader($loaders) : array_shift($loaders));
    }
885917
function (fn) {
    if (!fn || !_.isFunction(fn)) {
      var err = new Error('Please pass a valid function!');
      debug(err);
      throw err;
    }

    this.structureLoader = customLoader(fn);

    return this;
  }
648145
public static function loader($className) {		
		if(!isset(self::$loader_cache)) {
			self::buildLoaderCache();
		}
		
		if(isset(self::$loader_cache[$className])) {
			require_once(self::$loader_cache[$className]);
			return true;
		}
		else {
			return false;
		}
	}
389088
public static function make(Closure $callback = null)
    {
        if ($callback instanceof Closure) {
            return $callback(new static(Security::create()));
        }

        return new static(Security::create());
    }
103880
protected function loadConfigurationFile(array $config, XmlFileLoader $loader)
    {
        foreach ($config as $filename) {
            if (file_exists($file = sprintf('%s/%s.xml', $this->getConfigurationDirectory(), $filename))) {
                $loader->load($file);
            }
        }
    }
678308
public function getTwigCompiler($loader)
    {
        $this->twig = new Twig_Environment($loader, array(
           'cache'       => storage_path().'/views',
           'autoescape'  => false,
           'auto_reload' => true
        ));

        // Hook twig to do what you want.
        $hooks = $this->config->get('theme.engines.twig.hooks');
        $this->twig = $hooks($this->twig);

        // Get facades aliases.
        $aliases = $this->config->get('app.aliases');

        // Laravel alias to allow.
        $allows = $this->config->get('theme.engines.twig.allows');

        foreach ($aliases as $alias => $class)
        {
            // Nothing allow if not exists in twig config.
            if ( ! in_array($alias, $allows)) continue;

            // Clasname with namspacing.
            $className = '\\'.$alias;

            // Some method is not in facade like Str.
            if ( ! method_exists($className, 'getFacadeRoot'))
            {
                $this->twig->addGlobal($alias, new $className());
            }
            // Method support real facade.
            else
            {
                $this->twig->addGlobal($alias, $className::getFacadeRoot());
            }
        }

        /*$function = new Twig_SimpleFunction('call', function($function)
        {
            $args = func_get_args();
            $args = array_splice($args, 1);

            return call_user_func_array($function, $args);
        });

        $this->twig->addFunction($function);*/

        return $this->twig;
    }
1202215
public static function setLoader($loader) {
    if (!$loader) {
      self::$_loader = NULL;
      return;
    }
    if ($loader instanceof FluentDOM\Loadable) {
      self::$_loader = $loader;
      return;
    }
    throw new FluentDOM\Exceptions\InvalidArgument(
      'loader', [Loadable::class]
    );
  }
888976
private function getConfigurationLoader() {
    if (!array_key_exists($this->format, self::getConfigurationLoaders())) {
      throw new LoadException("configuration loader for format key $this->format could not be found");
    }

    $loaderClass = self::getConfigurationLoaders()[$this->format];
    $loader = new $loaderClass($this->filename);

    return $loader;
  }
1223616
function Loader(options) {
  if (!(this instanceof Loader)) {
    return new Loader(options);
  }
  this.options = options || {};
  this.cache = this.options.helpers || {};
}
1361702
public function setLoader(Loader $loader)
    {
        $this->loader = $loader;
        $this->loader->setNamespace($this->getNamespace());
    }
1077882
public static function helper($helperName, $args = array(), $dirs = null)
    {
        self::loadHelper($helperName, $dirs);
        return call_user_func_array(self::$loadedHelpers[$helperName], $args);
    }
1079770
public static function loadFromFile($name) {
        static $loader = null;
        if ($loader === null) {
            $loader = new ConfigurationLoader();
        }
        if (empty($name)) {
            return new Configuration('');
        } else {
            return $loader->loadConfig($name);
        }
    }
1043272
public function helper($helper)
    {
        $helperPath = $this->getHelperPath($helper);

        if ($helperPath === null) {
            throw new InvalidArgumentException("Helper [{$helper}] not found.");
        }

        $args = func_get_args();
        unset($args[0]);

        $callback = include($helperPath);

        if (!is_callable($callback)) {
            throw new BadFunctionCallException("Helper [{$helper}] is invalid.");
        }

        return call_user_func_array($callback, $args);
    }
688391
public function loadServices(FileLoader $loader)
    {
        // services, admin & config files
        foreach (['services', 'admin'] as $fileName) {
            if (file_exists($this->dir . $this->prefix . $fileName . $this->suffix)) {
                $loader->load($fileName . $this->suffix);
            }
        }

        return $this;
    }