Skip to content

Commit

Permalink
[Restoration] Remove InferParamFromClassMethodReturnRector, only temp…
Browse files Browse the repository at this point in the history
…orary rule for local refactoring
  • Loading branch information
TomasVotruba committed Oct 7, 2021
1 parent 7db8bc8 commit 37d1c2d
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 484 deletions.
83 changes: 34 additions & 49 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

- [Carbon](#carbon) (2)

- [CodeQuality](#codequality) (68)
- [CodeQuality](#codequality) (69)

- [CodingStyle](#codingstyle) (39)

Expand Down Expand Up @@ -90,7 +90,7 @@

- [Renaming](#renaming) (11)

- [Restoration](#restoration) (6)
- [Restoration](#restoration) (5)

- [Strict](#strict) (5)

Expand Down Expand Up @@ -845,6 +845,38 @@ Make if conditions more explicit

<br>

### ExplicitMethodCallOverMagicGetSetRector

Replace magic property fetch using `__get()` and `__set()` with existing method get*()/set*() calls

- class: [`Rector\CodeQuality\Rector\PropertyFetch\ExplicitMethodCallOverMagicGetSetRector`](../rules/CodeQuality/Rector/PropertyFetch/ExplicitMethodCallOverMagicGetSetRector.php)

```diff
class MagicCallsObject
{
// adds magic __get() and __set() methods
use \Nette\SmartObject;

private $name;

public function getName()
{
return $this->name;
}
}

class SomeClass
{
public function run(MagicObject $magicObject)
{
- return $magicObject->name;
+ return $magicObject->getName();
}
}
```

<br>

### FixClassCaseSensitivityNameRector

Change miss-typed case sensitivity name to correct one
Expand Down Expand Up @@ -9651,53 +9683,6 @@ return static function (ContainerConfigurator $containerConfigurator): void {

<br>

### InferParamFromClassMethodReturnRector

Change `@param` doc based on another method return type

:wrench: **configure it!**

- class: [`Rector\Restoration\Rector\ClassMethod\InferParamFromClassMethodReturnRector`](../rules/Restoration/Rector/ClassMethod/InferParamFromClassMethodReturnRector.php)

```php
use Rector\Restoration\Rector\ClassMethod\InferParamFromClassMethodReturnRector;
use Rector\Restoration\ValueObject\InferParamFromClassMethodReturn;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();

$services->set(InferParamFromClassMethodReturnRector::class)
->call('configure', [[
InferParamFromClassMethodReturnRector::INFER_PARAMS_FROM_CLASS_METHOD_RETURNS => ValueObjectInliner::inline([
new InferParamFromClassMethodReturn('SomeClass', 'process', 'getNodeTypes'),
]),
]]);
};
```


```diff
class SomeClass
{
public function getNodeTypes(): array
{
return [String_::class];
}

+ /**
+ * @param String_ $node
+ */
public function process(Node $node)
{
}
}
```

<br>

### MakeTypedPropertyNullableIfCheckedRector

Make typed property nullable if checked
Expand Down
11 changes: 0 additions & 11 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
use Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector;
use Rector\CodingStyle\ValueObject\ReturnArrayClassMethodToYield;
use Rector\Core\Configuration\Option;
use Rector\Core\Rector\AbstractRector;
use Rector\Nette\Set\NetteSetList;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Restoration\Rector\ClassMethod\InferParamFromClassMethodReturnRector;
use Rector\Restoration\ValueObject\InferParamFromClassMethodReturn;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
Expand All @@ -38,15 +35,7 @@
$containerConfigurator->import(NetteSetList::NETTE_UTILS_CODE_QUALITY);
$containerConfigurator->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY);

$configuration = ValueObjectInliner::inline([
new InferParamFromClassMethodReturn(AbstractRector::class, 'refactor', 'getNodeTypes'),
]);

$services = $containerConfigurator->services();
$services->set(InferParamFromClassMethodReturnRector::class)
->call('configure', [[
InferParamFromClassMethodReturnRector::INFER_PARAMS_FROM_CLASS_METHOD_RETURNS => $configuration,
]]);

// phpunit
$services->set(PreferThisOrSelfMethodCallRector::class)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 37d1c2d

Please sign in to comment.