mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-25 04:03:55 +01:00
commit
23ea1397c0
12
README.md
12
README.md
@ -181,6 +181,18 @@ parameters:
|
||||
php_version_features: '7.2' # your version is 7.3
|
||||
```
|
||||
|
||||
### Paths
|
||||
|
||||
If you're annoyed by repeating paths in arguments, you can move them to config instead:
|
||||
|
||||
```yaml
|
||||
# rector.yaml
|
||||
parameters:
|
||||
paths:
|
||||
- 'src'
|
||||
- 'tests'
|
||||
```
|
||||
|
||||
### Import Use Statements
|
||||
|
||||
FQN classes are imported by default every time Rector performs a change, so you don't have to do it manually/after each run. You can disable it by:
|
||||
|
@ -200,7 +200,7 @@
|
||||
"bin/rector dump-rectors -o markdown > docs/AllRectorsOverview.md",
|
||||
"bin/rector dump-nodes -o markdown > docs/NodesOverview.md"
|
||||
],
|
||||
"rector": "bin/rector process packages src tests --config rector-ci.yaml --dry-run"
|
||||
"rector": "bin/rector process --config rector-ci.yaml --dry-run"
|
||||
},
|
||||
"scripts-descriptions": {
|
||||
"docs": "Regenerate descriptions of all Rectors to docs/AllRectorsOverview.md file"
|
||||
|
@ -5,6 +5,8 @@ imports:
|
||||
- { resource: '../utils/**/config/config.yaml', ignore_errors: true }
|
||||
|
||||
parameters:
|
||||
# processed paths
|
||||
paths: []
|
||||
exclude_paths: []
|
||||
exclude_rectors: []
|
||||
autoload_paths: []
|
||||
@ -16,6 +18,8 @@ parameters:
|
||||
# e.g. /** @var \Some\ClassHere */
|
||||
import_doc_blocks: true
|
||||
|
||||
php_version_features: ~ # what PHP version should be used for features, local PHP version is used by default
|
||||
# what PHP version is used for features, composer.json version, then local PHP version is used by default
|
||||
php_version_features: ~
|
||||
|
||||
file_extensions:
|
||||
- 'php'
|
||||
|
@ -5,6 +5,11 @@ parameters:
|
||||
- 'dead-code'
|
||||
- 'nette-utils-code-quality'
|
||||
|
||||
paths:
|
||||
- 'src'
|
||||
- 'packages'
|
||||
- 'tests'
|
||||
|
||||
exclude_paths:
|
||||
- '/Fixture/'
|
||||
- '/Source/'
|
||||
|
@ -81,6 +81,12 @@ final class ProcessCommand extends AbstractCommand
|
||||
private $stubLoader;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $paths = [];
|
||||
|
||||
/**
|
||||
* @param string[] $paths
|
||||
* @param string[] $fileExtensions
|
||||
*/
|
||||
public function __construct(
|
||||
@ -94,6 +100,7 @@ final class ProcessCommand extends AbstractCommand
|
||||
ReportingExtensionRunner $reportingExtensionRunner,
|
||||
RectorNodeTraverser $rectorNodeTraverser,
|
||||
StubLoader $stubLoader,
|
||||
array $paths,
|
||||
array $fileExtensions
|
||||
) {
|
||||
$this->filesFinder = $phpFilesFinder;
|
||||
@ -109,6 +116,7 @@ final class ProcessCommand extends AbstractCommand
|
||||
$this->stubLoader = $stubLoader;
|
||||
|
||||
parent::__construct();
|
||||
$this->paths = $paths;
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
@ -117,7 +125,7 @@ final class ProcessCommand extends AbstractCommand
|
||||
$this->setDescription('Upgrade or refactor source code with provided rectors');
|
||||
$this->addArgument(
|
||||
Option::SOURCE,
|
||||
InputArgument::REQUIRED | InputArgument::IS_ARRAY,
|
||||
InputArgument::OPTIONAL | InputArgument::IS_ARRAY,
|
||||
'Files or directories to be upgraded.'
|
||||
);
|
||||
$this->addOption(
|
||||
@ -160,7 +168,7 @@ final class ProcessCommand extends AbstractCommand
|
||||
$this->rectorGuard->ensureSomeRectorsAreRegistered();
|
||||
$this->stubLoader->loadStubs();
|
||||
|
||||
$source = (array) $input->getArgument(Option::SOURCE);
|
||||
$source = $this->resolvesSourcePaths($input);
|
||||
|
||||
$phpFileInfos = $this->filesFinder->findInDirectoriesAndFiles($source, $this->fileExtensions);
|
||||
|
||||
@ -187,4 +195,20 @@ final class ProcessCommand extends AbstractCommand
|
||||
|
||||
return Shell::CODE_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function resolvesSourcePaths(InputInterface $input): array
|
||||
{
|
||||
$commandLinePaths = (array) $input->getArgument(Option::SOURCE);
|
||||
|
||||
// manual command line value has priority
|
||||
if (count($commandLinePaths) > 0) {
|
||||
return $commandLinePaths;
|
||||
}
|
||||
|
||||
// fallback to config defined paths
|
||||
return $this->paths;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user