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

[Docs] Add XML doc for Squiz.Classes.ClassFileName sniff #843

Merged

Conversation

braindawg
Copy link
Contributor

Description

Adds XML doc for the Squiz\Classes\ClassFileName sniff. This is the only sniff I was able to find that refers to both the filename and the file contents, so I'm open to feedback regarding the representation of the filename within the code samples. I tried several variations, hoping this is clear enough.

Suggested changelog entry

Add XML doc for the Squiz.Classes.ClassFileName sniff

Related issues/external references

Partial fix for #148

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

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.

Adjusts the `<em>` tags in the Squiz.Classes.ClassFileName sniff XML
docs to better highlight the parts of the code samples that illustrate
the purpose of the sniff.
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.

Hi @braindawg and welcome to the PHP_CodeSniffer project! Thank you for taking on these documentation tasks.

This PR is looking good and as things are, I'm happy to approve it.

However, while reviewing this PR, I looked at the sniff code and realized the sniff contains a problematic logic error, in that it recommends changing the class name instead of changing the file name.
This is problematic as the file name may be a name which is not a valid symbol name in PHP, which would make the error inactionable.

So, inspired by this PR, I've opened PR #845 to fix this (and make some other small improvements). The pertinent commit is c1cf608

So now I have a conundrum: merge this PR now and update the docs in PR #845 to change "Class name [case] does not match filename [case]." to "Filename [case] does not match class name [case]." or ask you to make that change in this PR and merge this after #845 has been merged.

What would you prefer ? And would you like to review PR #845 considering that you're already familiar with the sniff ?

@jrfnl jrfnl changed the title [Docs] Add XML doc for Squiz\Classes\ClassFileName sniff [Docs] Add XML doc for Squiz.Classes.ClassFileName sniff Feb 25, 2025
@braindawg
Copy link
Contributor Author

So now I have a conundrum: merge this PR now and update the docs in PR #845 to change "Class name [case] does not match filename [case]." to "Filename [case] does not match class name [case]." or ask you to make that change in this PR and merge this after #845 has been merged.

Seems like 6 of one, half a dozen of the other to me, as the same changes need to be made either way. If you have no preference, I'll wait until #845 is merged and then add a commit to update the verbiage as suggested.

I'm happy to take a look at #845, too, though it might be a few days before I can get to it.

@jrfnl
Copy link
Member

jrfnl commented Feb 26, 2025

If you have no preference, I'll wait until #845 is merged and then add a commit to update the verbiage as suggested.

I'm happy to take a look at #845, too, though it might be a few days before I can get to it.

Sounds like a plan. Thank you for understanding and I look forward to your review when you find the time 👍🏻

@jrfnl
Copy link
Member

jrfnl commented Mar 7, 2025

@braindawg Thanks for reviewing #845. I've now merged that PR. Would you like to update this PR to match ?

Per PR PHPCSStandards#845, the filename must be modified to match the class name,
since class names are much more restrictive than filenames and the
inverse is not always possible.

This clarifies in the example titles that the fix for the invalid code
is to modify the filename rather than the class name.
@braindawg
Copy link
Contributor Author

Updated the example titles to reflect that the filename must be changed to match the class name.

@jrfnl jrfnl added this to the 3.12.0 milestone Mar 7, 2025
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 for bearing with me and making that update @braindawg ! LGTM. Merging.

@jrfnl jrfnl merged commit 8adbcb2 into PHPCSStandards:master Mar 7, 2025
46 checks passed
jrfnl pushed a commit that referenced this pull request Mar 7, 2025
* Add XML doc for Squiz\Classes\ClassFileName sniff

* [Doc] Emphasize sniff focus for ClassFileName

Adjusts the `<em>` tags in the Squiz.Classes.ClassFileName sniff XML
docs to better highlight the parts of the code samples that illustrate
the purpose of the sniff.

* Correct file/class name relation in sniff doc

Per PR #845, the filename must be modified to match the class name,
since class names are much more restrictive than filenames and the
inverse is not always possible.

This clarifies in the example titles that the fix for the invalid code
is to modify the filename rather than the class name.
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.

2 participants