-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
[WIP] [GH-38] Implement undefined variable rule #65
Comments
👍 |
also need it |
Hey, what's the state of play with this? I notice it keeps getting milestone bumped, seems like a very useful rule. |
@oligriffiths you are welcome to contribute a PR. |
Moving to Future for now. If we are going to implement this, we can have a look at the proposed changes in https://github.com/phpmd/phpmd/pull/64/files. |
need it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is a class of bugs when you use a variable that is undefined. Some PHP functions allow this when the parameter is passed by reference, however it is still decouraged not define this variables beforehand for clarity.
This rule implements checking for undefined variables. This is done by first collecting all variable assignments, then all parameters of the method/function.\n\nIn the case of the following example, PHP_PMD will trigger two errors, unused local variable and undefined variable:
therefore propose to work on this patch further by modifying the UnusedLocalVariable to only warn about variable assignments that are not used and keep the undefined variable rule to catch the error class shown above.\n\nPossible Improvements:\n\n* Check if the variable assignment is actually BEFORE the variable usage. Currently it only checks that there is an assignment, it could be after the usage though.
Synced from GitHub: #64
Synced from PivotalTracker: http://www.pivotaltracker.com/story/show/42432495
The text was updated successfully, but these errors were encountered: