You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there is false positive error in StaticThisUsageSniff. Anonymous class definition inside static method with using $this variable, the sniff consider it as mistake.
Example code:
private static function functionExample(array $data)
{
return new class()
{
private $data;
public function __construct(array $data)
{
$this->data = $data;
}
};
}
Result: Usage of "$this" in static methods will cause runtime errors
The text was updated successfully, but these errors were encountered:
gsherwood
changed the title
Wrong StaticThisUsageSniff with anonymous class
Squiz.Scope.StaticThisUsage incorrectly looking inside anon classes
Dec 10, 2017
Hello,
there is false positive error in StaticThisUsageSniff. Anonymous class definition inside static method with using $this variable, the sniff consider it as mistake.
Example code:
Result:
Usage of "$this" in static methods will cause runtime errors
The text was updated successfully, but these errors were encountered: