[DeadCode] Add RemoveMixedDocblockOverruledByNativeTypeRector to drop @param mixed / @return mixed overruled by native type by TomasVotruba · Pull Request #8089 · rectorphp/rector-src · GitHub
Skip to content

[DeadCode] Add RemoveMixedDocblockOverruledByNativeTypeRector to drop @param mixed / @return mixed overruled by native type#8089

Merged
TomasVotruba merged 2 commits into
mainfrom
tv-remove-mixed-docblock
Jun 26, 2026
Merged

[DeadCode] Add RemoveMixedDocblockOverruledByNativeTypeRector to drop @param mixed / @return mixed overruled by native type#8089
TomasVotruba merged 2 commits into
mainfrom
tv-remove-mixed-docblock

Conversation

@TomasVotruba

@TomasVotruba TomasVotruba commented Jun 26, 2026

Copy link
Copy Markdown
Member

Removes @param mixed $x and @return mixed docblocks when a native type declaration is already present. A native type always overrules mixed (the widest type), so such tags add no information.

 final class SomeClass
 {
-    /**
-     * @param mixed $value
-     * @return mixed
-     */
     public function run(int $value): string
     {
     }
 }

Distinct from RemoveUselessParamTagRector, which only fires when the doc type equals the native type (e.g. @param string + string). This handles the mixed vs more-specific-native case (@param mixed + int).

Safety guards

  • param must have a native type declaration; otherwise kept
  • return must have a returnType; otherwise kept
  • tags with a description are kept (description is the only useful info on a mixed tag)
  • only pure mixed is matched (not mixed[], etc.)

Registered in DeadCodeLevel in the docblock group, right after RemoveDuplicatedReturnSelfDocblockRector.

@TomasVotruba TomasVotruba changed the title [DeadCode] Add RemoveMixedDocblockRector to drop @param mixed / @return mixed duplicating native type [DeadCode] Add RemoveMixedDocblockOverruledByNativeTypeRector to drop @param mixed / @return mixed overruled by native type Jun 26, 2026
@TomasVotruba TomasVotruba merged commit b163af7 into main Jun 26, 2026
65 checks passed
@TomasVotruba TomasVotruba deleted the tv-remove-mixed-docblock branch June 26, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant