File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
rules-tests/DeadCode/Rector/FunctionLike/NarrowTooWideReturnTypeRector/config
rules/DeadCode/Rector/FunctionLike Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 44
55use Rector \Config \RectorConfig ;
66use Rector \DeadCode \Rector \FunctionLike \NarrowTooWideReturnTypeRector ;
7+ use Rector \ValueObject \PhpVersionFeature ;
78
8- return RectorConfig::configure ()
9- ->withRules ([NarrowTooWideReturnTypeRector::class]);
9+ return static function (RectorConfig $ rectorConfig ): void {
10+ $ rectorConfig ->rule (NarrowTooWideReturnTypeRector::class);
11+ $ rectorConfig ->phpVersion (PhpVersionFeature::NEVER_TYPE );
12+ };
Original file line number Diff line number Diff line change 3131use Rector \Reflection \ReflectionResolver ;
3232use Rector \StaticTypeMapper \StaticTypeMapper ;
3333use Rector \TypeDeclaration \TypeInferer \SilentVoidResolver ;
34+ use Rector \ValueObject \PhpVersionFeature ;
35+ use Rector \VersionBonding \Contract \MinPhpVersionInterface ;
3436use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
3537use Symplify \RuleDocGenerator \ValueObject \RuleDefinition ;
3638
3739/**
3840 * @see \Rector\Tests\DeadCode\Rector\FunctionLike\NarrowTooWideReturnTypeRector\NarrowTooWideReturnTypeRectorTest
3941 */
40- final class NarrowTooWideReturnTypeRector extends AbstractRector
42+ final class NarrowTooWideReturnTypeRector extends AbstractRector implements MinPhpVersionInterface
4143{
4244 public function __construct (
4345 private readonly BetterNodeFinder $ betterNodeFinder ,
4446 private readonly StaticTypeMapper $ staticTypeMapper ,
4547 private readonly ReflectionResolver $ reflectionResolver ,
4648 private readonly SilentVoidResolver $ silentVoidResolver ,
49+ private readonly PhpVersionProvider $ phpVersionProvider ,
4750 ) {
4851 }
4952
@@ -85,6 +88,11 @@ public function foo(): string|int
8588 );
8689 }
8790
91+ public function provideMinPhpVersion (): int
92+ {
93+ return PhpVersionFeature::UNION_TYPES ;
94+ }
95+
8896 /**
8997 * @return array<class-string<Node>>
9098 */
You can’t perform that action at this time.
0 commit comments