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

✨ New Generic.Strings.UnnecessaryHeredoc sniff #633

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Oct 18, 2024

Description

New Generic.Strings.UnnecessaryHeredoc sniff which encourages the use of nowdocs instead of heredocs, when there is no interpolation or expressions in the body text.

This sniff will hopefully help with the PERCS work as it intends to cover the following PER rule:

A nowdoc SHOULD be used wherever possible. Heredoc MAY be used when a nowdoc does not satisfy requirements.

Includes fixer.
Includes tests.
Includes XML docs.
Includes metrics.

Suggested changelog entry

New Generic.Strings.UnnecessaryHeredoc sniff which warns about heredocs without interpolation or expressions in the body text and can auto-fix these to nowdocs.

Types of changes

  • New feature (non-breaking change which adds functionality)

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.
  • [Required for new sniffs] I have added XML documentation for the sniff.

New `Generic.Strings.UnnecessaryHeredoc` sniff which encourages the use of nowdocs instead of heredocs, when there is no interpolation or expressions in the body text.

This sniff will hopefully help with the PERCS work as it intends to cover the following PER rule:
> A nowdoc SHOULD be used wherever possible. Heredoc MAY be used when a nowdoc does not satisfy requirements.

Includes fixer.
Includes tests.
Includes XML docs.
@jrfnl jrfnl added this to the 3.11.0 milestone Oct 18, 2024
@jrfnl jrfnl force-pushed the feature/new-unnecessaryheredoc-sniff branch 2 times, most recently from c73d112 to 1cbb4c0 Compare October 20, 2024 17:24
This commit adds metrics to the new `Generic.Strings.UnnecessaryHeredoc` sniff to allow for collecting statistical information on how often a heredoc is used without expressions or interpolation.
@jrfnl jrfnl force-pushed the feature/new-unnecessaryheredoc-sniff branch from 1cbb4c0 to a9d0457 Compare October 20, 2024 17:28
@jrfnl jrfnl merged commit 8a7ee56 into master Oct 29, 2024
50 checks passed
@jrfnl jrfnl deleted the feature/new-unnecessaryheredoc-sniff branch October 29, 2024 06:53
jrfnl added a commit that referenced this pull request Oct 29, 2024
New `Generic.Strings.UnnecessaryHeredoc` sniff which encourages the use of nowdocs instead of heredocs, when there is no interpolation or expressions in the body text.

This sniff will hopefully help with the PERCS work as it intends to cover the following PER rule:
> A nowdoc SHOULD be used wherever possible. Heredoc MAY be used when a nowdoc does not satisfy requirements.

Includes fixer.
Includes tests.
Includes metrics.
Includes XML docs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant