<?php
class A
{
public static $instance;
public static function getInstance() {
if (static::$instance === null) {
static::$instance = new static();
}
}
}
class B extends A
{
public static $instance;
}
echo get_class(A::getInstance()) . PHP_EOL;
echo get_class(B::getInstance()) . PHP_EOL;
echo get_class(A::getInstance()) . PHP_EOL;
Fatal error: Uncaught TypeError: get_class(): Argument #1 ($object) must be of type object, null given in /in/VIeOm:19
Stack trace:
#0 {main}
thrown in /in/VIeOm on line 19
Process exited with code 255.
Warning: get_class() expects parameter 1 to be object, null given in /in/VIeOm on line 19
Warning: get_class() expects parameter 1 to be object, null given in /in/VIeOm on line 20
Warning: get_class() expects parameter 1 to be object, null given in /in/VIeOm on line 21
Warning: get_class() called without object from outside a class in /in/VIeOm on line 19
Warning: get_class() called without object from outside a class in /in/VIeOm on line 20
Warning: get_class() called without object from outside a class in /in/VIeOm on line 21