This issue is raised if a method with a return type does not have a return statement of an appropriate type.
class User
{
public function greet(): string
{
$message = 'Hello, there!';
// missing return statement
}
}
class User
{
public function greet()
{
$message = function (): string {
$message = 'Hello, there!';
// missing return statement
};
return $message();
}
}
class User
{
public function greet(): string
{
$message = 'Hello, there!';
return $message;
}
}
class User
{
public function greet()
{
$message = function (): string {
$message = 'Hello, there!';
return $message;
};
return $message();
}
}