-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Skip from call with return docblock on ReduceAlwaysFalseIf…
…OrRector (#6361) * [DeadCode] Skip from call with return docblock on ReduceAlwaysFalseIfOrRector * add native
- Loading branch information
1 parent
748330a
commit 8e96b1b
Showing
3 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...dCode/Rector/If_/ReduceAlwaysFalseIfOrRector/Fixture/from_call_with_native_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,51 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\If_\ReduceAlwaysFalseIfOrRector\Fixture; | ||
|
||
class FromCallWithNativeReturn | ||
{ | ||
/** | ||
* @return \DateTime | ||
*/ | ||
private function get(): \DateTime | ||
{ | ||
return new \DateTime('now'); | ||
} | ||
|
||
public function run($number) | ||
{ | ||
if (! $this->get() || $number > 50) { | ||
return 'yes'; | ||
} | ||
|
||
return 'no'; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\If_\ReduceAlwaysFalseIfOrRector\Fixture; | ||
|
||
class FromCallWithNativeReturn | ||
{ | ||
/** | ||
* @return \DateTime | ||
*/ | ||
private function get(): \DateTime | ||
{ | ||
return new \DateTime('now'); | ||
} | ||
|
||
public function run($number) | ||
{ | ||
if ($number > 50) { | ||
return 'yes'; | ||
} | ||
|
||
return 'no'; | ||
} | ||
} | ||
|
||
?> |
23 changes: 23 additions & 0 deletions
23
...ector/If_/ReduceAlwaysFalseIfOrRector/Fixture/skip_from_call_with_return_docblock.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,23 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\If_\ReduceAlwaysFalseIfOrRector\Fixture; | ||
|
||
class SkipFromCallWithReturnDocblock | ||
{ | ||
/** | ||
* @return \DateTime | ||
*/ | ||
private function get() | ||
{ | ||
return null; | ||
} | ||
|
||
public function run($number) | ||
{ | ||
if (! $this->get() || $number > 50) { | ||
return 'yes'; | ||
} | ||
|
||
return 'no'; | ||
} | ||
} |
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