I have class defined like this:
class FileSystem
{
private static $_instance = NULL;
private function __construct()
{
...
}
public static function getInstance()
{
if (self::$_instance === NULL) { // <- line 83
self::$_instance = new FileSystem;
}
return self::$_instance;
}
...
}
The error I get when running it is:
Uncaught Error: Access to undeclared static property: FileSystem::$_instance in /var/www/html/.../FileSystem.php:83
Server on which the code is running has php 7.1.
Method that calls that class is in another class:
public function stream_close()
{
if (!is_resource($this->_stream)) {
return false;
}
FileSystem::getInstance()->fclose($this->_stream);
return true;
}
your code as posted in your question should work fine. There is one reason of this kind of error and it's when you don't declare you static attribute so your error must be something like you forgot to save or that you have commented that declaration and so on.