Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fixer method to remove a line #517

Closed
1 task done
andrewnicols opened this issue May 28, 2024 · 2 comments
Closed
1 task done

Add Fixer method to remove a line #517

andrewnicols opened this issue May 28, 2024 · 2 comments

Comments

@andrewnicols
Copy link

Is your feature request related to a problem?

When writing some sniff fixes, it's necessary to remove an entire line. Currently there is no helper for this.
This is particularly helpful when writing sniffs for phpdocs.

Describe the solution you'd like

$phpcsFile->fixer->beginChangeset();
$phpcsFile->fixer->removeLineAtPointer($stackPtr);
$phpcsFile->fixer->endChangeset();

Additional context (optional)

  • I intend to create a pull request to implement this feature.
@jrfnl
Copy link
Member

jrfnl commented May 30, 2024

@andrewnicols I'd like to see a more thorough specification of what you'd expect such a method to do, as it feels like the current description is wide open to interpretation.

Here are just some of the questions which pop up in my mind and there's bound to be more:

  • Would this remove the line the pointer is on ? Or the next line ? (i.e. from the end of the line)
  • What if the pointer is somewhere in the middle of a line ?
  • Would this only apply to "blank" lines (including comment blank lines) or to lines containing any content ?
  • If the latter, a generic method seems kind of dangerous as it would not be able to validate that it is the "correct" line/content to be removed. I.e. the sniff would need to validate the line contents before removing it anyway, so why delegate the removing to a specialty method which cannot verify the sniff has done the required validation ?

@jrfnl
Copy link
Member

jrfnl commented Sep 14, 2024

Closing for lack of reply. As things are, this issue is not actionable. The issue can be reopened for further discussion if the requested additional information is added.

@jrfnl jrfnl closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants