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

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

Loads an interceptor autoloader.
public static load ( $interceptor = null ) : boolean
Результат boolean Returns `true` on success, `false` otherwise.
    public static function load($interceptor = null)
    {
        if (static::$_interceptor) {
            static::unpatch();
        }
        $original = $interceptor->originalLoader();
        $success = spl_autoload_register($interceptor->loader(), true, true);
        spl_autoload_unregister($original);
        static::$_interceptor = $interceptor;
        return $success;
    }

Usage Example

Пример #1
0
         $actual = Interceptor::instance();
         expect($success)->toBe(true);
         expect($actual)->toBe(null);
     });
     it("returns `false` if there's no patched autoloader", function () {
         Interceptor::patch(['cachePath' => $this->cachePath]);
         Interceptor::unpatch();
         $success = Interceptor::unpatch();
         expect($success)->toBe(false);
     });
 });
 describe("::load()", function () {
     it("auto unpatch when loading an interceptor autoloader", function () {
         $interceptor = Interceptor::patch(['cachePath' => $this->cachePath]);
         $new = new Interceptor(['originalLoader' => $interceptor->originalLoader(), 'cachePath' => $this->cachePath]);
         Interceptor::load($new);
         expect(Interceptor::instance())->toBe($new);
         expect(Interceptor::instance())->not->toBe($interceptor);
     });
 });
 describe("::instance()", function () {
     it("returns the interceptor autoloader", function () {
         $interceptor = Interceptor::patch(['cachePath' => $this->cachePath]);
         expect($interceptor)->toBeAnInstanceOf("Kahlan\\Jit\\Interceptor");
     });
 });
 describe("::composer()", function () {
     it("returns the composer autoloader", function () {
         $composer = Interceptor::composer()[0];
         expect($composer)->toBeAnInstanceOf("Composer\\Autoload\\ClassLoader");
     });
All Usage Examples Of Kahlan\Jit\Interceptor::load