Skip to content

Remove a param docblock made redundant by the added type - #26

Merged
TomasVotruba merged 1 commit into
mainfrom
remove-redundant-param-docblocks
Sep 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
remove-redundant-param-docblocks

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

When a parameter is given a native type and the doc comment already declares that same type in an @param tag, the tag becomes pure duplication:

/**
 * @param string $value   // redundant once the type is added
 */
public function foo(string $value) {}

This removes the redundant @param line for any type - scalars, arrays, and objects (matched with or without a leading backslash) - and drops the whole doc comment when nothing else is left. A tag is kept when it carries a description, or when its type differs from the one added (e.g. @param mixed while the added type is \DateTime).

  • new phpast.StripRedundantDocParams, driven by the type text apply writes for each parameter
  • a blank comment line left behind by a removed tag is cleaned up too
  • covered by phpast unit tests and apply end-to-end cases

When a native type is added and the doc comment declares the same type in an
`@param <type> $name` tag, the tag now just repeats the signature. Remove it -
for any type, matching an object type with or without its leading backslash -
and drop the whole doc comment when nothing else remains. A tag with a trailing
description, or one whose type differs from the added type, is kept.
@TomasVotruba
TomasVotruba merged commit 59da93a into main Sep 15, 2026
1 check passed
@TomasVotruba
TomasVotruba deleted the remove-redundant-param-docblocks branch September 15, 2026 08:50
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