-
-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Allow change empty() to [] compare of other object prop…
…erty usage on SimplifyEmptyCheckOnEmptyArrayRector (#6147)
- Loading branch information
1 parent
a9ddf8f
commit 25b437a
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...ty_/SimplifyEmptyCheckOnEmptyArrayRector/Fixture/property_fetch_from_other_object.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,31 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector\Fixture; | ||
|
||
use Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector\Source\OtherClass; | ||
|
||
final class PropertyFetchFromOtherObject | ||
{ | ||
public function isEmptyArray(OtherClass $otherClass): bool | ||
{ | ||
return empty($otherClass->prop); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector\Fixture; | ||
|
||
use Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector\Source\OtherClass; | ||
|
||
final class PropertyFetchFromOtherObject | ||
{ | ||
public function isEmptyArray(OtherClass $otherClass): bool | ||
{ | ||
return $otherClass->prop === []; | ||
} | ||
} | ||
|
||
?> |
10 changes: 10 additions & 0 deletions
10
...ests/CodeQuality/Rector/Empty_/SimplifyEmptyCheckOnEmptyArrayRector/Source/OtherClass.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); | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector\Source; | ||
|
||
class OtherClass | ||
{ | ||
public array $prop = []; | ||
} |
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