Skip to content

Commit

Permalink
[DX] Add INSTANCEOF set to work with types via instanceof checks (#3609)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Apr 13, 2023
1 parent 3a9bebf commit bc0a0d7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
22 changes: 22 additions & 0 deletions config/set/instanceof.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\FuncCall\InlineIsAInstanceOfRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector;
use Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector;
use Rector\TypeDeclaration\Rector\Empty_\EmptyOnNullableObjectToInstanceOfRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
EmptyOnNullableObjectToInstanceOfRector::class,
GetClassToInstanceOfRector::class,
InlineIsAInstanceOfRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
RemoveDuplicatedInstanceOfRector::class,
RemoveDeadInstanceOfRector::class,
]);
};
5 changes: 5 additions & 0 deletions packages/Set/ValueObject/SetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,9 @@ final class SetList implements SetListInterface
* @var string
*/
public const EARLY_RETURN = __DIR__ . '/../../../config/set/early-return.php';

/**
* @var string
*/
public const INSTANCEOF = __DIR__ . '/../../../config/set/instanceof.php';
}
1 change: 1 addition & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
SetList::PRIVATIZATION,
SetList::NAMING,
SetList::TYPE_DECLARATION,
SetList::INSTANCEOF,
SetList::EARLY_RETURN,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
SetList::CODING_STYLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@

return static function (RectorConfig $rectorConfig): void {
$rectorConfig
->ruleWithConfiguration(RemoveFuncCallRector::class, [
'var_dump'
]);
->ruleWithConfiguration(RemoveFuncCallRector::class, ['var_dump']);
};

0 comments on commit bc0a0d7

Please sign in to comment.