Kahlan\Jit\Interceptor::patch PHP Метод

patch() публичный статический Метод

Patch the autoloader to be intercepted by the current autoloader.
public static patch ( array $options = [] )
$options array Options for the interceptor autoloader.
    public static function patch($options = [])
    {
        if (static::$_interceptor) {
            throw new JitException("An interceptor is already attached.");
        }
        $defaults = ['loader' => null];
        $options += $defaults;
        $loader = $options['originalLoader'] = $options['loader'] ?: static::composer();
        if (!$loader) {
            throw new JitException("The loader option need to be a valid autoloader.");
        }
        unset($options['loader']);
        class_exists('Kahlan\\Jit\\JitException');
        class_exists('Kahlan\\Jit\\Node\\NodeDef');
        class_exists('Kahlan\\Jit\\Node\\FunctionDef');
        class_exists('Kahlan\\Jit\\Node\\BlockDef');
        class_exists('Kahlan\\Jit\\TokenStream');
        class_exists('Kahlan\\Jit\\Parser');
        $interceptor = new static($options);
        spl_autoload_unregister($loader);
        return static::load($interceptor) ? $interceptor : false;
    }

Usage Example

Пример #1
0
 /**
  * The default `'interceptor'` filter.
  */
 protected function _interceptor()
 {
     return Filter::on($this, 'interceptor', [], function ($chain) {
         Interceptor::patch(['loader' => [$this->autoloader(), 'loadClass'], 'include' => $this->args()->get('include'), 'exclude' => array_merge($this->args()->get('exclude'), ['Kahlan\\']), 'persistent' => $this->args()->get('persistent'), 'cachePath' => rtrim(realpath(sys_get_temp_dir()), DS) . DS . 'kahlan', 'clearCache' => $this->args()->get('cc')]);
     });
 }
All Usage Examples Of Kahlan\Jit\Interceptor::patch