Skip to content

Commit

Permalink
[CodeQuality] Skip __construct() method on ExplicitReturnNullRector (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Mar 22, 2024
1 parent 61c7e92 commit b042152
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\ClassMethod\ExplicitReturnNullRector\Fixture;

class SkipConstruct
{
public function __construct(int $number)
{
if ($number > 50) {
return 'yes';
}

echo 'test';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Rector\PhpParser\Node\BetterNodeFinder;
use Rector\Rector\AbstractRector;
use Rector\TypeDeclaration\TypeInferer\SilentVoidResolver;
use Rector\ValueObject\MethodName;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;

Expand Down Expand Up @@ -100,6 +101,10 @@ public function refactor(Node $node): ?Node
return null;
}

if ($this->isName($node, MethodName::CONSTRUCT)) {
return null;
}

if ($this->containsYieldOrThrow($node)) {
return null;
}
Expand Down

0 comments on commit b042152

Please sign in to comment.