-
-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Strict] Handle may be unitialized property on DisallowedEmptyRuleFix…
…erRector
- Loading branch information
1 parent
f4257af
commit 86066d7
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
.../DisallowedEmptyRuleFixerRector/Fixture/may_unitialized_property_no_default_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,41 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector\Fixture; | ||
|
||
final class MayUnitializedPropertyNoDefaultValue | ||
{ | ||
public array $items; | ||
|
||
public function isEmpty() | ||
{ | ||
return empty($this->items); | ||
} | ||
|
||
public function isNotEmpty() | ||
{ | ||
return ! empty($this->items); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector\Fixture; | ||
|
||
final class MayUnitializedPropertyNoDefaultValue | ||
{ | ||
public array $items; | ||
|
||
public function isEmpty() | ||
{ | ||
return ! isset($this->items) || $this->items === []; | ||
} | ||
|
||
public function isNotEmpty() | ||
{ | ||
return isset($this->items) && $this->items !== []; | ||
} | ||
} | ||
|
||
?> |
41 changes: 41 additions & 0 deletions
41
.../Rector/Empty_/DisallowedEmptyRuleFixerRector/Fixture/property_with_default_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,41 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector\Fixture; | ||
|
||
final class PropertyWithDefaultValue | ||
{ | ||
public array $items = []; | ||
|
||
public function isEmpty() | ||
{ | ||
return empty($this->items); | ||
} | ||
|
||
public function isNotEmpty() | ||
{ | ||
return ! empty($this->items); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector\Fixture; | ||
|
||
final class PropertyWithDefaultValue | ||
{ | ||
public array $items = []; | ||
|
||
public function isEmpty() | ||
{ | ||
return $this->items === []; | ||
} | ||
|
||
public function isNotEmpty() | ||
{ | ||
return $this->items !== []; | ||
} | ||
} | ||
|
||
?> |