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

Generic/EmptyPHPStatement: improve code coverage #699

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rodrigoprimo
Copy link
Contributor

Description

This PR improves code coverage for the Generic.CodeAnalysis.EmptyPHPStatement sniff.

While adding tests for the shot open tag, I noticed a behavior in the sniff related to #593 that we might want to address in this PR or in a separate PR if it is not intentional behavior. The sniff fixes <? ; something_else(); ?> to <?something_else(); ?>. Note that there is no space between the PHP open tag and the function call. Should the sniff change to preserve one space between the PHP open tag and the function call? It is probably not a high priority as the resulting code is not a parse error, and short open tags are not very popular.

Related issues/external references

Part of #146

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.

`$prevNonEmpty` will never be `false` as there will always be at least
a PHP open tag token before the semicolon token.
This commits removes an unreachable default case.
`$tokens[$stackPtr]['type']` will always be either `T_SEMICOLON` or
`T_CLOSE_TAG` as those are the two tokens that this sniff listens for.
So, the default case will never be reached.
Doing this to be able to create another test file to test the sniff
with the short open tag.
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