Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ vendor/bin/rector process src

## Features

### Paths

If you're annoyed by repeating paths in arguments, you can move them to config instead:

```yaml
# rector.yaml
parameters:
paths:
- 'src'
- 'tests'
```

### Extra Autoloading

Rector relies on whatever autoload setup the project it is fixing is using by using the Composer autoloader as default. To specify your own autoload file, use `--autoload-file` option:
Expand Down Expand Up @@ -168,7 +180,7 @@ parameters:
- '*/src/*/Tests/*'
```

You can use a whole ruleset, except one rule:
You can use a whole set, except 1 rule:

```yaml
# rector.yaml
Expand All @@ -177,9 +189,7 @@ parameters:
- 'Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector'
```

### How to Skip Specific Line + Specific Rule?

Use `@noRector \FQN name` annotation:
For in-file exclusion, use `@noRector \FQN name` annotation:

```php
class SomeClass
Expand All @@ -205,18 +215,6 @@ 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 not imported by default. If you don't want to do it manually after every Rector run, enable it by:
Expand Down Expand Up @@ -261,6 +259,8 @@ parameters:
symfony_container_xml_path: 'var/cache/dev/AppKernelDevDebugContainer.xml'
```

<br>

## More Detailed Documentation

- **[All Rectors Overview](/docs/rector_rules_overview.md)**
Expand All @@ -270,10 +270,14 @@ parameters:
- [PHP Parser Nodes Overview](/docs/nodes_overview.md)
- [Add Checkstyle with your CI](/docs/checkstyle.md)

<br>

## How to Contribute

See [the contribution guide](/CONTRIBUTING.md).

<br>

## Run Rector in Docker

You can run Rector on your project using Docker:
Expand All @@ -293,7 +297,9 @@ docker run -v $(pwd):/project rector/rector:latest process /project/app \
--dry-run
```

### Community Packages
<br>

## Community Packages

Do you use Rector to upgrade your code? Add it here:

Expand Down
2 changes: 0 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"Rector\\Doctrine\\": "rules/doctrine/src",
"Rector\\DynamicTypeAnalysis\\": "packages/dynamic-type-analysis/src",
"Rector\\DoctrineAnnotationGenerated\\": "packages/doctrine-annotation-generated/src",
"Rector\\ElasticSearchDSL\\": "rules/elastic-search-dsl/src",
"Rector\\FileSystemRector\\": "packages/file-system-rector/src",
"Rector\\FrameworkMigration\\": "rules/framework-migration/src",
"Rector\\Guzzle\\": "rules/guzzle/src",
Expand Down Expand Up @@ -150,7 +149,6 @@
"Rector\\DoctrineGedmoToKnplabs\\Tests\\": "rules/doctrine-gedmo-to-knplabs/tests",
"Rector\\Doctrine\\Tests\\": "rules/doctrine/tests",
"Rector\\DynamicTypeAnalysis\\Tests\\": "packages/dynamic-type-analysis/tests",
"Rector\\ElasticSearchDSL\\Tests\\": "rules/elastic-search-dsl/tests",
"Rector\\Guzzle\\Tests\\": "rules/guzzle/tests",
"Rector\\JMS\\Tests\\": "rules/jms/tests",
"Rector\\Laravel\\Tests\\": "rules/laravel/tests",
Expand Down
3 changes: 0 additions & 3 deletions config/set/elasticsearch-dsl/elasticsearch-dsl50.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# https://github.com/ongr-io/ElasticsearchDSL/blob/5.x/CHANGELOG.md
services:
Rector\ElasticSearchDSL\Rector\MethodCall\MigrateFilterToQueryRector: null

Rector\Renaming\Rector\Class_\RenameClassRector:
$oldToNewClasses:
ONGR\ElasticsearchDSL\Query\BoolQuery: 'ONGR\ElasticsearchDSL\Query\Compound\BoolQuery'
Expand Down Expand Up @@ -44,4 +42,3 @@ services:
ONGR\ElasticsearchDSL\Query\MoreLikeThisQuery: 'ONGR\ElasticsearchDSL\Query\Specialized\MoreLikeThisQuery'
ONGR\ElasticsearchDSL\Query\ScriptQuery: 'ONGR\ElasticsearchDSL\Query\Specialized\ScriptQuery'
ONGR\ElasticsearchDSL\Query\TemplateQuery: 'ONGR\ElasticsearchDSL\Query\Specialized\TemplateQuery'

35 changes: 1 addition & 34 deletions docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# All 483 Rectors Overview
# All 482 Rectors Overview

- [Projects](#projects)
- [General](#general)
Expand All @@ -17,7 +17,6 @@
- [DoctrineCodeQuality](#doctrinecodequality) (2)
- [DoctrineGedmoToKnplabs](#doctrinegedmotoknplabs) (7)
- [DynamicTypeAnalysis](#dynamictypeanalysis) (3)
- [ElasticSearchDSL](#elasticsearchdsl) (1)
- [FileSystemRector](#filesystemrector) (1)
- [Guzzle](#guzzle) (1)
- [JMS](#jms) (2)
Expand Down Expand Up @@ -3848,38 +3847,6 @@ Clean up probe that records argument types

<br>

## ElasticSearchDSL

### `MigrateFilterToQueryRector`

- class: [`Rector\ElasticSearchDSL\Rector\MethodCall\MigrateFilterToQueryRector`](/../master/rules/elastic-search-dsl/src/Rector/MethodCall/MigrateFilterToQueryRector.php)
- [test fixtures](/../master/rules/elastic-search-dsl/tests/Rector/MethodCall/MigrateFilterToQueryRector/Fixture)

Migrates addFilter to addQuery

```diff
use ONGR\ElasticsearchDSL\Search;
use ONGR\ElasticsearchDSL\Query\TermsQuery;
+use ONGR\ElasticsearchDSL\Query\Compound\BoolQuery;

class SomeClass
{
public function run()
{
$search = new Search();

- $search->addFilter(
- new TermsQuery('categoryIds', [1, 2])
+ $search->addQuery(
+ new TermsQuery('categoryIds', [1, 2]),
+ BoolQuery::FILTER
);
}
}
```

<br>

## FileSystemRector

### `RemoveProjectFileRector`
Expand Down
9 changes: 0 additions & 9 deletions rules/elastic-search-dsl/config/config.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ sonar.projectKey=rectorphp_rector

# relative paths to source
# wildcards don't work :(
sonar.sources=compiler/src,src,rules/autodiscovery/src,rules/architecture/src,packages/attribute-aware-php-doc/src,packages/better-php-doc-parser/src,rules/cakephp/src,rules/celebrity/src,rules/code-quality/src,rules/coding-style/src,packages/console-differ/src,rules/dead-code/src,rules/doctrine/src,rules/doctrine-code-quality/src,rules/framework-migration/src,packages/file-system-rector/src,rules/elastic-search-dsl/src,rules/guzzle/src,rules/laravel/src,rules/legacy/src,rules/mysql-to-mysqli/src,rules/nette-tester-to-phpunit/src,rules/nette-to-symfony/src,rules/nette/src,packages/node-collector/src,packages/node-type-resolver/src,packages/node-name-resolver/src,rules/phpstan/src,packages/phpstan-static-type-mapper/src,rules/phpunit-symfony/src,rules/phpunit/src,rules/psr4/src,rules/php-spec-to-phpunit/src,rules/php52/src,rules/php53/src,rules/php54/src,rules/php55/src,rules/php56/src,rules/php70/src,rules/php71/src,rules/php72/src,rules/php73/src,rules/php74/src,rules/php80/src,rules/removing-static/src,rules/renaming/src,rules/restoration/src,packages/refactoring/src,rules/solid/src,rules/sensio/src,packages/static-type-mapper/src,rules/symfony-code-quality/src,rules/symfony-phpunit/src,rules/symfony/src,rules/twig/src,rules/type-declaration/src,packages/vendor-locker/src,packages/rector-generator/src,rules/strict-code-quality/src,packages/dynamic-type-analysis/src,rules/php-deglobalize/src,rules/phalcon/src,rules/doctrine-gedmo-to-knplabs/src,packages/polyfill/src
sonar.sources=compiler/src,src,rules/autodiscovery/src,rules/architecture/src,packages/attribute-aware-php-doc/src,packages/better-php-doc-parser/src,rules/cakephp/src,rules/celebrity/src,rules/code-quality/src,rules/coding-style/src,packages/console-differ/src,rules/dead-code/src,rules/doctrine/src,rules/doctrine-code-quality/src,rules/framework-migration/src,packages/file-system-rector/src,rules/guzzle/src,rules/laravel/src,rules/legacy/src,rules/mysql-to-mysqli/src,rules/nette-tester-to-phpunit/src,rules/nette-to-symfony/src,rules/nette/src,packages/node-collector/src,packages/node-type-resolver/src,packages/node-name-resolver/src,rules/phpstan/src,packages/phpstan-static-type-mapper/src,rules/phpunit-symfony/src,rules/phpunit/src,rules/psr4/src,rules/php-spec-to-phpunit/src,rules/php52/src,rules/php53/src,rules/php54/src,rules/php55/src,rules/php56/src,rules/php70/src,rules/php71/src,rules/php72/src,rules/php73/src,rules/php74/src,rules/php80/src,rules/removing-static/src,rules/renaming/src,rules/restoration/src,packages/refactoring/src,rules/solid/src,rules/sensio/src,packages/static-type-mapper/src,rules/symfony-code-quality/src,rules/symfony-phpunit/src,rules/symfony/src,rules/twig/src,rules/type-declaration/src,packages/vendor-locker/src,packages/rector-generator/src,rules/strict-code-quality/src,packages/dynamic-type-analysis/src,rules/php-deglobalize/src,rules/phalcon/src,rules/doctrine-gedmo-to-knplabs/src,packages/polyfill/src

sonar.tests=tests,rules/autodiscovery/tests,rules/architecture/tests,packages/better-php-doc-parser/tests,rules/cakephp/tests,rules/celebrity/tests,rules/code-quality/tests,rules/coding-style/tests,rules/dead-code/tests,rules/doctrine/tests,rules/doctrine-code-quality/tests,rules/elastic-search-dsl/tests,rules/guzzle/tests,rules/laravel/tests,rules/legacy/tests,rules/mysql-to-mysqli/tests,rules/nette-tester-to-phpunit/tests,rules/nette-to-symfony/tests,rules/nette/tests,packages/node-type-resolver/tests,utils/phpstan-extensions/src,rules/phpstan/tests,rules/phpunit-symfony/tests,rules/phpunit/tests,rules/psr4/tests,rules/php-spec-to-phpunit/tests,rules/php52/tests,rules/php53/tests,rules/php54/tests,rules/php55/tests,rules/php56/tests,rules/php70/tests,rules/php71/tests,rules/php72/tests,rules/php73/tests,rules/php74/tests,rules/php80/tests,rules/removing-static/tests,rules/renaming/tests,rules/restoration/tests,rules/solid/tests,rules/sensio/tests,rules/symfony-code-quality/tests,rules/symfony-phpunit/tests,rules/symfony/tests,rules/twig/tests,rules/type-declaration/tests,rules/strict-code-quality/tests,packages/dynamic-type-analysis/tests,rules/php-deglobalize/tests,rules/phalcon/tests,utils/documentation-generator/src,utils/phpstan-attribute-type-syncer/src,utils/phpstan-static-type-mapper-checker/src,rules/doctrine-gedmo-to-knplabs/tests,packages/polyfill/tests
sonar.tests=tests,rules/autodiscovery/tests,rules/architecture/tests,packages/better-php-doc-parser/tests,rules/cakephp/tests,rules/celebrity/tests,rules/code-quality/tests,rules/coding-style/tests,rules/dead-code/tests,rules/doctrine/tests,rules/doctrine-code-quality/tests,rules/guzzle/tests,rules/laravel/tests,rules/legacy/tests,rules/mysql-to-mysqli/tests,rules/nette-tester-to-phpunit/tests,rules/nette-to-symfony/tests,rules/nette/tests,packages/node-type-resolver/tests,utils/phpstan-extensions/src,rules/phpstan/tests,rules/phpunit-symfony/tests,rules/phpunit/tests,rules/psr4/tests,rules/php-spec-to-phpunit/tests,rules/php52/tests,rules/php53/tests,rules/php54/tests,rules/php55/tests,rules/php56/tests,rules/php70/tests,rules/php71/tests,rules/php72/tests,rules/php73/tests,rules/php74/tests,rules/php80/tests,rules/removing-static/tests,rules/renaming/tests,rules/restoration/tests,rules/solid/tests,rules/sensio/tests,rules/symfony-code-quality/tests,rules/symfony-phpunit/tests,rules/symfony/tests,rules/twig/tests,rules/type-declaration/tests,rules/strict-code-quality/tests,packages/dynamic-type-analysis/tests,rules/php-deglobalize/tests,rules/phalcon/tests,utils/documentation-generator/src,utils/phpstan-attribute-type-syncer/src,utils/phpstan-static-type-mapper-checker/src,rules/doctrine-gedmo-to-knplabs/tests,packages/polyfill/tests

# see https://docs.sonarqube.org/latest/project-administration/narrowing-the-focus/#NarrowingtheFocus-patterns
sonar.exclusions=src/**/*.php.inc,rules/**/*.php.inc,packages/**/*.php.inc,packages/**/Fixture/**/*,rules/**/Fixture/**/*,tests/**/Source/**/*