Skip to content

Conversation

fredden
Copy link
Member

@fredden fredden commented Feb 8, 2024

Description

This began as part of #289.

When a parse error is present, the PSR12.Files.DeclareStatement sniff was incorrectly performing an auto-fix. (That change was then conflicting with PSR12.Operators.OperatorSpacing - #289 includes improvements to that sniff to avoid the conflict from the other end too.) This pull request adds some defensive coding to identify and bow out when a particular parse error is detected. Further defensive coding can be added in future to detect other errors here. (@jrfnl has expressed intention to rewrite this sniff, so I'm not addressing all parse error cases right now.)

Suggested changelog entry

PSR12.Files.DeclareStatement - bow out when parse error detected

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

PR checklist

  • I have checked there is no other PR open for the same change.
  • I have read the Contribution Guidelines.
  • I grant the project the right to include and distribute the code under the BSD-3-Clause license (and I have the right to grant these rights).
  • I have added tests to cover my changes.
  • I have verified that the code complies with the projects coding standards.
fredden added a commit to fredden/PHP_CodeSniffer that referenced this pull request Feb 8, 2024
@jrfnl jrfnl added this to the 3.9.0 milestone Feb 8, 2024
@jrfnl
Copy link
Member

jrfnl commented Feb 8, 2024

Related to #152

Copy link
Member

@jrfnl jrfnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fredden !

I'll merge this and will try and get back to the rewrite of the sniff soonish to address everything else ;-)

@jrfnl jrfnl merged commit 7240235 into PHPCSStandards:master Feb 10, 2024
@fredden fredden deleted the parse-error-detection/PSR12.Files.DeclareStatement branch February 10, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment