From 7bfde7c57fd1518d7eb8854ff9e15903f9cc133e Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 2 Jul 2026 10:48:10 -0600 Subject: [PATCH 1/3] fix: uppercase http methods to remove guzzle deprecation --- CHANGELOG.md | 4 +++ composer.json | 2 +- lib/EasyPost/Constant/Constants.php | 2 +- lib/EasyPost/EasyPostObject.php | 6 ++-- lib/EasyPost/Http/HttpMethod.php | 12 +++++++ lib/EasyPost/Http/Requestor.php | 15 +++++--- lib/EasyPost/Service/AddressService.php | 10 ++++-- lib/EasyPost/Service/ApiKeyService.php | 7 ++-- lib/EasyPost/Service/BaseService.php | 13 +++---- lib/EasyPost/Service/BatchService.php | 11 +++--- lib/EasyPost/Service/BetaRateService.php | 3 +- .../Service/BetaReferralCustomerService.php | 35 ++++++++++++++++--- lib/EasyPost/Service/BillingService.php | 12 ++++--- .../Service/CarrierAccountService.php | 5 +-- .../Service/CarrierMetadataService.php | 3 +- lib/EasyPost/Service/ClaimService.php | 3 +- .../Service/CustomerPortalService.php | 8 ++++- lib/EasyPost/Service/EmbeddableService.php | 3 +- lib/EasyPost/Service/EndShipperService.php | 3 +- lib/EasyPost/Service/EventService.php | 5 +-- .../Service/FedExRegistrationService.php | 9 ++--- lib/EasyPost/Service/InsuranceService.php | 3 +- lib/EasyPost/Service/LumaService.php | 3 +- lib/EasyPost/Service/OrderService.php | 5 +-- lib/EasyPost/Service/PickupService.php | 5 +-- .../Service/ReferralCustomerService.php | 13 +++---- lib/EasyPost/Service/ReportService.php | 7 ++-- lib/EasyPost/Service/ShipmentService.php | 23 ++++++------ lib/EasyPost/Service/SmartRateService.php | 5 +-- lib/EasyPost/Service/TrackerService.php | 3 +- lib/EasyPost/Service/UserService.php | 5 +-- phpunit.xml.dist | 23 ++++++------ test/EasyPost/HookTest.php | 6 ++-- test/EasyPost/Mocking/MockingUtility.php | 7 ++-- 34 files changed, 183 insertions(+), 96 deletions(-) create mode 100644 lib/EasyPost/Http/HttpMethod.php diff --git a/CHANGELOG.md b/CHANGELOG.md index c5dda903..412b8f2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## v8.8.1 (2026-07-02) + +Uppercases all HTTP methods to correct a new Guzzle deprecation + ## v8.8.0 (2026-06-25) - Adds `params` to `requestPin` ensuring users can pass `easypost_details` to the call. diff --git a/composer.json b/composer.json index 352bfd89..8f4c9378 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "easypost/easypost-php", "description": "EasyPost Shipping API Client Library for PHP", - "version": "8.8.0", + "version": "8.8.1", "keywords": [ "shipping", "api", diff --git a/lib/EasyPost/Constant/Constants.php b/lib/EasyPost/Constant/Constants.php index bad59171..9de5e6ef 100644 --- a/lib/EasyPost/Constant/Constants.php +++ b/lib/EasyPost/Constant/Constants.php @@ -11,7 +11,7 @@ abstract class Constants const BETA_API_VERSION = 'beta'; // Library constants - const LIBRARY_VERSION = '8.8.0'; + const LIBRARY_VERSION = '8.8.1'; const SUPPORT_EMAIL = 'support@easypost.com'; // Validation diff --git a/lib/EasyPost/EasyPostObject.php b/lib/EasyPost/EasyPostObject.php index 08dfed43..2d63550c 100644 --- a/lib/EasyPost/EasyPostObject.php +++ b/lib/EasyPost/EasyPostObject.php @@ -54,7 +54,8 @@ public function __set(string $k, mixed $v): void // @phpstan-ignore-next-line while (true && $i < 99) { if (!is_null($current->_parent)) { - $param = [$current->_name => $param]; + $name = $current->_name; + $param = [is_null($name) ? '' : $name => $param]; $current = $current->_parent; } $i++; @@ -90,7 +91,8 @@ public function __unset(string $k): void // @phpstan-ignore-next-line while (true && $i < 99) { if (!is_null($current->_parent)) { - $param = [$current->_name => $param]; + $name = $current->_name; + $param = [is_null($name) ? '' : $name => $param]; $current = $current->_parent; } $i++; diff --git a/lib/EasyPost/Http/HttpMethod.php b/lib/EasyPost/Http/HttpMethod.php new file mode 100644 index 00000000..3e4c9868 --- /dev/null +++ b/lib/EasyPost/Http/HttpMethod.php @@ -0,0 +1,12 @@ +value; + } else { + $method = strtoupper($method); + } $absoluteUrl = self::absoluteUrl($client, $url, $beta); $requestOptions = [ 'http_errors' => false, // we set this false here so we can do our own error handling 'timeout' => $client->getTimeout(), ]; - if (in_array(strtolower($method), ['get', 'delete'])) { + if (in_array($method, [HttpMethod::GET->value, HttpMethod::DELETE->value])) { $requestOptions['query'] = $params; } else { $params = self::encodeObjects($params); diff --git a/lib/EasyPost/Service/AddressService.php b/lib/EasyPost/Service/AddressService.php index 74969d59..90f16f8d 100644 --- a/lib/EasyPost/Service/AddressService.php +++ b/lib/EasyPost/Service/AddressService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -96,7 +97,12 @@ public function createAndVerify(mixed $params = null): mixed $wrappedParams['address'] = $params; $url = self::classUrl(self::serviceModelClassName(self::class)); - $response = Requestor::request($this->client, 'post', $url . '/create_and_verify', $wrappedParams); + $response = Requestor::request( + $this->client, + HttpMethod::POST, + $url . '/create_and_verify', + $wrappedParams + ); return InternalUtil::convertToEasyPostObject($this->client, $response['address']); } @@ -110,7 +116,7 @@ public function createAndVerify(mixed $params = null): mixed public function verify(string $id): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/verify'; - $response = Requestor::request($this->client, 'get', $url, null); + $response = Requestor::request($this->client, HttpMethod::GET, $url, null); return InternalUtil::convertToEasyPostObject($this->client, $response['address']); } diff --git a/lib/EasyPost/Service/ApiKeyService.php b/lib/EasyPost/Service/ApiKeyService.php index c755e305..a687f030 100644 --- a/lib/EasyPost/Service/ApiKeyService.php +++ b/lib/EasyPost/Service/ApiKeyService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Constant\Constants; use EasyPost\Exception\General\FilteringException; use EasyPost\Http\Requestor; @@ -45,7 +46,7 @@ public function retrieveApiKeysForUser(string $id): mixed */ public function all(): mixed { - $response = Requestor::request($this->client, 'get', '/api_keys'); + $response = Requestor::request($this->client, HttpMethod::GET, '/api_keys'); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -82,7 +83,7 @@ public function delete(string $id): void */ public function enable(string $id): mixed { - $response = Requestor::request($this->client, 'post', "/api_keys/{$id}/enable"); + $response = Requestor::request($this->client, HttpMethod::POST, "/api_keys/{$id}/enable"); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -95,7 +96,7 @@ public function enable(string $id): mixed */ public function disable(string $id): mixed { - $response = Requestor::request($this->client, 'post', "/api_keys/{$id}/disable"); + $response = Requestor::request($this->client, HttpMethod::POST, "/api_keys/{$id}/disable"); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/BaseService.php b/lib/EasyPost/Service/BaseService.php index af60a958..eace7b91 100644 --- a/lib/EasyPost/Service/BaseService.php +++ b/lib/EasyPost/Service/BaseService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Constant\Constants; use EasyPost\EasyPostClient; use EasyPost\Exception\General\EndOfPaginationException; @@ -118,7 +119,7 @@ protected function retrieveResource(string $class, string $id, bool $beta = fals { $url = $this->instanceUrl($class, $id); - $response = Requestor::request($this->client, 'get', $url, null, $beta); + $response = Requestor::request($this->client, HttpMethod::GET, $url, null, $beta); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -135,7 +136,7 @@ protected function allResources(string $class, mixed $params = null, bool $beta { self::validate($params); $url = self::classUrl($class); - $response = Requestor::request($this->client, 'get', $url, $params, $beta); + $response = Requestor::request($this->client, HttpMethod::GET, $url, $params, $beta); if (isset($params)) { $response['_params'] = $params; } @@ -196,7 +197,7 @@ protected function createResource(string $class, mixed $params = null, bool $bet { self::validate($params); $url = self::classUrl($class); - $response = Requestor::request($this->client, 'post', $url, $params, $beta); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params, $beta); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -215,7 +216,7 @@ protected function deleteResource(string $class, string $id, mixed $params = nul self::validate(); $url = $this->instanceUrl($class, $id); - Requestor::request($this->client, 'delete', $url, $params, $beta); + Requestor::request($this->client, HttpMethod::DELETE, $url, $params, $beta); } /** @@ -224,7 +225,7 @@ protected function deleteResource(string $class, string $id, mixed $params = nul * @param string $class * @param string $id * @param mixed $params - * @param string $method + * @param HttpMethod|string $method * @param bool $beta * @return mixed */ @@ -232,7 +233,7 @@ protected function updateResource( string $class, string $id, mixed $params = null, - string $method = 'patch', + HttpMethod|string $method = HttpMethod::PATCH, bool $beta = false ): mixed { self::validate(); diff --git a/lib/EasyPost/Service/BatchService.php b/lib/EasyPost/Service/BatchService.php index 62f0edbc..e923d16f 100644 --- a/lib/EasyPost/Service/BatchService.php +++ b/lib/EasyPost/Service/BatchService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -55,7 +56,7 @@ public function create(mixed $params = null): mixed public function buy(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/buy'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -70,7 +71,7 @@ public function buy(string $id, mixed $params = null): mixed public function label(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/label'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -85,7 +86,7 @@ public function label(string $id, mixed $params = null): mixed public function removeShipments(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/remove_shipments'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -100,7 +101,7 @@ public function removeShipments(string $id, mixed $params = null): mixed public function addShipments(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/add_shipments'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -115,7 +116,7 @@ public function addShipments(string $id, mixed $params = null): mixed public function createScanForm(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/scan_form'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/BetaRateService.php b/lib/EasyPost/Service/BetaRateService.php index d33ed69b..0cc0df7e 100644 --- a/lib/EasyPost/Service/BetaRateService.php +++ b/lib/EasyPost/Service/BetaRateService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -22,7 +23,7 @@ public function retrieveStatelessRates(mixed $params): mixed 'shipment' => $params, ]; - $response = Requestor::request($this->client, 'post', '/rates', $wrappedParams, true); + $response = Requestor::request($this->client, HttpMethod::POST, '/rates', $wrappedParams, true); return InternalUtil::convertToEasyPostObject($this->client, $response['rates']); } diff --git a/lib/EasyPost/Service/BetaReferralCustomerService.php b/lib/EasyPost/Service/BetaReferralCustomerService.php index 5fb9a195..39922e7c 100644 --- a/lib/EasyPost/Service/BetaReferralCustomerService.php +++ b/lib/EasyPost/Service/BetaReferralCustomerService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -36,7 +37,13 @@ public function addPaymentMethod( ] ]; - $response = Requestor::request($this->client, 'post', '/referral_customers/payment_method', $params, true); + $response = Requestor::request( + $this->client, + HttpMethod::POST, + '/referral_customers/payment_method', + $params, + true + ); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -51,7 +58,13 @@ public function refundByAmount(int $refundAmount): mixed { $params = ['refund_amount' => $refundAmount]; - $response = Requestor::request($this->client, 'post', '/referral_customers/refunds', $params, true); + $response = Requestor::request( + $this->client, + HttpMethod::POST, + '/referral_customers/refunds', + $params, + true + ); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -66,7 +79,13 @@ public function refundByPaymentLog(string $paymentLogId): mixed { $params = ['payment_log_id' => $paymentLogId]; - $response = Requestor::request($this->client, 'post', '/referral_customers/refunds', $params, true); + $response = Requestor::request( + $this->client, + HttpMethod::POST, + '/referral_customers/refunds', + $params, + true + ); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -78,7 +97,7 @@ public function refundByPaymentLog(string $paymentLogId): mixed */ public function createCreditCardClientSecret(): mixed { - $response = Requestor::request($this->client, 'post', '/setup_intents', null, true); + $response = Requestor::request($this->client, HttpMethod::POST, '/setup_intents', null, true); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -92,7 +111,13 @@ public function createCreditCardClientSecret(): mixed public function createBankAccountClientSecret(?string $returnUrl = null): mixed { $params = $returnUrl ? ['return_url' => $returnUrl] : null; - $response = Requestor::request($this->client, 'post', '/financial_connections_sessions', $params, true); + $response = Requestor::request( + $this->client, + HttpMethod::POST, + '/financial_connections_sessions', + $params, + true + ); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/BillingService.php b/lib/EasyPost/Service/BillingService.php index 0cdab4f2..f74d9cc7 100644 --- a/lib/EasyPost/Service/BillingService.php +++ b/lib/EasyPost/Service/BillingService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Constant\Constants; use EasyPost\Exception\Api\PaymentException; use EasyPost\Http\Requestor; @@ -47,7 +48,7 @@ public function fundWallet(string $amount, string $priority = 'primary'): void $url = $paymentMethodEndpoint . "/$paymentMethodId/charges"; $wrappedParams = ['amount' => $amount]; - Requestor::request($this->client, 'post', $url, $wrappedParams); + Requestor::request($this->client, HttpMethod::POST, $url, $wrappedParams); } /** @@ -61,7 +62,7 @@ public function deletePaymentMethod(string $priority): void [$paymentMethodEndpoint, $paymentMethodId] = self::getPaymentInfo(strtolower($priority)); $url = $paymentMethodEndpoint . "/$paymentMethodId"; - Requestor::request($this->client, 'delete', $url); + Requestor::request($this->client, HttpMethod::DELETE, $url); } /** @@ -79,10 +80,11 @@ private function getPaymentInfo(string $priority = 'primary'): array 'secondary' => 'secondary_payment_method' ]; $paymentMethodToUse = $paymentMethodMap[$priority] ?? null; + $selectedPaymentMethod = $paymentMethodToUse ? ($paymentMethods->$paymentMethodToUse ?? null) : null; - if ($paymentMethodToUse != null && $paymentMethods->$paymentMethodToUse->id != null) { - $paymentMethodId = $paymentMethods->$paymentMethodToUse->id; - $paymentMethodObjectType = $paymentMethods->$paymentMethodToUse->object; + if ($selectedPaymentMethod != null && $selectedPaymentMethod->id != null) { + $paymentMethodId = $selectedPaymentMethod->id; + $paymentMethodObjectType = $selectedPaymentMethod->object; if ($paymentMethodObjectType == 'CreditCard') { $endpoint = '/credit_cards'; } else if ($paymentMethodObjectType == 'BankAccount') { diff --git a/lib/EasyPost/Service/CarrierAccountService.php b/lib/EasyPost/Service/CarrierAccountService.php index efed6346..cf051fa8 100644 --- a/lib/EasyPost/Service/CarrierAccountService.php +++ b/lib/EasyPost/Service/CarrierAccountService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Constant\Constants; use EasyPost\Exception\General\MissingParameterException; use EasyPost\Http\Requestor; @@ -76,7 +77,7 @@ public function create(mixed $params = null): mixed $carrierAccountType = $params['type']; $params = [self::selectTopLayerKey($carrierAccountType) => $params]; $url = self::selectCarrierAccountCreationEndpoint($carrierAccountType); - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -89,7 +90,7 @@ public function create(mixed $params = null): mixed */ public function types(mixed $params = null): mixed { - $response = Requestor::request($this->client, 'get', '/carrier_types', $params); + $response = Requestor::request($this->client, HttpMethod::GET, '/carrier_types', $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/CarrierMetadataService.php b/lib/EasyPost/Service/CarrierMetadataService.php index b2725db4..7fb85d62 100644 --- a/lib/EasyPost/Service/CarrierMetadataService.php +++ b/lib/EasyPost/Service/CarrierMetadataService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -33,7 +34,7 @@ public function retrieve(?array $carriers = null, ?array $types = null): mixed $url = "{$url}types=" . join(',', $types); } - $response = Requestor::request($this->client, 'get', $url, null); + $response = Requestor::request($this->client, HttpMethod::GET, $url, null); return InternalUtil::convertToEasyPostObject($this->client, $response['carriers'] ?? []); } diff --git a/lib/EasyPost/Service/ClaimService.php b/lib/EasyPost/Service/ClaimService.php index bf274ec4..412b57f1 100644 --- a/lib/EasyPost/Service/ClaimService.php +++ b/lib/EasyPost/Service/ClaimService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -63,7 +64,7 @@ public function getNextPage(mixed $claims, ?int $pageSize = null): mixed */ public function cancel(string $id): mixed { - $response = Requestor::request($this->client, 'post', "/claims/{$id}/cancel"); + $response = Requestor::request($this->client, HttpMethod::POST, "/claims/{$id}/cancel"); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/CustomerPortalService.php b/lib/EasyPost/Service/CustomerPortalService.php index ea8a5d44..5c3de604 100644 --- a/lib/EasyPost/Service/CustomerPortalService.php +++ b/lib/EasyPost/Service/CustomerPortalService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -18,7 +19,12 @@ class CustomerPortalService extends BaseService */ public function createAccountLink(mixed $params = null): mixed { - $response = Requestor::request($this->client, 'post', '/customer_portal/account_link', $params); + $response = Requestor::request( + $this->client, + HttpMethod::POST, + '/customer_portal/account_link', + $params + ); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/EmbeddableService.php b/lib/EasyPost/Service/EmbeddableService.php index de508d83..a404c2aa 100644 --- a/lib/EasyPost/Service/EmbeddableService.php +++ b/lib/EasyPost/Service/EmbeddableService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -18,7 +19,7 @@ class EmbeddableService extends BaseService */ public function createSession(mixed $params = null): mixed { - $response = Requestor::request($this->client, 'post', '/embeddables/session', $params); + $response = Requestor::request($this->client, HttpMethod::POST, '/embeddables/session', $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/EndShipperService.php b/lib/EasyPost/Service/EndShipperService.php index b47e0d19..f82e2ef6 100644 --- a/lib/EasyPost/Service/EndShipperService.php +++ b/lib/EasyPost/Service/EndShipperService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Util\InternalUtil; /** @@ -55,6 +56,6 @@ public function update(string $id, mixed $params): mixed { $params = InternalUtil::wrapParams($params, 'address'); - return self::updateResource(self::serviceModelClassName(self::class), $id, $params, 'put'); + return self::updateResource(self::serviceModelClassName(self::class), $id, $params, HttpMethod::PUT); } } diff --git a/lib/EasyPost/Service/EventService.php b/lib/EasyPost/Service/EventService.php index c7526374..5f03fccc 100644 --- a/lib/EasyPost/Service/EventService.php +++ b/lib/EasyPost/Service/EventService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -54,7 +55,7 @@ public function retrieveAllPayloads(string $id): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/payloads'; - $response = Requestor::request($this->client, 'get', $url); + $response = Requestor::request($this->client, HttpMethod::GET, $url); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -70,7 +71,7 @@ public function retrievePayload(string $id, string $payloadId): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/payloads/' . $payloadId; - $response = Requestor::request($this->client, 'get', $url); + $response = Requestor::request($this->client, HttpMethod::GET, $url); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/FedExRegistrationService.php b/lib/EasyPost/Service/FedExRegistrationService.php index 6843494c..ef26717c 100644 --- a/lib/EasyPost/Service/FedExRegistrationService.php +++ b/lib/EasyPost/Service/FedExRegistrationService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -23,7 +24,7 @@ public function registerAddress(string $fedexAccountNumber, mixed $params = null $wrappedParams = $this->wrapAddressValidation($params); $url = "/fedex_registrations/{$fedexAccountNumber}/address"; - $response = Requestor::request($this->client, 'post', $url, $wrappedParams); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $wrappedParams); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -44,7 +45,7 @@ public function requestPin(string $fedexAccountNumber, string $pinMethodOption, ]; $url = "/fedex_registrations/{$fedexAccountNumber}/pin"; - $response = Requestor::request($this->client, 'post', $url, $wrappedParams); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $wrappedParams); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -61,7 +62,7 @@ public function validatePin(string $fedexAccountNumber, mixed $params = null): m $wrappedParams = $this->wrapPinValidation($params); $url = "/fedex_registrations/{$fedexAccountNumber}/pin/validate"; - $response = Requestor::request($this->client, 'post', $url, $wrappedParams); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $wrappedParams); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -78,7 +79,7 @@ public function submitInvoice(string $fedexAccountNumber, mixed $params = null): $wrappedParams = $this->wrapInvoiceValidation($params); $url = "/fedex_registrations/{$fedexAccountNumber}/invoice"; - $response = Requestor::request($this->client, 'post', $url, $wrappedParams); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $wrappedParams); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/InsuranceService.php b/lib/EasyPost/Service/InsuranceService.php index 555e8319..7dcb3539 100644 --- a/lib/EasyPost/Service/InsuranceService.php +++ b/lib/EasyPost/Service/InsuranceService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -65,7 +66,7 @@ public function create(mixed $params = null): mixed */ public function refund(string $id): mixed { - $response = Requestor::request($this->client, 'post', "/insurances/{$id}/refund"); + $response = Requestor::request($this->client, HttpMethod::POST, "/insurances/{$id}/refund"); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/LumaService.php b/lib/EasyPost/Service/LumaService.php index 0e12fa0c..05c25d40 100644 --- a/lib/EasyPost/Service/LumaService.php +++ b/lib/EasyPost/Service/LumaService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -21,7 +22,7 @@ public function getPromise(array $params): mixed $params = InternalUtil::wrapParams($params, 'shipment'); $url = '/luma/promise'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response['luma_info']); } diff --git a/lib/EasyPost/Service/OrderService.php b/lib/EasyPost/Service/OrderService.php index fb6d92a8..a6ffef93 100644 --- a/lib/EasyPost/Service/OrderService.php +++ b/lib/EasyPost/Service/OrderService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Rate; use EasyPost\Util\InternalUtil; @@ -45,7 +46,7 @@ public function create(mixed $params = null): mixed public function getRates(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/rates'; - $response = Requestor::request($this->client, 'get', $url, $params); + $response = Requestor::request($this->client, HttpMethod::GET, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -68,7 +69,7 @@ public function buy(string $id, mixed $params = null): mixed } $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/buy'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/PickupService.php b/lib/EasyPost/Service/PickupService.php index 3c91315c..2c7773a2 100644 --- a/lib/EasyPost/Service/PickupService.php +++ b/lib/EasyPost/Service/PickupService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -67,7 +68,7 @@ public function create(mixed $params = null): mixed public function buy(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/buy'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -82,7 +83,7 @@ public function buy(string $id, mixed $params = null): mixed public function cancel(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/cancel'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/ReferralCustomerService.php b/lib/EasyPost/Service/ReferralCustomerService.php index 44be0954..9ff66f32 100644 --- a/lib/EasyPost/Service/ReferralCustomerService.php +++ b/lib/EasyPost/Service/ReferralCustomerService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Constant\Constants; use EasyPost\EasyPostClient; use EasyPost\Exception\Api\ExternalApiException; @@ -67,7 +68,7 @@ public function updateEmail(string $userId, string $email): void ] ]; - Requestor::request($this->client, 'put', "/referral_customers/{$userId}", $wrappedParams); + Requestor::request($this->client, HttpMethod::PUT, "/referral_customers/{$userId}", $wrappedParams); } /** @@ -136,7 +137,7 @@ public function addCreditCardFromStripe( ]; $client = new EasyPostClient($referralApiKey); - $response = Requestor::request($client, 'post', '/credit_cards', $params); + $response = Requestor::request($client, HttpMethod::POST, '/credit_cards', $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -165,7 +166,7 @@ public function addBankAccountFromStripe( ]; $client = new EasyPostClient($referralApiKey); - $response = Requestor::request($client, 'post', '/bank_accounts', $params); + $response = Requestor::request($client, HttpMethod::POST, '/bank_accounts', $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -177,7 +178,7 @@ public function addBankAccountFromStripe( */ private function retrieveEasypostStripeApiKey(): string { - $response = Requestor::request($this->client, 'get', '/partners/stripe_public_key'); + $response = Requestor::request($this->client, HttpMethod::GET, '/partners/stripe_public_key'); return $response['public_key'] ?? ''; } @@ -224,7 +225,7 @@ private function createStripeToken( $requestOptions['http_errors'] = false; try { - $response = $guzzleClient->request('POST', $url, $requestOptions); + $response = $guzzleClient->request(HttpMethod::POST->value, $url, $requestOptions); } catch (\GuzzleHttp\Exception\ConnectException $error) { throw new HttpException(sprintf(Constants::COMMUNICATION_ERROR, 'Stripe', $error->getMessage())); } @@ -264,7 +265,7 @@ private function createEasypostCreditCard( ]; $client = new EasyPostClient($referralApiKey); - $response = Requestor::request($client, 'post', '/credit_cards', $params); + $response = Requestor::request($client, HttpMethod::POST, '/credit_cards', $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/ReportService.php b/lib/EasyPost/Service/ReportService.php index 71c8fdd1..8093376a 100644 --- a/lib/EasyPost/Service/ReportService.php +++ b/lib/EasyPost/Service/ReportService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Constant\Constants; use EasyPost\Exception\General\EndOfPaginationException; use EasyPost\Exception\General\MissingParameterException; @@ -40,7 +41,7 @@ public function all(mixed $params = null): mixed self::validate($params); $url = self::reportUrl($type); unset($params['type']); - $response = Requestor::request($this->client, 'get', $url, $params); + $response = Requestor::request($this->client, HttpMethod::GET, $url, $params); $response['type'] = $type; return InternalUtil::convertToEasyPostObject($this->client, $response); @@ -73,7 +74,7 @@ public function getNextPage(mixed $reports, ?int $pageSize = null): mixed } $url = self::reportUrl($reportArray[0]->object); - $response = Requestor::request($this->client, 'get', $url, $params); + $response = Requestor::request($this->client, HttpMethod::GET, $url, $params); if (isset($userParams)) { $response['_params'] = $userParams; @@ -101,7 +102,7 @@ public function create(mixed $params = null): mixed $url = self::reportUrl($params['type']); self::validate($params); - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/ShipmentService.php b/lib/EasyPost/Service/ShipmentService.php index b1a4a595..ef2f3a26 100644 --- a/lib/EasyPost/Service/ShipmentService.php +++ b/lib/EasyPost/Service/ShipmentService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Rate; use EasyPost\Util\InternalUtil; @@ -69,7 +70,7 @@ public function create(mixed $params = null): mixed public function regenerateRates(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/rerate'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -83,7 +84,7 @@ public function regenerateRates(string $id, mixed $params = null): mixed public function getSmartRates(string $id): array { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/smartrate'; - $response = Requestor::request($this->client, 'get', $url); + $response = Requestor::request($this->client, HttpMethod::GET, $url); $result = isset($response['result']) ? $response['result'] : []; @@ -113,7 +114,7 @@ public function buy(string $id, mixed $params = null, string|bool $endShipperId $params['end_shipper_id'] = $endShipperId; } - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -128,7 +129,7 @@ public function buy(string $id, mixed $params = null, string|bool $endShipperId public function refund(string $id, mixed $params = null): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/refund'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -150,7 +151,7 @@ public function label(string $id, mixed $params = null): mixed } $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/label'; - $response = Requestor::request($this->client, 'get', $url, $params); + $response = Requestor::request($this->client, HttpMethod::GET, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -172,7 +173,7 @@ public function insure(string $id, mixed $params = null): mixed } $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/insure'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -192,7 +193,7 @@ public function generateForm(string $id, string $formType, mixed $formOptions = $params['form'] = $formOptions; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -229,7 +230,7 @@ public function retrieveEstimatedDeliveryDate(string $id, string $plannedShipDat ]; $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/smartrate/delivery_date'; - $response = Requestor::request($this->client, 'get', $url, $params); + $response = Requestor::request($this->client, HttpMethod::GET, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response['rates'] ?? []); } @@ -249,7 +250,7 @@ public function recommendShipDate(string $id, string $desiredDeliveryDate): mixe ]; $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/smartrate/precision_shipping'; - $response = Requestor::request($this->client, 'get', $url, $params); + $response = Requestor::request($this->client, HttpMethod::GET, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response['rates'] ?? []); } @@ -265,7 +266,7 @@ public function createAndBuyLuma(array $params): mixed $params = InternalUtil::wrapParams($params, 'shipment'); $url = self::classUrl(self::serviceModelClassName(self::class)) . '/luma'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -280,7 +281,7 @@ public function createAndBuyLuma(array $params): mixed public function buyLuma(string $id, array $params): mixed { $url = $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/luma'; - $response = Requestor::request($this->client, 'post', $url, $params); + $response = Requestor::request($this->client, HttpMethod::POST, $url, $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/SmartRateService.php b/lib/EasyPost/Service/SmartRateService.php index 8ee394a7..1818d002 100644 --- a/lib/EasyPost/Service/SmartRateService.php +++ b/lib/EasyPost/Service/SmartRateService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Exception\General\EndOfPaginationException; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -20,7 +21,7 @@ class SmartRateService extends BaseService */ public function recommendShipDate(mixed $params = null): mixed { - $response = Requestor::request($this->client, 'post', '/smartrate/deliver_on', $params); + $response = Requestor::request($this->client, HttpMethod::POST, '/smartrate/deliver_on', $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } @@ -34,7 +35,7 @@ public function recommendShipDate(mixed $params = null): mixed */ public function estimateDeliveryDate(mixed $params = null): mixed { - $response = Requestor::request($this->client, 'post', '/smartrate/deliver_by', $params); + $response = Requestor::request($this->client, HttpMethod::POST, '/smartrate/deliver_by', $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/TrackerService.php b/lib/EasyPost/Service/TrackerService.php index 052c9260..2032bc6a 100644 --- a/lib/EasyPost/Service/TrackerService.php +++ b/lib/EasyPost/Service/TrackerService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -74,7 +75,7 @@ public function create(mixed $params = null): mixed */ public function retrieveBatch(mixed $params = null): mixed { - $response = Requestor::request($this->client, 'post', '/trackers/batch', $params); + $response = Requestor::request($this->client, HttpMethod::POST, '/trackers/batch', $params); return InternalUtil::convertToEasyPostObject($this->client, $response); } diff --git a/lib/EasyPost/Service/UserService.php b/lib/EasyPost/Service/UserService.php index a3302ff0..21a622bf 100644 --- a/lib/EasyPost/Service/UserService.php +++ b/lib/EasyPost/Service/UserService.php @@ -2,6 +2,7 @@ namespace EasyPost\Service; +use EasyPost\Http\HttpMethod; use EasyPost\Exception\General\EndOfPaginationException; use EasyPost\Http\Requestor; use EasyPost\Util\InternalUtil; @@ -82,7 +83,7 @@ public function updateBrand(string $id, mixed $params = null): mixed { $response = Requestor::request( $this->client, - 'patch', + HttpMethod::PATCH, $this->instanceUrl(self::serviceModelClassName(self::class), $id) . '/brand', $params ); @@ -101,7 +102,7 @@ public function allChildren(mixed $params = null): mixed self::validate($params); $url = '/users/children'; - $response = Requestor::request($this->client, 'get', $url, $params); + $response = Requestor::request($this->client, HttpMethod::GET, $url, $params); if (isset($params)) { $response['_params'] = $params; } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 694e8a49..20431c80 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,14 +1,13 @@ - - - - ./test/EasyPost/ - - - - - - ./lib/EasyPost/ - - + + + + ./test/EasyPost/ + + + + + ./lib/EasyPost/ + + diff --git a/test/EasyPost/HookTest.php b/test/EasyPost/HookTest.php index cd6724b0..701d496f 100644 --- a/test/EasyPost/HookTest.php +++ b/test/EasyPost/HookTest.php @@ -34,7 +34,7 @@ public static function tearDownAfterClass(): void */ public function requestTest(array $args): void { - $this->assertEquals('post', $args['method']); + $this->assertEquals('POST', $args['method']); $this->assertEquals('https://api.easypost.com/v2/parcels', $args['path']); $this->assertArrayHasKey('parcel', $args['request_body']); $this->assertArrayHasKey('Authorization', $args['headers']); @@ -51,6 +51,7 @@ public function testRequestHooks(): void self::$client->subscribeToRequestHook([$this, 'requestTest']); self::$client->parcel->create(Fixture::basicParcel()); + self::$client->unsubscribeFromRequestHook([$this, 'requestTest']); } /** @@ -61,7 +62,7 @@ public function testRequestHooks(): void public function responseTest(array $args): void { $this->assertEquals(201, $args['http_status']); - $this->assertEquals('post', $args['method']); + $this->assertEquals('POST', $args['method']); $this->assertEquals('https://api.easypost.com/v2/parcels', $args['path']); $this->assertNotNull(json_decode($args['response_body'], true)['object']); $this->assertArrayHasKey('location', $args['headers']); @@ -78,6 +79,7 @@ public function testResponseHooks(): void self::$client->subscribeToResponseHook([$this, 'responseTest']); self::$client->parcel->create(Fixture::basicParcel()); + self::$client->unsubscribeFromResponseHook([$this, 'responseTest']); } /** diff --git a/test/EasyPost/Mocking/MockingUtility.php b/test/EasyPost/Mocking/MockingUtility.php index 133e812d..40cc6ef3 100644 --- a/test/EasyPost/Mocking/MockingUtility.php +++ b/test/EasyPost/Mocking/MockingUtility.php @@ -30,9 +30,12 @@ public function __construct(array $mockRequests) */ public function findMatchingMockRequest($method, $url): mixed { + $normalizedMethod = strtoupper($method); + foreach ($this->mockRequests as $mockRequest) { - $methodMatches = $mockRequest->matchRule->method === '' - || $mockRequest->matchRule->method === $method; + $matchRuleMethod = strtoupper($mockRequest->matchRule->method); + $methodMatches = $matchRuleMethod === '' + || $matchRuleMethod === $normalizedMethod; $urlMatches = $mockRequest->matchRule->urlRegexPattern == '' || preg_match($mockRequest->matchRule->urlRegexPattern, $url) >= 1; // limit to exactly one match? if ($methodMatches && $urlMatches) { From 1a71f6737268cad3a0121260cf1e5507bdf92258 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 2 Jul 2026 11:01:22 -0600 Subject: [PATCH 2/3] chore: clean up dead code --- lib/EasyPost/EasyPostClient.php | 12 ++++-------- lib/EasyPost/EasyPostObject.php | 30 ------------------------------ 2 files changed, 4 insertions(+), 38 deletions(-) diff --git a/lib/EasyPost/EasyPostClient.php b/lib/EasyPost/EasyPostClient.php index 2bbc94af..754b54aa 100644 --- a/lib/EasyPost/EasyPostClient.php +++ b/lib/EasyPost/EasyPostClient.php @@ -158,15 +158,11 @@ public function __get(string $serviceName) if (array_key_exists($serviceName, $serviceClassMap)) { return new $serviceClassMap[$serviceName]($this); - } else { - // TODO: checking for `_parent` is a hack and should be fixed when we revisit the - // (de)serialization of objects in this lib. - if ($serviceName != '_parent') { - throw new EasyPostException( - sprintf(Constants::UNDEFINED_PROPERTY_ERROR, 'EasyPostClient', $serviceName) - ); - } } + + throw new EasyPostException( + sprintf(Constants::UNDEFINED_PROPERTY_ERROR, 'EasyPostClient', $serviceName) + ); } /** diff --git a/lib/EasyPost/EasyPostObject.php b/lib/EasyPost/EasyPostObject.php index 2d63550c..27d5bc7c 100644 --- a/lib/EasyPost/EasyPostObject.php +++ b/lib/EasyPost/EasyPostObject.php @@ -45,21 +45,6 @@ public function __construct(mixed $parent = null, mixed $name = null) public function __set(string $k, mixed $v): void { $this->_values[$k] = $v; - - $i = 0; - $current = $this; - $param = [$k => $v]; - - // TODO: Rework this when we fix (de)serialization - // @phpstan-ignore-next-line - while (true && $i < 99) { - if (!is_null($current->_parent)) { - $name = $current->_name; - $param = [is_null($name) ? '' : $name => $param]; - $current = $current->_parent; - } - $i++; - } } /** @@ -82,21 +67,6 @@ public function __unset(string $k): void { if (!in_array($k, $this->_immutableValues)) { unset($this->_values[$k]); - - $i = 0; - $current = $this; - $param = [$k => null]; - - // TODO: Rework this when we fix (de)serialization - // @phpstan-ignore-next-line - while (true && $i < 99) { - if (!is_null($current->_parent)) { - $name = $current->_name; - $param = [is_null($name) ? '' : $name => $param]; - $current = $current->_parent; - } - $i++; - } } } From f7deeffef2fcaa506700960d16d68375f301bc36 Mon Sep 17 00:00:00 2001 From: Justintime50 <39606064+Justintime50@users.noreply.github.com> Date: Thu, 2 Jul 2026 11:02:02 -0600 Subject: [PATCH 3/3] docs: changelog entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 412b8f2f..7828ebe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## v8.8.1 (2026-07-02) -Uppercases all HTTP methods to correct a new Guzzle deprecation +- Uppercases all HTTP methods to correct a new Guzzle deprecation +- Removed dead code in `__set` and `__unset` of an `EasyPostObject` ## v8.8.0 (2026-06-25)