phpsa
phpsa copied to clipboard
[Bug] Trait & unused variable
Warning: Unused variable $fqcnParts in method getMetadata() in ./src/Analyzer/Pass/Statement/ConstantNaming.php [unused-variable]
Warning: Unused variable $name in method getMetadata() in ./src/Analyzer/Pass/Statement/ConstantNaming.php [unused-variable]
Warning: Unused variable $description in method getMetadata() in ./src/Analyzer/Pass/Statement/ConstantNaming.php [unused-variable]
for every analyzer. But all of them are used in the trait method.
This is caused because Trait method is merged into this Class but anyway We cannot compile method in Trait because Trait's method can use another Class where it's used, recursion oops
Another moment $fqcnParts is not used because FunctionCall to end, didnt mark this argument is used, I am worry about FunctionCall, can you take a look?
Unused variable happens for me in class, variable is initialized and passed as argument to method of a class, im getting noticed that it is unused but clearly it is.
Also i noticed that all warning of unused variables are when variable is passed to method as argument.
@Kilgaloon This is caused only for static method call, I am going to fix it
@Kilgaloon
Fixed in master branch in https://github.com/ovr/phpsa/commit/9bcb42c7032c7f1d191273e82015da3de8ea96d7
Tested on
class Test
{
/**
* @return bool
*/
public function returnTrue()
{
$a = '127.0.0.1';
self::inet_pton($a);
}
/**
* @param $test
* @return int
*/
public static function inet_pton($test)
{
return inet_pton($test);
}
}
Can you try latest changes from master branch?
Thanks
I can confirm that this is working now, but another problem is happening right now. It is related with unused variables, i will create new issue about this. #280