-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NullableCompareToNullRector: Don't trust phpdocs (#5225)
- Loading branch information
Showing
4 changed files
with
52 additions
and
31 deletions.
There are no files selected for viewing
24 changes: 14 additions & 10 deletions
24
rules-tests/CodingStyle/Rector/If_/NullableCompareToNullRector/Fixture/fixture.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 |
---|---|---|
@@ -1,23 +1,27 @@ | ||
<?php | ||
|
||
/** @var stdClass|null $value */ | ||
$value = null; | ||
if ($value) { | ||
} | ||
namespace Rector\Tests\CodingStyle\Rector\If_\NullableCompareToNullRector\Fixture; | ||
|
||
function doFoo(?stdClass $value) { | ||
if ($value) { | ||
} | ||
|
||
if (!$value) { | ||
if (!$value) { | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
/** @var stdClass|null $value */ | ||
$value = null; | ||
if ($value !== null) { | ||
} | ||
namespace Rector\Tests\CodingStyle\Rector\If_\NullableCompareToNullRector\Fixture; | ||
|
||
function doFoo(?stdClass $value) { | ||
if ($value !== null) { | ||
} | ||
|
||
if ($value === null) { | ||
if ($value === null) { | ||
} | ||
} | ||
|
||
?> |
18 changes: 18 additions & 0 deletions
18
rules-tests/CodingStyle/Rector/If_/NullableCompareToNullRector/Fixture/skip_mixed.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,18 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodingStyle\Rector\If_\NullableCompareToNullRector\Fixture; | ||
|
||
class SkipMixed | ||
{ | ||
public function run(mixed $mixed) | ||
{ | ||
if (! $mixed) { | ||
return 'truethy mixed'; | ||
} | ||
|
||
if ($mixed) { | ||
return 'falsey mixed'; | ||
} | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
rules-tests/CodingStyle/Rector/If_/NullableCompareToNullRector/Fixture/skip_phpdoc.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,11 @@ | ||
<?php | ||
|
||
/** @var stdClass|null $value */ | ||
$value = null; | ||
if ($value) { | ||
} | ||
|
||
if (!$value) { | ||
} | ||
|
||
?> |
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