#!/usr/bin/env php
<?php declare(strict_types=1);

use Composer\XdebugHandler\XdebugHandler;
use Psr\Container\ContainerInterface;
use Rector\Console\Application;
use Symplify\PackageBuilder\Console\ThrowableRenderer;

// Performance boost
gc_disable();

// Require Composer autoload.php
require_once __DIR__ . '/bootstrap.php';

$xdebug = new XdebugHandler('rector', '--ansi');
$xdebug->check();
unset($xdebug);

try {
    /** @var ContainerInterface $container */
    $container = require_once __DIR__ . '/container.php';

    $application = $container->get(Application::class);
    exit($application->run());
} catch (Throwable $throwable) {
    (new ThrowableRenderer())->render($throwable);
    exit($throwable->getCode());
}
