-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php74] Add privatePropertyOnly config to TypedPropertyRector (#898)
- Loading branch information
1 parent
3ff1751
commit b551636
Showing
5 changed files
with
120 additions
and
1 deletion.
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
50 changes: 50 additions & 0 deletions
50
...ests/Php74/Rector/Property/TypedPropertyRector/FixturePrivatePropertyOnly/fixture.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,50 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixturePrivatePropertyOnly; | ||
|
||
class Fixture | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
private $privateProperty; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
protected $protectedProperty; | ||
} | ||
|
||
class ExtendsFixture extends Fixture | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
protected $protectedProperty; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\FixturePrivatePropertyOnly; | ||
|
||
class Fixture | ||
{ | ||
private bool $privateProperty; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
protected $protectedProperty; | ||
} | ||
|
||
class ExtendsFixture extends Fixture | ||
{ | ||
/** | ||
* @var bool | ||
*/ | ||
protected $protectedProperty; | ||
} | ||
|
||
?> |
33 changes: 33 additions & 0 deletions
33
rules-tests/Php74/Rector/Property/TypedPropertyRector/PrivatePropertyOnlyTest.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\Php74\Rector\Property\TypedPropertyRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
use Symplify\SmartFileSystem\SmartFileInfo; | ||
|
||
final class PrivatePropertyOnlyTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(SmartFileInfo $fileInfo): void | ||
{ | ||
$this->doTestFileInfo($fileInfo); | ||
} | ||
|
||
/** | ||
* @return Iterator<SmartFileInfo> | ||
*/ | ||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixturePrivatePropertyOnly'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/private_property_only.php'; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
rules-tests/Php74/Rector/Property/TypedPropertyRector/config/private_property_only.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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Core\Configuration\Option; | ||
use Rector\Php74\Rector\Property\TypedPropertyRector; | ||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; | ||
|
||
return static function (ContainerConfigurator $containerConfigurator): void { | ||
$parameters = $containerConfigurator->parameters(); | ||
$parameters->set(Option::AUTO_IMPORT_NAMES, true); | ||
|
||
$services = $containerConfigurator->services(); | ||
$services->set(TypedPropertyRector::class) | ||
->call('configure', [[ | ||
TypedPropertyRector::PRIVATE_PROPERTY_ONLY => true, | ||
]]); | ||
}; |
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