The class has been incorrectly instantiated, which would cause a runtime error.
This issue will be reported in the following cases:
This is not an exhaustive list of causes. Please refer to each occurrence's message for more details.
class Greet
{
public function __construct(string $message) {}
public function getInstance()
{
new self(); // invalid: "Greet" class's constructor invoked with 0 parameters, but 1 is required.
}
}
$greet = new Greet(1); // invalid: Greet expects its first parameter to be a string, but it is given an int.
interface Admin {}
$admin = new Admin(); // invalid: cannot instantiate an interface.
abstract class User
{
abstract public function getName();
}
$admin = new User(); // invalid: cannot instantiate an abstract class.
class Greet
{
public function __construct(string $message) {}
public function getInstance()
{
new self('Hello');
}
}
$greet = new Greet('Hi');