Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong PHP Document return for Calculate Installments #374

Open
phsantosti opened this issue Oct 9, 2020 · 0 comments
Open

Wrong PHP Document return for Calculate Installments #374

phsantosti opened this issue Oct 9, 2020 · 0 comments

Comments

@phsantosti
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant