-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add RectorConfigurator for custom configuration methods and avoid con…
…flicts with Symfony API (#2019) Co-authored-by: Grzegorz Korba <grzegorz.korba@codito.pl>
- Loading branch information
1 parent
4b351a7
commit c20f230
Showing
10 changed files
with
111 additions
and
23 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
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