-
-
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.
[TypeDeclaration] Handle return self on TypedPropertyFromStrictGetter…
…MethodReturnTypeRector on php 8.0 feature enabled (#3088) * Add failing test fixture for TypedPropertyFromStrictGetterMethodReturnTypeRector # Failing Test for TypedPropertyFromStrictGetterMethodReturnTypeRector Based on https://getrector.org/demo/ee1243f2-fa5c-4460-a27d-31fb67439bbf * [TypeDeclaration] Handle return self on TypedPropertyFromStrictGetterMethodReturnTypeRector no php 8.0 feature enabled * rename fixture * [ci-review] Rector Rectify * Fix namespace * using SelfStaticType instead of SelfObjectType Co-authored-by: Matthias Schmidt <matthias@mttsch.dev> Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
30afbb8
commit 335d593
Showing
5 changed files
with
85 additions
and
5 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
29 changes: 29 additions & 0 deletions
29
...operty/TypedPropertyFromStrictGetterMethodReturnTypeRector/FixturePhp80/some_self.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,29 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector\FixturePhp80; | ||
|
||
final class SomeSelf | ||
{ | ||
private $test; | ||
|
||
public function getTest(): self | ||
{ | ||
return $this->test; | ||
} | ||
} | ||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector\FixturePhp80; | ||
|
||
final class SomeSelf | ||
{ | ||
private self $test; | ||
|
||
public function getTest(): self | ||
{ | ||
return $this->test; | ||
} | ||
} | ||
?> |
29 changes: 29 additions & 0 deletions
29
...erMethodReturnTypeRector/TypedPropertyFromStrictGetterMethodReturnTypePhp80RectorTest.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\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector; | ||
|
||
use Iterator; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class TypedPropertyFromStrictGetterMethodReturnTypePhp80RectorTest extends AbstractRectorTestCase | ||
{ | ||
/** | ||
* @dataProvider provideData() | ||
*/ | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public function provideData(): Iterator | ||
{ | ||
return $this->yieldFilesFromDirectory(__DIR__ . '/FixturePhp80'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/rule_php80.php'; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...Rector/Property/TypedPropertyFromStrictGetterMethodReturnTypeRector/config/rule_php80.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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\Core\ValueObject\PhpVersionFeature; | ||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(TypedPropertyFromStrictGetterMethodReturnTypeRector::class); | ||
|
||
$rectorConfig->phpVersion(PhpVersionFeature::STATIC_RETURN_TYPE); | ||
}; |
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