Access to an undefined static property App\StaticPropertyCallCheck::$name
11 public function run(): void
12 {
13 // invalid
14 self::$name = 'test';15
16 // valid
17 self::$path = '/home/user';
Description
This issue is raised when there's an attempt to access a static property that is undefined in the current scope. Please make sure that the property being accessed exists.
Bad practice
class CopyFile
{
public function setPath(): void
{
self::$path = '/home/new_user'; // invalid: static property "path" is not defined
}
}
Recommended
class CopyFile
{
private static $path = null;
public function setPath(): void
{
self::$path = '/home/new_user';
}
}