Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Add RemoveNullTagValueNodeRector (#5352)
* [DeadCode] Add RemoveNullTagValueNodeRector * [ci-review] Rector Rectify * [ci-review] Rector Rectify * rename fixture * desc * register in missing in set command on purpose * add fixtures * fix param * fix var * [ci-review] Rector Rectify * fix * more fixture * more fixture * regenerate docs --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
f8c3a2e
commit 287eab3
Showing
11 changed files
with
378 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...eadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector/Fixture/remove_null_param.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class RemoveNullParam | ||
{ | ||
/** | ||
* @param null $foo | ||
*/ | ||
function foo($foo = null) | ||
{ | ||
return null; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class RemoveNullParam | ||
{ | ||
function foo($foo = null) | ||
{ | ||
return null; | ||
} | ||
} | ||
|
||
?> |
30 changes: 30 additions & 0 deletions
30
...adCode/Rector/ClassMethod/RemoveNullTagValueNodeRector/Fixture/remove_null_return.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class RemoveNull | ||
{ | ||
/** | ||
* @return null | ||
*/ | ||
function foo() | ||
{ | ||
return null; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class RemoveNull | ||
{ | ||
function foo() | ||
{ | ||
return null; | ||
} | ||
} | ||
|
||
?> |
24 changes: 24 additions & 0 deletions
24
.../DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector/Fixture/remove_null_var.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class RemoveNullVar | ||
{ | ||
/** | ||
* @var null | ||
*/ | ||
public $var = null; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class RemoveNullVar | ||
{ | ||
public $var = null; | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
...DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector/Fixture/remove_null_var2.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class RemoveNullVar2 | ||
{ | ||
public function foo() | ||
{ | ||
/** @var null $var */ | ||
$var = execute(); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class RemoveNullVar2 | ||
{ | ||
public function foo() | ||
{ | ||
$var = execute(); | ||
} | ||
} | ||
|
||
?> |
14 changes: 14 additions & 0 deletions
14
.../Rector/ClassMethod/RemoveNullTagValueNodeRector/Fixture/skip_different_tag_value.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class SkipDifferentTagValue | ||
{ | ||
/** | ||
* @return mixed | ||
*/ | ||
function foo() | ||
{ | ||
return null; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ode/Rector/ClassMethod/RemoveNullTagValueNodeRector/Fixture/skip_with_description.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector\Fixture; | ||
|
||
class SkipWithDescription | ||
{ | ||
/** | ||
* @return null some description | ||
*/ | ||
function foo() | ||
{ | ||
return null; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...Code/Rector/ClassMethod/RemoveNullTagValueNodeRector/RemoveNullTagValueNodeRectorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use SplFileInfo; | ||
|
||
final class RemoveNullTagValueNodeRectorTest extends AbstractRectorTestCase | ||
{ | ||
#[DataProvider('provideData')] | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
/** | ||
* @return Iterator<SplFileInfo> | ||
*/ | ||
public static function provideData(): Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...tests/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector/config/configured_rule.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\DeadCode\Rector\ClassMethod\RemoveNullTagValueNodeRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(RemoveNullTagValueNodeRector::class); | ||
}; |
Oops, something went wrong.