mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 03:40:50 +00:00
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\Core\Console\Style;
|
|
|
|
use Symfony\Component\Console\Application;
|
|
use Symfony\Component\Console\Input\ArgvInput;
|
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
|
|
|
final class RectorConsoleOutputStyleFactory
|
|
{
|
|
public function __construct(
|
|
private readonly PrivatesCaller $privatesCaller
|
|
) {
|
|
}
|
|
|
|
public function create(): RectorConsoleOutputStyle
|
|
{
|
|
$argvInput = new ArgvInput();
|
|
$consoleOutput = new ConsoleOutput();
|
|
|
|
// to configure all -v, -vv, -vvv options without memory-lock to Application run() arguments
|
|
$this->privatesCaller->callPrivateMethod(new Application(), 'configureIO', [$argvInput, $consoleOutput]);
|
|
$debugArgvInputParameterOption = $argvInput->getParameterOption('--debug');
|
|
|
|
// --debug is called
|
|
if ($debugArgvInputParameterOption === null) {
|
|
$consoleOutput->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
|
|
}
|
|
|
|
return new RectorConsoleOutputStyle($argvInput, $consoleOutput);
|
|
}
|
|
}
|