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

Remove unused variables from a few sniffs #2514

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

rodrigoprimo
Copy link
Collaborator

As discussed in #2513 (comment), this PR removes unused variables detected automatically using PHPStorm code inspection from a few sniffs.

I have checked that the removed variables do not trigger errors at PHPStan levels higher than what we are currently using and that the modified code has at least minimal test coverage.

@dingo-d, in the screenshot that you shared in #2513 (comment), EnqueuedResourcesSniff.php is included, but I was not able to find any unused variables in this file.

This commit removes three instances where a variable was passed to
`preg_match()` as the third parameter to fill it with the results of the
search, but later it was not used.
This commit removes the unnecessary initialization of the variable
`$end` at the beginning of the sniff code. Every single `case` statement
of the `switch` that follows either re-initialize the variable with a
different value or returns without using the variable.
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.

LGTM. Thanks @rodrigoprimo!

For context regarding the $matches parameters in preg_match() calls: prior to PHP 5.4, the $matches parameter was a required parameter when calling preg_match_all(), so this is likely a left-over loosely related to that (from when PHP 5.3 was still supported).

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