[DeadCode] Fix RemoveUnreachableStatementRector issue with global function declarations (#5575)

This commit is contained in:
addshore 2021-02-16 16:03:52 +00:00 committed by GitHub
parent 5921571647
commit a3f3b0e7d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -12,6 +12,7 @@ use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassLike;
use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\Stmt\Else_;
use PhpParser\Node\Stmt\Function_;
use PhpParser\Node\Stmt\If_;
use PhpParser\Node\Stmt\Namespace_;
use PhpParser\Node\Stmt\Nop;
@ -174,6 +175,10 @@ CODE_SAMPLE
return true;
}
if ($stmt instanceof Function_) {
return true;
}
if ($stmt instanceof Namespace_) {
return true;
}

View File

@ -0,0 +1,11 @@
<?php
namespace Rector\DeadCode\Tests\Rector\Stmt\RemoveUnreachableStatementRector\Fixture;
calledFunction();
return;
function calledFunction()
{
define("SOMETHING",true);
}