-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'rectorphp:main' into php84/rounding-modes-enum
- Loading branch information
Showing
851 changed files
with
11,754 additions
and
3,696 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM php:8-cli-alpine | ||
FROM php:8.2-cli-alpine | ||
|
||
WORKDIR /etc/rector | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# Upgrading from Rector 1.x to 2.0 | ||
|
||
## PHP version requirements | ||
|
||
Rector now uses PHP 7.4 or newer to run. | ||
|
||
<br> | ||
|
||
## Rector now uses PHP-Parser 5 | ||
|
||
See [upgrading guide](https://github.com/nikic/PHP-Parser/blob/master/UPGRADE-5.0.md) for PHP-Parser. | ||
|
||
<br> | ||
|
||
## Rector now uses PHPStan 2 | ||
|
||
See [upgrading guide](https://github.com/phpstan/phpstan-src/blob/2.0.x/UPGRADING.md) for PHPStan. | ||
|
||
<br> | ||
|
||
## Upgrade for custom Rules writers | ||
|
||
### 1. `AbstractScopeAwareRector` is removed, use `AbstractRector` instead | ||
|
||
The `Rector\Rector\AbstractScopeAwareRector` was too granular to fetch single helper object. It made creating new custom rules ambiguous, one layer more complex and confusing. This class has been removed in favor of standard `AbstractRector`. The `Scope` object can be fetched via `ScopeFetcher`. | ||
|
||
**Before** | ||
|
||
```php | ||
use Rector\Rector\AbstractScopeAwareRector; | ||
|
||
final class SimpleRector extends AbstractScopeAwareRector | ||
{ | ||
public function refactorWithScope(Node $node, Scope $scope): ?Node | ||
{ | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
**After** | ||
|
||
```php | ||
use Rector\Rector\AbstractRector; | ||
use Rector\PHPStan\ScopeFetcher; | ||
|
||
final class SimpleRector extends AbstractRector | ||
{ | ||
public function refactor(Node $node): ?Node | ||
{ | ||
if (...) { | ||
// this allow to fetch scope only when needed | ||
$scope = ScopeFetcher::fetch($node); | ||
} | ||
|
||
// ... | ||
} | ||
} | ||
``` | ||
|
||
|
||
### 2. `AbstractRector` get focused on code, the `getRuleDefinition()` is no longer required | ||
|
||
Core rules need documentation, so people can read their feature and [search through](https://getrector.com/find-rule) them. Yet for writing custom rules and local rules, its not necessary. People often filled it empty, just to make Rector happy. | ||
|
||
This is no longer needed. Now The `getRuleDefinition()` method has been removed: | ||
|
||
```diff | ||
use Rector\Rector\AbstractRector; | ||
-use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; | ||
-use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; | ||
|
||
final class SimpleRector extends AbstractRector | ||
{ | ||
- public function getRuleDefinition(): RuleDefinition | ||
- { | ||
- return new RuleDefinition('// @todo fill the description', [ | ||
- new CodeSample( | ||
- <<<'CODE_SAMPLE' | ||
-// @todo fill code before | ||
-CODE_SAMPLE | ||
- , | ||
- <<<'CODE_SAMPLE' | ||
-// @todo fill code after | ||
-CODE_SAMPLE | ||
- ), | ||
- ]); | ||
- } | ||
|
||
// valuable code here | ||
} | ||
``` | ||
|
||
If you need description yourself to understand rule after many months, use the common place for documentation - docblock above class. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
build/target-repository/e2e/reflection-union-php72/composer.json
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
build/target-repository/e2e/reflection-union-php72/rector.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.