From 13d2f98643ea9242e8bf5e05ad795988ca6f9a91 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Nov 2020 02:09:53 +0100 Subject: [PATCH] [automated] Re-Generate Nodes/Rectors Documentation (#4656) Co-authored-by: kodiakhq --- docs/rector_rules_overview.md | 126 +++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 3 deletions(-) diff --git a/docs/rector_rules_overview.md b/docs/rector_rules_overview.md index 8890edcdf5e..6f7e9f4f452 100644 --- a/docs/rector_rules_overview.md +++ b/docs/rector_rules_overview.md @@ -349,18 +349,36 @@ return static function (ContainerConfigurator $containerConfigurator): void { ## AddLiteralSeparatorToNumberRector -Add "_" as thousands separator in numbers +Add "_" as thousands separator in numbers for higher or equals to limitValue config + +:wrench: **configure it!** - class: `Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector` +```php +use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector; +use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; + +return static function (ContainerConfigurator $containerConfigurator): void { + $services = $containerConfigurator->services(); + + $services->set(AddLiteralSeparatorToNumberRector::class) + ->call('configure', [[ + AddLiteralSeparatorToNumberRector::LIMIT_VALUE => 1000000, + ]]); +}; +``` + +↓ + ```diff class SomeClass { public function run() { -- $int = 1000; +- $int = 500000; - $float = 1000500.001; -+ $int = 1_000; ++ $int = 500_000; + $float = 1_000_500.001; } } @@ -2130,6 +2148,32 @@ Change `containerBuilder->expand()` to static call with parameters
+## CallOnAppArrayAccessToStandaloneAssignRector + +Replace magical call on `$this->app["something"]` to standalone type assign variable + +- class: `Rector\Laravel\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector` + +```diff + class SomeClass + { + /** + * @var \Illuminate\Contracts\Foundation\Application + */ + private $app; + + public function run() + { +- $validator = $this->app['validator']->make('...'); ++ /** @var \Illuminate\Validation\Factory $validationFactory */ ++ $validationFactory = $this->app['validator']; ++ $validator = $validationFactory->make('...'); + } + } +``` + +
+ ## CallUserFuncCallToVariadicRector Replace call_user_func_call with variadic @@ -7060,6 +7104,38 @@ Change is method names to start with is/has/was
+## MakeTaggedPassedToParameterIterableTypeRector + +Change param type to iterable, if passed one + +- class: `Rector\Laravel\Rector\New_\MakeTaggedPassedToParameterIterableTypeRector` + +```diff + class AnotherClass + { + /** + * @var \Illuminate\Contracts\Foundation\Application + */ + private $app; + + public function create() + { + $tagged = $this->app->tagged('some_tagged'); + return new SomeClass($tagged); + } + } + + class SomeClass + { +- public function __construct(array $items) ++ public function __construct(iterable $items) + { + } + } +``` + +
+ ## MakeTypedPropertyNullableIfCheckedRector Make typed property nullable if checked @@ -9029,6 +9105,28 @@ Change `@param` types to type declarations if not a BC-break
+## ParamTypeToAssertTypeRector + +Turn `@param` type to `assert` type + +- class: `Rector\StrictCodeQuality\Rector\ClassMethod\ParamTypeToAssertTypeRector` + +```diff + class SomeClass + { + /** + * @param \A|\B $arg + */ + public function run($arg) + { +- ++ \Webmozart\Assert\Assert::isAnyOf($arg, [\A::class, \B::class]); + } + } +``` + +
+ ## ParentClassToTraitsRector Replaces parent class to specific traits @@ -9672,6 +9770,28 @@ return static function (ContainerConfigurator $containerConfigurator): void {
+## PropertyDeferToDeferrableProviderToRector + +Change deprecated `$defer` = true; to Illuminate\Contracts\Support\DeferrableProvider interface + +- class: `Rector\Laravel\Rector\Class_\PropertyDeferToDeferrableProviderToRector` + +```diff + use Illuminate\Support\ServiceProvider; ++use Illuminate\Contracts\Support\DeferrableProvider; + +-final class SomeServiceProvider extends ServiceProvider ++final class SomeServiceProvider extends ServiceProvider implements DeferrableProvider + { +- /** +- * @var bool +- */ +- protected $defer = true; + } +``` + +
+ ## PropertyToMethodRector Replaces properties assign calls be defined methods.