#!/usr/bin/env php
<?php declare(strict_types=1);
/**
 * This file is part of the PHP_CompatInfo package.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @author Laurent Laville
 */

// @link https://www.tomasvotruba.cz/blog/2018/08/02/5-gotchas-of-the-bin-file-in-php-cli-applications/

if (PHP_SAPI !== 'cli') {
    return;
}

gc_disable(); // performance boost

require_once dirname(__DIR__) . '/config/bootstrap.php';

use Bartlett\CompatInfo\Infrastructure\Framework\Symfony\DependencyInjection\ContainerFactory;
use Bartlett\CompatInfo\Presentation\Console\ApplicationInterface;
use Bartlett\CompatInfo\Presentation\Console\CommandLoaderInterface;

use Symfony\Component\DependencyInjection\ContainerBuilder;

/** @var ContainerBuilder $container */
$container = (new ContainerFactory())->create();

$app = $container->get(ApplicationInterface::class);
$app->setContainer($container);

// @link https://symfony.com/doc/current/console/lazy_commands.html
$app->setCommandLoader($container->get(CommandLoaderInterface::class));

exit($app->run());
