-
-
Notifications
You must be signed in to change notification settings - Fork 205
Closed
Description
Hello. I was trying the new release 9.1.0 and I realized that the ForbiddenThisUseContextsSniff currently generating more false positives than actual issues.
Following use case currently resulting with an issue while it's completely valid:
<?php
class MyBar extends ArrayObject
{
protected $x = array('aa', 'bb');
public function remove($name)
{
if (isset($this[$name])) {
unset($this[$name]);
return true;
}
return false;
}
}
(new MyBar())->remove('x');producing:
"$this" can no longer be unset since PHP 7.1.
Is this intended behavior? If its not, sounds like a problem inside this case block: https://github.com/PHPCompatibility/PHPCompatibility/blob/master/PHPCompatibility/Sniffs/Variables/ForbiddenThisUseContextsSniff.php#L248 I tried to follow the flow but could not figure out a proper solution without affecting other use cases.
If someone can assist me with some tips, I would like to create a PR to reduce related false positives.