Wrong PHP Document return for Calculate Installments
phsantosti opened this issue · comments
pagarme-php/src/Endpoints/Transactions.php
Line 171 in a70d329
I start a new implementation of this lib, using PHP 7.4.
in my implementation, i've created a abtraction of the method transactions()->calculateInstallments([]);
public function getInstallments(int $amount, string $freeInstallments = CONF_PAGARME_CREDIT_CARD_MAX_FREE_INSTALLMENTS, string $maxInstallments = CONF_PAGARME_CREDIT_CARD_MAX_INSTALLMENTS, float $interestRate = CONF_PAGARME_CREDIT_CARD_PENALTY): ArrayObject { return $this->pagarme->transactions()->calculateInstallments([ 'amount' => $amount, 'free_installments' => $freeInstallments, 'max_installments' => $maxInstallments, 'interest_rate' => $interestRate ]); }
But when i try to use, i receive a error message:
Fatal error: Uncaught TypeError: Return value of Application\Libraries\PaymentWeb::getInstallments() must be an instance of ArrayObject, instance of stdClass returned in C:\xampp74\htdocs\corecms\application\Libraries\PaymentWeb.php on line 100
In the PHP DOC of this method, show a ArrayObject in return, so i use ArrayObject in return, but the real return is object (stdClass).
I change the return to stdClass and it works correctly, then i create this issue.
public function getInstallments(int $amount, string $freeInstallments = CONF_PAGARME_CREDIT_CARD_MAX_FREE_INSTALLMENTS, string $maxInstallments = CONF_PAGARME_CREDIT_CARD_MAX_INSTALLMENTS, float $interestRate = CONF_PAGARME_CREDIT_CARD_PENALTY): object { return $this->pagarme->transactions()->calculateInstallments([ 'amount' => $amount, 'free_installments' => $freeInstallments, 'max_installments' => $maxInstallments, 'interest_rate' => $interestRate ]); }