Skip to content

Commit 20d9930

Browse files
committed
feat: allow ExplicitNullableParamTypeRector to run for PHP 8.1
This allows this rule to be applied one minor version earlier in "eager" mode, since DNF type specifications came one step after intersection types themselves. I was originally just going to bump the required PHP version up to 8.2, but I saw precedence for adding version guards in other rules: - ReturnTypeFromStrictTypedCallRector - AddParamTypeDeclarationRector - IsIterableRector So when PHP 8.1 is a possibility, we can still *reduce* the number of deprecations without fully committing to them all.
1 parent 572089f commit 20d9930

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

rules/Php84/Rector/Param/ExplicitNullableParamTypeRector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ public function refactor(Node $node): ?Param
9393
if ($node->type instanceof UnionType) {
9494
$node->type->types[] = new Name('null');
9595
} elseif ($node->type instanceof ComplexType) {
96+
if (! $this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::UNION_INTERSECTION_TYPES)) {
97+
return null;
98+
}
99+
96100
/** @var IntersectionType $nodeType */
97101
$nodeType = $node->type;
98102
$node->type = new UnionType([$nodeType, new Name('null')]);

0 commit comments

Comments
 (0)