-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RemoveNonExistingVarAnnotationRector: Allow return annotations (#3534)
Fixes rectorphp/rector#7859
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...ector/Node/RemoveNonExistingVarAnnotationRector/Fixture/return_annotation_invalid.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\Node\RemoveNonExistingVarAnnotationRector\Fixture; | ||
|
||
class ReturnAnnotationInvalid | ||
{ | ||
public function getValue() | ||
{ | ||
/** @var int */ | ||
return; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector\Fixture; | ||
|
||
class ReturnAnnotationInvalid | ||
{ | ||
public function getValue() | ||
{ | ||
return; | ||
} | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
...ctor/Node/RemoveNonExistingVarAnnotationRector/Fixture/return_annotation_unwanted.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\Node\RemoveNonExistingVarAnnotationRector\Fixture; | ||
|
||
class ReturnAnnotationUnwanted | ||
{ | ||
public function getValue() | ||
{ | ||
/** @var array<string, string> */ | ||
return new stdClass; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector\Fixture; | ||
|
||
class ReturnAnnotationUnwanted | ||
{ | ||
public function getValue() | ||
{ | ||
return new stdClass; | ||
} | ||
} | ||
|
||
?> |
12 changes: 12 additions & 0 deletions
12
...or/Node/RemoveNonExistingVarAnnotationRector/Fixture/skip_direct_return_func_call.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,12 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector\Fixture; | ||
|
||
class SkipDirectReturnFuncCall | ||
{ | ||
public function getValue(): int|false|null | ||
{ | ||
/** @var int|false|null */ | ||
return filter_input(INPUT_GET, 'value', FILTER_VALIDATE_INT); | ||
} | ||
} |
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