Kahlan\Jit\Interceptor::composer PHP Method

composer() public static method

Look for the composer autoloader.
public static composer ( ) : mixed
return mixed The founded composer autolaoder or `null` if not found.
    public static function composer()
    {
        $loaders = spl_autoload_functions();
        foreach ($loaders as $key => $loader) {
            if (is_array($loader) && $loader[0] instanceof ClassLoader) {
                return $loader;
            }
        }
    }

Usage Example

コード例 #1
0
ファイル: KahlanSpec.php プロジェクト: samsonasik/kahlan
describe("Kahlan", function () {
    /**
     * Save current & reinitialize the Interceptor class.
     */
    before(function () {
        $this->previous = Interceptor::instance();
        Interceptor::unpatch();
    });
    /**
     * Restore Interceptor class.
     */
    after(function () {
        Interceptor::load($this->previous);
    });
    beforeEach(function () {
        $this->specs = new Kahlan(['autoloader' => Interceptor::composer()[0], 'suite' => new Suite(['matcher' => new Matcher()])]);
    });
    describe("->loadConfig()", function () {
        it("sets passed arguments to specs", function () {
            $args = ['--src=src', '--spec=spec/Fixture/Kahlan/Spec', '--pattern=*MySpec.php', '--reporter=verbose', '--coverage=3', '--config=spec/Fixture/Kahlan/kahlan-config.php', '--ff=5', '--cc', '--no-colors', '--no-header', '--include=*', '--exclude=Kahlan\\', '--persistent=false', '--autoclear=Kahlan\\Plugin\\Monkey', '--autoclear=Kahlan\\Plugin\\Call', '--autoclear=Kahlan\\Plugin\\Stub', '--autoclear=Kahlan\\Plugin\\Quit'];
            $this->specs->loadConfig($args);
            expect($this->specs->args()->get())->toBe(['src' => ['src'], 'spec' => ['spec/Fixture/Kahlan/Spec'], 'reporter' => ["verbose"], 'pattern' => "*MySpec.php", 'config' => "spec/Fixture/Kahlan/kahlan-config.php", 'ff' => 5, 'cc' => true, 'no-colors' => true, 'no-header' => true, 'include' => ['*'], 'exclude' => ['Kahlan\\'], 'persistent' => false, 'autoclear' => ['Kahlan\\Plugin\\Monkey', 'Kahlan\\Plugin\\Call', 'Kahlan\\Plugin\\Stub', 'Kahlan\\Plugin\\Quit'], 'coverage' => '3']);
        });
        it("loads the config file", function () {
            $this->specs->loadConfig(['--spec=spec/Fixture/Kahlan/Spec/PassTest.php', '--config=spec/Fixture/Kahlan/kahlan-config.php', '--pattern=*Test.php', '--reporter=none']);
            $this->specs->run();
            expect($this->specs->suite()->loaded)->toBe(true);
            Interceptor::unpatch();
        });
        it("echoes version if --version if provided", function () {
            $version = Kahlan::VERSION;
All Usage Examples Of Kahlan\Jit\Interceptor::composer