-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DowngradeTo74: Fix rector rule if ReflectionClass is nullable
- Loading branch information
1 parent
dac3d75
commit a82dccc
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...ector/MethodCall/DowngradeReflectionGetAttributesRector/Fixture/class_is_nullable.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\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionGetAttributesRector\Fixture; | ||
|
||
class SomeClass | ||
{ | ||
public function run(?\ReflectionClass $reflectionClass) | ||
{ | ||
if ($reflectionClass->getAttributes('SomeAttribute')[0] ?? null) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp80\Rector\MethodCall\DowngradeReflectionGetAttributesRector\Fixture; | ||
|
||
class SomeClass | ||
{ | ||
public function run(?\ReflectionClass $reflectionClass) | ||
{ | ||
if ((method_exists($reflectionClass, 'getAttributes') ? $reflectionClass->getAttributes('SomeAttribute') : [])[0] ?? null) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
?> |
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