-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeQuality] Skip non typed property no default value never assigned…
… on SimplifyEmptyCheckOnEmptyArrayRector (#3171) Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
2848e0d
commit bbd9d4f
Showing
11 changed files
with
265 additions
and
20 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...nEmptyArrayRectorTest/Fixture/non_typed_property_has_default_value_never_assigned.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,33 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRectorTest\Fixture; | ||
|
||
final class NonTypedPropertyHasDefaultValueNeverAssigned | ||
{ | ||
/** @var array */ | ||
public $property = []; | ||
|
||
public function isEmpty(): bool | ||
{ | ||
return empty($this->property); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRectorTest\Fixture; | ||
|
||
final class NonTypedPropertyHasDefaultValueNeverAssigned | ||
{ | ||
/** @var array */ | ||
public $property = []; | ||
|
||
public function isEmpty(): bool | ||
{ | ||
return $this->property === []; | ||
} | ||
} | ||
|
||
?> |
23 changes: 23 additions & 0 deletions
23
...rayRectorTest/Fixture/skip_non_typed_property_has_default_value_assigned_nullable.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,23 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRectorTest\Fixture; | ||
|
||
final class SkipNonTypedPropertyHasDefaultValueAssignedNullable | ||
{ | ||
/** @var array */ | ||
public $property = []; | ||
|
||
public function run() | ||
{ | ||
if (rand(0, 1)) { | ||
$this->property = null; | ||
} else { | ||
$this->property = []; | ||
} | ||
} | ||
|
||
public function isEmpty(): bool | ||
{ | ||
return empty($this->property); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...est/Fixture/skip_non_typed_property_has_default_value_has_assign_dynamic_property.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,19 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRectorTest\Fixture; | ||
|
||
final class SkipNonTypedPropertyHasDefaultValueHasAssignDynamicProperty | ||
{ | ||
/** @var array */ | ||
public $property = []; | ||
|
||
public function assignDynamicProperty(string $dynamicProperty) | ||
{ | ||
$this->$dynamicProperty = 'value'; | ||
} | ||
|
||
public function isEmpty(): bool | ||
{ | ||
return empty($this->property); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...tyArrayRectorTest/Fixture/skip_non_typed_property_no_default_value_never_assigned.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,14 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRectorTest\Fixture; | ||
|
||
final class SkipNonTypedPropertyNoDefaultValueNeverAssigned | ||
{ | ||
/** @var array */ | ||
public $property; | ||
|
||
public function isEmpty(): bool | ||
{ | ||
return empty($this->property); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...implifyEmptyCheckOnEmptyArrayRectorTest/Fixture/skip_non_typed_property_promotion.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\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRectorTest\Fixture; | ||
|
||
final class SkipNonTypedPropertyPromotion | ||
{ | ||
/** | ||
* @param array $property | ||
*/ | ||
public function __construct(private $property) | ||
{ | ||
} | ||
|
||
public function isEmpty(): bool | ||
{ | ||
return empty($this->property); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
..._/SimplifyEmptyCheckOnEmptyArrayRectorTest/Fixture/typed_array_property_promotion.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,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRectorTest\Fixture; | ||
|
||
final class TypedArrayPropertyPromotion | ||
{ | ||
public function __construct(private array $property) | ||
{ | ||
} | ||
|
||
public function isEmpty(): bool | ||
{ | ||
return empty($this->property); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRectorTest\Fixture; | ||
|
||
final class TypedArrayPropertyPromotion | ||
{ | ||
public function __construct(private array $property) | ||
{ | ||
} | ||
|
||
public function isEmpty(): bool | ||
{ | ||
return $this->property === []; | ||
} | ||
} | ||
|
||
?> |
8 changes: 8 additions & 0 deletions
8
.../TypedPropertyFromAssignsRector/Fixture/skip_typed_from_default_value_null_assign.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,8 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class SkipTypedFromDefaultValueNullAssign | ||
{ | ||
private $name = null; | ||
} |
21 changes: 21 additions & 0 deletions
21
...r/Property/TypedPropertyFromAssignsRector/Fixture/typed_from_default_value_assign.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,21 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class TypedFromDefaultValueAssign | ||
{ | ||
private $name = []; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
final class TypedFromDefaultValueAssign | ||
{ | ||
private array $name = []; | ||
} | ||
|
||
?> |
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
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
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