Skip to content

Commit

Permalink
[Strict] Handle may be unitialized property on DisallowedEmptyRuleFix…
Browse files Browse the repository at this point in the history
…erRector
  • Loading branch information
samsonasik committed Jan 1, 2024
1 parent f4257af commit 86066d7
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
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 !== [];
}
}

?>
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 !== [];
}
}

?>

0 comments on commit 86066d7

Please sign in to comment.