Skip to content

Keep an empty docblock as is#3394

Closed
shaal wants to merge 4 commits intorectorphp:masterfrom
shaal:do-not-remove-empty-docblock
Closed

Keep an empty docblock as is#3394
shaal wants to merge 4 commits intorectorphp:masterfrom
shaal:do-not-remove-empty-docblock

Conversation

@shaal
Copy link
Copy Markdown
Contributor

@shaal shaal commented May 20, 2020

To maintain the assumption, that rector would only change what it was instructed to, when there's an empty docblock, we want to preserve it.

Removing empty docblocks should be a specific Rector rule that people can opt-in to run, instead of automatically removed every time Rector runs.

@shaal
Copy link
Copy Markdown
Contributor Author

shaal commented May 20, 2020

I think the PR is failing because now there is nothing that calls the function isPhpDocNodeEmpty().

@TomasVotruba
Copy link
Copy Markdown
Member

TomasVotruba commented May 20, 2020

One of them is coding standard and second are failing tests.

image

@shaal shaal mentioned this pull request May 20, 2020
@shaal
Copy link
Copy Markdown
Contributor Author

shaal commented May 21, 2020

@shaal
Copy link
Copy Markdown
Contributor Author

shaal commented May 21, 2020

@TomasVotruba how would you like to resolve this?
Should this PR update all the failing tests to keep the empty docblocks as is?

@TomasVotruba
Copy link
Copy Markdown
Member

TomasVotruba commented May 21, 2020

When the original docblock is:

/**
 * @var int
 */

And then @var is removed by some rule (e.g. PHP 7.4 typed properties), the output cannot be:

/**
 */

but:


So the docblock must be cleaned from start/end if changed.

If there is no change, it can be printed in original way.

@TomasVotruba
Copy link
Copy Markdown
Member

This is surpassed by #5251

Thank you for your work 👍

@shaal
Copy link
Copy Markdown
Contributor Author

shaal commented Mar 3, 2021

Thank you @TomasVotruba

TomasVotruba added a commit that referenced this pull request Feb 20, 2023
rectorphp/rector-src@38372f2 [Php56][Php70] Handle infinite loop on AddDefaultValueForUndefinedVariableRector+IfToSpaceshipRector (#3394)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants