Remove dead instanceof check on type hinted property
final class SomeClass
{
private $someObject;
public function __construct(SomeObject $someObject)
{
$this->someObject = $someObject;
}
public function run()
{
- if ($this->someObject instanceof SomeObject) {
- return true;
- }
-
- return false;
+ return true;
}
}
Configure your rector.php
:
<?php
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\If_\RemoveTypedPropertyDeadInstanceOfRector;
return RectorConfig::configure()
->withRules([
RemoveTypedPropertyDeadInstanceOfRector::class,
]);