-
-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RectorConfig for custom configuration methods and avoid conflicts with Symfony API #2019
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6f83cd2
Introduce `RectorContainerConfigurator`
Wirone c6a0ca7
symplify namespace
TomasVotruba 3cb0e8d
remove refactoring rule
TomasVotruba 6cc2d00
add e2e test with custom RectorConfigurator
TomasVotruba 78da0c1
shorten to RectorConfig
TomasVotruba beace59
use RectorConfig in main rector.php
TomasVotruba de5d7f4
add rector config patch
TomasVotruba 7ec0522
add RectorConfig->paths() method
TomasVotruba 0f19134
use paths() in test
TomasVotruba 30506cf
assert paths are string
TomasVotruba File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor |
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,5 @@ | ||
{ | ||
"require": { | ||
"php": "^8.1" | ||
} | ||
} |
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,22 @@ | ||
1 file with changes | ||
=================== | ||
|
||
1) src/SomeClass.php:6 | ||
|
||
---------- begin diff ---------- | ||
@@ @@ | ||
class SomeClass | ||
{ | ||
public function __construct( | ||
- private readonly \stdClass $stdClass | ||
+ private \stdClass $stdClass | ||
) | ||
{ | ||
} | ||
----------- end diff ----------- | ||
|
||
Applied rules: | ||
* DowngradeReadonlyPropertyRector (https://wiki.php.net/rfc/readonly_properties_v2) | ||
|
||
|
||
[OK] 1 file would have changed (dry-run) by 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->paths([ | ||
__DIR__ . '/src', | ||
]); | ||
|
||
$services = $rectorConfig->services(); | ||
$services->set(DowngradeReadonlyPropertyRector::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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace E2e\UseRectorConfigurator; | ||
|
||
class SomeClass | ||
{ | ||
public function __construct( | ||
private readonly \stdClass $stdClass | ||
) | ||
{ | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Config; | ||
|
||
use Rector\Core\Configuration\Option; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
use Webmozart\Assert\Assert; | ||
|
||
/** | ||
* @api | ||
* Same as Symfony container configurator, with patched return type for "set()" method for easier DX. | ||
* It is an alias for internal class that is prefixed during build, so it's basically for keeping stable public API. | ||
*/ | ||
final class RectorConfig extends ContainerConfigurator | ||
{ | ||
/** | ||
* @param mixed[] $paths | ||
*/ | ||
public function paths(array $paths): void | ||
{ | ||
Assert::allString($paths); | ||
|
||
$parameters = $this->parameters(); | ||
$parameters->set(Option::PATHS, $paths); | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this PR is merged, line needs to update in each Rector split repository's
composer.json
, so we have the same patched Symfony everywhere