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

Create function parameter assignment sniff #104

Open
aik099 opened this issue Jan 5, 2019 · 0 comments
Open

Create function parameter assignment sniff #104

aik099 opened this issue Jan 5, 2019 · 0 comments

Comments

@aik099
Copy link
Owner

aik099 commented Jan 5, 2019

Idea of the sniff is to locate function/method parameter that's value is replaced within the method. This is bad idea, because any code that reads parameter value expects original value to be retrieved, but instead is getting last modified value version.

Implementation plan:

  1. listen for T_FUNCTION token
  2. get parameters of that function, that aren't passed by reference
  3. lookup names of these parameters in function body and T_WHITESPACE (optional) + assignment tokens after it

P.S.
The $$var code won't be supported, because it's hard to trace back statically.

Examples

function functionName($param1, &$param2)
{
    $param1 = 'new value' . $param1; // not allowed
    $param2 = 'new value'; // allowed, because value is passed by reference
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant