-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php80] Make configurable INLINE_PUBLIC on ClassPropertyAssignToConst…
…ructorPromotionRector (#3126) Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
2b35d2e
commit 3f2a16a
Showing
13 changed files
with
401 additions
and
89 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
31 changes: 31 additions & 0 deletions
31
...omotionRector/FixtureInlinePublicDisable/final_class_non_typed_protected_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,31 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\FixtureInlinePublicDisable; | ||
|
||
final class FinalClassNonTypedProtectedProperty | ||
{ | ||
/** | ||
* @var object | ||
*/ | ||
protected $x; | ||
|
||
public function __construct(object $x) | ||
{ | ||
$this->x = $x; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\FixtureInlinePublicDisable; | ||
|
||
final class FinalClassNonTypedProtectedProperty | ||
{ | ||
public function __construct(protected object $x) | ||
{ | ||
} | ||
} | ||
|
||
?> |
31 changes: 31 additions & 0 deletions
31
...orPromotionRector/FixtureInlinePublicDisable/non_final_non_typed_private_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,31 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\FixtureInlinePublicDisable; | ||
|
||
class NonFinalNonTypedPrivateProperty | ||
{ | ||
/** | ||
* @var object | ||
*/ | ||
private $x; | ||
|
||
public function __construct(object $x) | ||
{ | ||
$this->x = $x; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\FixtureInlinePublicDisable; | ||
|
||
class NonFinalNonTypedPrivateProperty | ||
{ | ||
public function __construct(private object $x) | ||
{ | ||
} | ||
} | ||
|
||
?> |
16 changes: 16 additions & 0 deletions
16
...ctor/FixtureInlinePublicDisable/skip_non_typed_non_final_class_protected_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,16 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\FixtureInlinePublicDisable; | ||
|
||
class SkipNonTypedNonFinalClassProtectedProperty | ||
{ | ||
/** | ||
* @var object | ||
*/ | ||
protected $x; | ||
|
||
public function __construct(object $x) | ||
{ | ||
$this->x = $x; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...omotionRector/FixtureInlinePublicDisable/typed_non_final_class_protected_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,28 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\FixtureInlinePublicDisable; | ||
|
||
class TypedNonFinalClassProtectedProperty | ||
{ | ||
protected object $x; | ||
|
||
public function __construct(object $x) | ||
{ | ||
$this->x = $x; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector\FixtureInlinePublicDisable; | ||
|
||
class TypedNonFinalClassProtectedProperty | ||
{ | ||
public function __construct(protected object $x) | ||
{ | ||
} | ||
} | ||
|
||
?> |
29 changes: 29 additions & 0 deletions
29
...Rector/Class_/ClassPropertyAssignToConstructorPromotionRector/InlinePublicDisableTest.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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Tests\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class InlinePublicDisableTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixtureInlinePublicDisable'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule_disable_inline_public.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
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
...opertyAssignToConstructorPromotionRector/config/configured_rule_disable_inline_public.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\Config\RectorConfig; | ||
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
// inline public is disable by default | ||
$rectorConfig->rule(ClassPropertyAssignToConstructorPromotionRector::class); | ||
}; |
Oops, something went wrong.