pagarme-php icon indicating copy to clipboard operation
pagarme-php copied to clipboard

Wrong PHP Document return for Calculate Installments

Open phsantosti opened this issue 5 years ago • 0 comments
trafficstars

https://github.com/pagarme/pagarme-php/blob/a70d32904369d9fad1afc9c8ef998d4c785c2947/src/Endpoints/Transactions.php#L171

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 ]); }

phsantosti avatar Oct 09 '20 05:10 phsantosti