pagarme / pagarme-php

:blue_heart: Pagar.me's PHP API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong PHP Document return for Calculate Installments

phsantosti opened this issue · comments

* @return \ArrayObject

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