-
-
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.
[NodeTypeResolver] Handle nullable extended class on ->isObjectType()…
… on DowngradeReflectionGetAttributesRector (#5224) * [NodeTypeResolver] Handle nullable extended class on ->isObjectType() on DowngradeReflectionGetAttributesRector * [ci-review] Rector Rectify * [ci-review] Rector Rectify * Fixed 🎉 * fix --------- Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
2ad03db
commit 8615d40
Showing
7 changed files
with
93 additions
and
18 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
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
28 changes: 28 additions & 0 deletions
28
tests/Issues/DowngradeNullableReflectionProperty/DowngradeNullableReflectionPropertyTest.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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\Core\Tests\Issues\DowngradeNullableReflectionProperty; | ||
|
||
use Iterator; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use Rector\Testing\PHPUnit\AbstractRectorTestCase; | ||
|
||
final class DowngradeNullableReflectionPropertyTest extends AbstractRectorTestCase | ||
{ | ||
#[DataProvider('provideData')] | ||
public function test(string $filePath): void | ||
{ | ||
$this->doTestFile($filePath); | ||
} | ||
|
||
public static function provideData(): Iterator | ||
{ | ||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture'); | ||
} | ||
|
||
public function provideConfigFilePath(): string | ||
{ | ||
return __DIR__ . '/config/configured_rule.php'; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...sues/DowngradeNullableReflectionProperty/Fixture/use_nullable_reflection_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,35 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\DowngradeNullableReflectionProperty\Fixture; | ||
|
||
class UseNullableReflectionProperty | ||
{ | ||
public function run(?\ReflectionProperty $reflectionProperty) | ||
{ | ||
if ($reflectionProperty->getAttributes('SomeAttribute')[0] ?? null) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\DowngradeNullableReflectionProperty\Fixture; | ||
|
||
class UseNullableReflectionProperty | ||
{ | ||
public function run(?\ReflectionProperty $reflectionProperty) | ||
{ | ||
if ((method_exists($reflectionProperty, 'getAttributes') ? $reflectionProperty->getAttributes('SomeAttribute') : [])[0] ?? null) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
?> |
10 changes: 10 additions & 0 deletions
10
tests/Issues/DowngradeNullableReflectionProperty/config/configured_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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Rector\Config\RectorConfig; | ||
use Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionGetAttributesRector; | ||
|
||
return static function (RectorConfig $rectorConfig): void { | ||
$rectorConfig->rule(DowngradeReflectionGetAttributesRector::class); | ||
}; |