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

Squiz/ObjectInstantiation: move parse error test to its own file #543

Conversation

biinari
Copy link
Contributor

@biinari biinari commented Jul 14, 2024

Description

Suggested changelog entry

N/A

Related issues/external references

See #143

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.

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.

In principle all good, but if I look at the original commit (PR squizlabs/PHP_CodeSniffer#836) which introduced this, I'm not sure this test was intended as a parse error test, nor that it has value for this sniff.

I think this test has been superseded by PR
squizlabs/PHP_CodeSniffer#3484, which also added dedicated tests for that part of the Tokenizer, so instead, it might be better to remove this test from the ObjectInstantiation test case file.

@biinari What do you think ?

@jrfnl jrfnl removed this from the 3.10.x Next milestone Jul 14, 2024
@biinari
Copy link
Contributor Author

biinari commented Jul 14, 2024

Well spotted @jrfnl, on closer inspection I agree that this test was not intended to check for parse errors / live coding.

It looks like it was intended to check for new when used as a name rather than a keyword (though it may have failed to cover that given the line finishes early causing a parse error). This test for keyword context does indeed seem to be covered by squizlabs/PHP_CodeSniffer#3484 and squizlabs/PHP_CodeSniffer#3608, which added some tests for function names.

I can't see any way that this sniff would need a live coding test case, all the needed context comes before the new keyword so it would not create a false positive.

I'm happy to close this PR and submit another to remove this test from the test case file without the file rename.

@jrfnl
Copy link
Member

jrfnl commented Jul 14, 2024

I can't see any way that this sniff would need a live coding test case, all the needed context comes before the new keyword so it would not create a false positive.

Just checked the sniff code and I agree with that conclusion.

I'm happy to close this PR and submit another to remove this test from the test case file without the file rename.

Sounds like a good plan!

@biinari biinari closed this Jul 14, 2024
@biinari biinari deleted the chore/143-Squiz_ObjectInstantiation_separate_parse_error branch July 14, 2024 18:36
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