From 61ad9eaa38174a338914637bafa4e75013f61449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Walker?= Date: Thu, 15 Oct 2026 19:11:56 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20declara=20o=20null=20nos=20par=C3=A2metr?= =?UTF-8?q?os=20de=20gateway=20opcionais?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O PHP 8.4 deprecia o nullable implícito em tempo de compilação. A deprecação é impressa por todo processo que carrega os models, e os testes da aplicação que rodam em processo separado falham com ela. Os tipos passam a incluir null de forma explícita, sem mudança para quem chama. --- src/Models/Customer.php | 4 ++-- src/Models/Invoice.php | 2 +- src/Models/Model.php | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Models/Customer.php b/src/Models/Customer.php index fc1babb..9d72dff 100644 --- a/src/Models/Customer.php +++ b/src/Models/Customer.php @@ -187,7 +187,7 @@ public function setDefaultCard(string $cardId): Customer * @throws \Potelo\MultiPayment\Exceptions\GatewayException * @throws \Potelo\MultiPayment\Exceptions\GatewayNotAvailableException */ - public function getCreditCard(string $creditCardId, GatewayContract|string $gateway = null): CreditCard + public function getCreditCard(string $creditCardId, GatewayContract|string|null $gateway = null): CreditCard { $gateway = ConfigurationHelper::resolveGateway($gateway); $creditCard = new CreditCard(); @@ -207,7 +207,7 @@ public function getCreditCard(string $creditCardId, GatewayContract|string $gate * @throws \Potelo\MultiPayment\Exceptions\GatewayException * @throws \Potelo\MultiPayment\Exceptions\GatewayNotAvailableException */ - public function deleteCreditCard(string $creditCardId, GatewayContract|string $gateway = null): void + public function deleteCreditCard(string $creditCardId, GatewayContract|string|null $gateway = null): void { $gateway = ConfigurationHelper::resolveGateway($gateway); $creditCard = new CreditCard(); diff --git a/src/Models/Invoice.php b/src/Models/Invoice.php index b9c3848..373331b 100644 --- a/src/Models/Invoice.php +++ b/src/Models/Invoice.php @@ -271,7 +271,7 @@ public function validateAutomaticPixAttribute(): void /** * @inheritDoc */ - public function save(GatewayContract|string $gateway = null, bool $validate = true): void + public function save(GatewayContract|string|null $gateway = null, bool $validate = true): void { if ($validate) { $this->validate(); diff --git a/src/Models/Model.php b/src/Models/Model.php index 36db79b..ca8906e 100644 --- a/src/Models/Model.php +++ b/src/Models/Model.php @@ -42,7 +42,7 @@ public function create(array $data, $gateway = null): void * @return void * @throws GatewayException|GatewayNotAvailableException|ModelAttributeValidationException|\Potelo\MultiPayment\Exceptions\ConfigurationException */ - public function save(GatewayContract|string $gateway = null, bool $validate = true): void + public function save(GatewayContract|string|null $gateway = null, bool $validate = true): void { $class = $this->getClassName(); if (property_exists($this, 'id') && !empty($this->id)) { @@ -161,7 +161,7 @@ protected static function getClassName(): string * @throws \Potelo\MultiPayment\Exceptions\ConfigurationException * @throws \Potelo\MultiPayment\Exceptions\GatewayException */ - public function get(GatewayContract|string $gateway = null): static + public function get(GatewayContract|string|null $gateway = null): static { $method = 'get' . static::getClassName(); $gateway = ConfigurationHelper::resolveGateway($gateway); @@ -179,7 +179,7 @@ public function get(GatewayContract|string $gateway = null): static * @throws \Potelo\MultiPayment\Exceptions\ConfigurationException * @throws \Potelo\MultiPayment\Exceptions\GatewayException */ - public function delete(GatewayContract|string $gateway = null): void + public function delete(GatewayContract|string|null $gateway = null): void { $method = 'delete' . static::getClassName(); $gateway = ConfigurationHelper::resolveGateway($gateway); @@ -192,7 +192,7 @@ public function delete(GatewayContract|string $gateway = null): void /** * Refresh the model instance with the latest data from the gateway. */ - public function refresh(GatewayContract|string $gateway = null): static + public function refresh(GatewayContract|string|null $gateway = null): static { $gateway = ConfigurationHelper::resolveGateway($gateway); return $this->get($gateway);