add --xdebug option

This commit is contained in:
Tomas Votruba 2019-10-29 17:43:11 +01:00
parent 51403e5348
commit e5194fecc2
6 changed files with 17 additions and 21 deletions

View File

@ -51,12 +51,6 @@ script:
php bin/run_all_sets.php
fi
# try #2205 w/ xdebug
- |
if [[ $COVERAGE == true ]]; then
bin/rector -c
fi
# Eat your own dog food
- |
if [[ $DOG_FOOD == true ]]; then

View File

@ -25,16 +25,7 @@ try {
}
// And from --config or default one
$argInput = new ArgvInput();
// https://github.com/rectorphp/rector/issues/2205
$configOptionValue = ConfigFileFinder::getOptionValue($argInput, ['-c', '--config']);
if ($configOptionValue === '--ansi') {
// empty --config with xdebug handler
die('Option "-c" or "--config" cannot be empty. Provide path to config file' . PHP_EOL);
}
ConfigFileFinder::detectFromInput('rector', $argInput);
ConfigFileFinder::detectFromInput('rector', new ArgvInput());
$configs[] = ConfigFileFinder::provide('rector', ['rector.yml', 'rector.yaml']);
// remove empty values

View File

@ -3,7 +3,6 @@
declare(strict_types=1);
use Composer\XdebugHandler\XdebugHandler;
use Psr\Container\ContainerInterface;
use Rector\Console\Application;
@ -15,10 +14,6 @@ gc_disable();
// Require Composer autoload.php
require_once __DIR__ . '/bootstrap.php';
$xdebug = new XdebugHandler('rector', '--ansi');
$xdebug->check();
unset($xdebug);
/** @var ContainerInterface $container */
$container = require_once __DIR__ . '/container.php';

View File

@ -46,6 +46,7 @@ services:
- 'Symfony\Component\Console\Input\*Input'
- 'PHPStan\Analyser\NameScope'
- 'PHPStan\Rules\RuleErrors\RuleError*'
- '*\XdebugHandler'
Symplify\CodingStandard\Fixer\Naming\PropertyNameMatchingTypeFixer:
extra_skipped_classes:

View File

@ -167,6 +167,13 @@ final class Application extends SymfonyApplication
'Enable debug verbosity (-vvv)'
));
$inputDefinition->addOption(new InputOption(
'xdebug',
null,
InputOption::VALUE_NONE,
'Allow running xdebug'
));
$inputDefinition->addOption(new InputOption(
'--working-dir',
'-d',

View File

@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Rector\Console\Command;
use Composer\XdebugHandler\XdebugHandler;
use Nette\Utils\Strings;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Descriptor\TextDescriptor;
@ -60,5 +61,12 @@ abstract class AbstractCommand extends Command
$this->getApplication()->setCatchExceptions(false);
}
// @fixes https://github.com/rectorphp/rector/issues/2205
if ($input->getOption('xdebug')) {
$xdebug = new XdebugHandler('rector', '--ansi');
$xdebug->check();
unset($xdebug);
}
}
}