mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 09:20:52 +00:00
commit
d0968b2400
|
@ -5,6 +5,8 @@ Rector is under development phase in 2018, to figure out the best way to use it
|
|||
[![Build Status](https://img.shields.io/travis/rectorphp/rector/master.svg?style=flat-square)](https://travis-ci.org/rectorphp/rector)
|
||||
[![Coverage Status](https://img.shields.io/coveralls/RectorPHP/Rector/master.svg?style=flat-square)](https://coveralls.io/github/rectorphp/rector?branch=master)
|
||||
|
||||
![Rector-showcase](docs/images/rector-showcase.gif)
|
||||
|
||||
Rector **upgrades your application** for you, with focus on open-source projects:
|
||||
|
||||
<p align="center">
|
||||
|
@ -19,6 +21,7 @@ Rector **upgrades your application** for you, with focus on open-source projects
|
|||
<a href="/src/config/level/twig"><img src="/docs/images/twig.png"></a>
|
||||
</p>
|
||||
|
||||
|
||||
Rector can:
|
||||
|
||||
- [Rename classes](#replace-a-class-name)
|
||||
|
|
BIN
docs/images/rector-showcase.gif
Normal file
BIN
docs/images/rector-showcase.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 MiB |
|
@ -3,7 +3,7 @@
|
|||
namespace Rector\Autoloading;
|
||||
|
||||
use Nette\Loaders\RobotLoader;
|
||||
use Rector\Console\Command\ProcessCommand;
|
||||
use Rector\Configuration\Option;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
|
||||
|
@ -33,7 +33,7 @@ final class AdditionalAutoloader
|
|||
private function autoloadFileFromInput(InputInterface $input): void
|
||||
{
|
||||
/** @var string|null $autoloadFile */
|
||||
$autoloadFile = $input->getOption(ProcessCommand::OPTION_AUTOLOAD_FILE);
|
||||
$autoloadFile = $input->getOption(Option::OPTION_AUTOLOAD_FILE);
|
||||
if ($autoloadFile === null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -8,4 +8,14 @@ final class Option
|
|||
* @var string
|
||||
*/
|
||||
public const SOURCE = 'source';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const OPTION_AUTOLOAD_FILE = 'autoload-file';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const OPTION_DRY_RUN = 'dry-run';
|
||||
}
|
||||
|
|
|
@ -24,16 +24,6 @@ use Throwable;
|
|||
|
||||
final class ProcessCommand extends Command
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const OPTION_AUTOLOAD_FILE = 'autoload-file';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private const OPTION_DRY_RUN = 'dry-run';
|
||||
|
||||
/**
|
||||
* @var FileProcessor
|
||||
*/
|
||||
|
@ -116,13 +106,13 @@ final class ProcessCommand extends Command
|
|||
'Files or directories to be upgraded.'
|
||||
);
|
||||
$this->addOption(
|
||||
self::OPTION_DRY_RUN,
|
||||
Option::OPTION_DRY_RUN,
|
||||
null,
|
||||
InputOption::VALUE_NONE,
|
||||
'See diff of changes, do not save them to files.'
|
||||
);
|
||||
$this->addOption(
|
||||
self::OPTION_AUTOLOAD_FILE,
|
||||
Option::OPTION_AUTOLOAD_FILE,
|
||||
null,
|
||||
InputOption::VALUE_REQUIRED,
|
||||
'File with extra autoload'
|
||||
|
@ -139,7 +129,7 @@ final class ProcessCommand extends Command
|
|||
|
||||
$source = $input->getArgument(Option::SOURCE);
|
||||
$this->parameterProvider->changeParameter(Option::SOURCE, $source);
|
||||
$this->parameterProvider->changeParameter(self::OPTION_DRY_RUN, $input->getOption(self::OPTION_DRY_RUN));
|
||||
$this->parameterProvider->changeParameter(Option::OPTION_DRY_RUN, $input->getOption(Option::OPTION_DRY_RUN));
|
||||
$files = $this->phpFilesFinder->findInDirectoriesAndFiles($source);
|
||||
|
||||
$this->processCommandReporter->reportLoadedRectors();
|
||||
|
@ -196,7 +186,7 @@ final class ProcessCommand extends Command
|
|||
{
|
||||
$oldContent = $fileInfo->getContents();
|
||||
|
||||
if ($this->parameterProvider->provideParameter(self::OPTION_DRY_RUN)) {
|
||||
if ($this->parameterProvider->provideParameter(Option::OPTION_DRY_RUN)) {
|
||||
$newContent = $this->fileProcessor->processFileToString($fileInfo);
|
||||
if ($newContent !== $oldContent) {
|
||||
$this->diffFiles[] = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user