Skip to content

[Rector] Skip deprecated rules in set + check bare int refactor() return - #277

Merged
TomasVotruba merged 4 commits into
mainfrom
skip-deprecated-rector-rules-in-set
Aug 24, 2026
Merged

[Rector] Skip deprecated rules in set + check bare int refactor() return#277
TomasVotruba merged 4 commits into
mainfrom
skip-deprecated-rector-rules-in-set

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Aug 24, 2026

Copy link
Copy Markdown
Member

Two src/Rules/Rector/ improvements.

1. PhpUpgradeDowngradeRegisteredInSetRule — skip deprecated rules

The rule demands every Php*/DowngradePhp* Rector rule be registered in its matching config set:

Register "Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector" service to "php73.php" config set

Deprecated rules (marker Rector\Configuration\Deprecation\Contract\DeprecatedInterface) are on their way out and are not registered in sets, so they are now skipped — same treatment as ConfigurableRectorInterface.

use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
use Rector\Contract\Rector\RectorInterface;

// before: "Register ... to php80.php config set"   after: skipped
final class SomeDeprecatedPhp80Rector implements RectorInterface, DeprecatedInterface
{
}

2. NoIntegerRefactorReturnRule — also check bare int return type

Previously only a UnionType return type (e.g. Node|int) was inspected; a bare int return type slipped through unchecked. Now bare int is checked too, while REMOVE_NODE stays allowed.

// now reported — was silently skipped before
public function refactor(Node $node): int
{
    return NodeVisitor::DONT_TRAVERSE_CHILDREN;
}

// allowed
public function refactor(Node $node): int
{
    return NodeVisitor::REMOVE_NODE;
}

@TomasVotruba TomasVotruba changed the title [Rector] Skip deprecated rules in PhpUpgradeDowngradeRegisteredInSetRule [Rector] Skip deprecated rules in set + check bare int refactor() return Aug 24, 2026
@TomasVotruba
TomasVotruba force-pushed the skip-deprecated-rector-rules-in-set branch from 79012fe to ddd05c1 Compare August 24, 2026 18:29
@TomasVotruba
TomasVotruba merged commit 15eccad into main Aug 24, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the skip-deprecated-rector-rules-in-set branch August 24, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant