-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.2] make AddAllowDynamicPropertiesAttributeRector configurable (#1391)
- Loading branch information
1 parent
fa31841
commit 6012e41
Showing
15 changed files
with
225 additions
and
15 deletions.
There are no files selected for viewing
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
2 changes: 1 addition & 1 deletion
2
...adding_to_descendants_of_stdclass.php.inc → ...adding_to_descendants_of_stdclass.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
2 changes: 1 addition & 1 deletion
2
...ing_to_descendants_with_magic_set.php.inc → ...ing_to_descendants_with_magic_set.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
2 changes: 1 addition & 1 deletion
2
...llow_dynamic_properties_attribute.php.inc → ...llow_dynamic_properties_attribute.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
10 changes: 10 additions & 0 deletions
10
...opertiesAttributeRector/Fixture/Skip/skips_adjusting_class_outside_transform_list.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,10 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector\Fixture\Skip; | ||
|
||
class DoesNothingOnExcludedClass | ||
{ | ||
public string $someProperty = 'hello world'; | ||
} | ||
|
||
?> |
22 changes: 22 additions & 0 deletions
22
...owDynamicPropertiesAttributeRector/FixtureAllClasses/add_allow_dynamic_properties.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,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector\FixtureAllClasses; | ||
|
||
class WantsAttribute | ||
{ | ||
public string $someProperty = 'hello world'; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector\FixtureAllClasses; | ||
|
||
#[\AllowDynamicProperties] | ||
class WantsAttribute | ||
{ | ||
public string $someProperty = 'hello world'; | ||
} | ||
|
||
?> |
24 changes: 24 additions & 0 deletions
24
...icPropertiesAttributeRector/FixtureAllClasses/append_add_allow_dynamic_properties.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,24 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector\FixtureAllClasses; | ||
|
||
#[\Immutable] | ||
class AppendAttribute | ||
{ | ||
public string $someProperty = 'hello world'; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector\FixtureAllClasses; | ||
|
||
#[\Immutable] | ||
#[\AllowDynamicProperties] | ||
class AppendAttribute | ||
{ | ||
public string $someProperty = 'hello world'; | ||
} | ||
|
||
?> |
22 changes: 22 additions & 0 deletions
22
...ropertiesAttributeRector/FixtureAllClasses/skip_adding_to_descendants_of_stdclass.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,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector\FixtureAllClasses; | ||
|
||
use stdClass; | ||
|
||
class ChildOfStdClass extends stdClass | ||
{ | ||
public string $someProperty = 'hello world'; | ||
} | ||
|
||
class DescendantOfStdClass extends ChildOfStdClass | ||
{ | ||
public string $someProperty = 'hello space'; | ||
} | ||
|
||
class GrandChildOfStdClass extends ChildOfStdClass | ||
{ | ||
public string $someProperty = 'hello universe'; | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
...ertiesAttributeRector/FixtureAllClasses/skip_adding_to_descendants_with_magic_set.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,28 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector\FixtureAllClasses; | ||
|
||
class MagicSetObjects | ||
{ | ||
private array $props = []; | ||
|
||
public function __set(string $name, $value) { | ||
$this->props[$name] = $value; | ||
} | ||
|
||
public function __get(string $name) { | ||
return $this->props[$name]; | ||
} | ||
} | ||
|
||
class AnotherMagicObject extends MagicSetObjects | ||
{ | ||
public string $data = 'hello world'; | ||
} | ||
|
||
class YetAnotherMagic extends AnotherMagicObject | ||
{ | ||
public string $data = 'hello space'; | ||
} | ||
|
||
?> |
19 changes: 19 additions & 0 deletions
19
...ibuteRector/FixtureAllClasses/skip_already_has_allow_dynamic_properties_attribute.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\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector\FixtureAllClasses; | ||
|
||
#[\AllowDynamicProperties] | ||
class AlreadyHasAttribute | ||
{ | ||
public string $someProperty = 'hello world'; | ||
} | ||
|
||
class ChildOfAlreadyHasAttribute extends AlreadyHasAttribute { | ||
public string $someProperty = 'hello space'; | ||
} | ||
|
||
class GrandkidOfAlreadyHasAttribute extends ChildOfAlreadyHasAttribute { | ||
public string $someProperty = 'hello universe'; | ||
} | ||
|
||
?> |
33 changes: 33 additions & 0 deletions
33
...micPropertiesAttributeRector/UnconfiguredAddAllowDynamicPropertiesAttributeRectorTest.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,33 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class UnconfiguredAddAllowDynamicPropertiesAttributeRectorTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureAllClasses'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/unconfigured_rule.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
11 changes: 11 additions & 0 deletions
11
...sform/Rector/Class_/AddAllowDynamicPropertiesAttributeRector/config/unconfigured_rule.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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Transform\Rector\Class_\AddAllowDynamicPropertiesAttributeRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$services = $containerConfigurator->services(); | ||
$services->set(AddAllowDynamicPropertiesAttributeRector::class); | ||
}; |
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