Por algum motivo meus getters estão retornando NULL (todos eles) como corrijo? Erro que recebo: PHP Fatal error: Uncaught TypeError: Account::returnName(): Return value must be of type string, null returned in /workspace/Main.php:38
<?php
class Account
{
private $holderDocument;
private $holderName;
private $accountBalance;
private $accountLimit;
private static $Accounts = 0;
public function __construct(string $holderDocument, string $holderName)
{
$this->holderDocument = $holderDocument;
$this->holderName = $holderName;
$this->checkName($holderName);
$this->accountBalance = 0;
$this->accountLimit = 0;
self::$Accounts++;
}
public function returnAccounts()
{
return $this->Accounts;
}
public function returnBalance(): float
{
return $this->accountBalance;
}
public function returnDocument(): string
{
return $this->holderDocument;
}
public function returnName(): string
{
return $this->holdeName;
}
public function withdrawal($amountWithdraw): void
{
if (($this->accountBalance+$this->accountLimit) < $amountWithdraw)
{
echo "You have insufficient funds in your account to complete the transaction";
return;
}
$this->accountBalance -= $amountWithdraw;
echo "Withdrawal successfully completed", PHP_EOL;
}
public function deposit($amountDeposit): void
{
if ($amountDeposit < 0)
{
echo "It's not possible to make a deposit of a negative amount.";
return;
}
$this->accountBalance += $amountDeposit;
echo "Deposit successfully completed", PHP_EOL;
}
public function wireTransfer(float $amountTransfer , Account $targetAccount)
{
if (($this->accountBalance+$this->accountLimit) < $amountTransfer)
{
echo "You have insufficient funds in your account to complete the transaction";
return;
}
$this->withdrawal($amountTransfer);
$targetAccount->deposit($amountTransfer);
}
public function checkName(string $holderName)
{
if (strlen($holderName) < 3)
{
echo "The name must have a 3 characters lenght";
exit();
}
}
}
$firstAccount = new Account("123459831", "João Pedro");
$firstAccount->deposit(500);
$firstAccount->withdrawal(200);
$firstAccount->returnName();
?>