From 386ee2e9ae242e14a562c30402ddd1e159785861 Mon Sep 17 00:00:00 2001 From: Aleksandr Nomokonov Date: Mon, 8 Jun 2026 18:28:54 +0700 Subject: [PATCH] chore: add PHP 8.5 support and modernize code style - Bump minimum PHP to 8.4 in composer.json (required for http_get_last_response_headers()) - Fix PHP 8.4+ implicitly-nullable parameter deprecations by adding explicit ?Type on nullable params (Clients, ProductListHelper) - Replace deprecated $http_response_header with http_get_last_response_headers() in MindboxStream - Switch phpcs ruleset from deprecated PSR2 to PSR12 and reformat codebase accordingly (phpcbf) - Update CI to a PHP 8.4/8.5 matrix; remove obsolete .travis.yml - Update docs to state PHP 8.4+ requirement Co-Authored-By: Claude Opus 4.8 --- .github/workflows/main.yml | 24 +++++++------- .gitignore | 2 +- .travis.yml | 32 ------------------- README.md | 2 +- composer.json | 2 +- docs/getting_started.md | 2 +- phpcs.xml.dist | 2 +- src/Clients/AbstractMindboxClient.php | 4 +-- src/Clients/MindboxClientFactory.php | 1 - src/Clients/MindboxClientV2.php | 3 +- src/Clients/MindboxClientV3.php | 3 +- src/DTO/DTO.php | 1 - src/DTO/DTOCollection.php | 1 - src/DTO/ResultDTO.php | 1 - src/DTO/V2/CustomFieldDTO.php | 1 - src/DTO/V2/IdentityDTO.php | 1 - src/DTO/V2/LineDTO.php | 1 - src/DTO/V2/OrderDTO.php | 1 - .../V2/Responses/LineResponseCollection.php | 1 - src/DTO/V2/Responses/LineResponseDTO.php | 1 - .../V2/Responses/OrderResponseCollection.php | 1 - src/DTO/V2/Responses/OrderResponseDTO.php | 1 - src/DTO/V3/AreaDTO.php | 1 - src/DTO/V3/CustomFieldDTO.php | 1 - src/DTO/V3/CustomerDTO.php | 1 - src/DTO/V3/CustomerIdentityDTO.php | 1 - src/DTO/V3/DiscountDTO.php | 1 - src/DTO/V3/IdentityDTO.php | 1 - src/DTO/V3/LineDTO.php | 1 - src/DTO/V3/OperationDTO.php | 1 - src/DTO/V3/OrderDTO.php | 1 - src/DTO/V3/PaymentDTO.php | 1 - src/DTO/V3/ProductDTO.php | 1 - src/DTO/V3/ProductIdentityDTO.php | 1 - src/DTO/V3/ProductListItemDTO.php | 1 - .../Requests/AddProductToListRequestDTO.php | 1 - src/DTO/V3/Requests/AreaRequestDTO.php | 1 - .../V3/Requests/CategoryRequestCollection.php | 1 - src/DTO/V3/Requests/CategoryRequestDTO.php | 1 - src/DTO/V3/Requests/CustomFieldRequestDTO.php | 1 - .../CustomerIdentityRequestCollection.php | 1 - .../Requests/CustomerIdentityRequestDTO.php | 1 - src/DTO/V3/Requests/CustomerRequestDTO.php | 4 +-- .../DiscountCardIdentityRequestDTO.php | 1 - .../V3/Requests/DiscountRequestCollection.php | 1 - src/DTO/V3/Requests/DiscountRequestDTO.php | 1 - src/DTO/V3/Requests/IdentityRequestDTO.php | 1 - src/DTO/V3/Requests/LineRequestCollection.php | 1 - src/DTO/V3/Requests/LineRequestDTO.php | 2 +- .../V3/Requests/MergeCustomersRequestDTO.php | 1 - src/DTO/V3/Requests/OrderCreateRequestDTO.php | 1 - src/DTO/V3/Requests/OrderRequestDTO.php | 5 +-- src/DTO/V3/Requests/OrderUpdateRequestDTO.php | 1 - src/DTO/V3/Requests/PageRequestDTO.php | 1 - src/DTO/V3/Requests/PreorderRequestDTO.php | 1 - .../V3/Requests/ProductIdentityRequestDTO.php | 1 - .../ProductListItemRequestCollection.php | 1 - .../V3/Requests/ProductListItemRequestDTO.php | 1 - src/DTO/V3/Requests/ProductRequestDTO.php | 4 +-- .../RemoveProductFromListRequestDTO.php | 1 - .../SetProductCountInListRequestDTO.php | 1 - .../V3/Requests/SetProductListRequestDTO.php | 1 - .../V3/Requests/SmsConfirmationRequestDTO.php | 1 - .../SubscriptionRequestCollection.php | 1 - .../V3/Requests/SubscriptionRequestDTO.php | 1 - .../Responses/ActionTemplateResponseDTO.php | 1 - .../AppliedDiscountResponseCollection.php | 1 - .../Responses/AppliedDiscountResponseDTO.php | 1 - .../AppliedPromotionResponseCollection.php | 1 - .../Responses/AppliedPromotionResponseDTO.php | 1 - src/DTO/V3/Responses/AreaResponseDTO.php | 1 - .../BalanceChangeKindResponseDTO.php | 1 - .../Responses/BalanceResponseCollection.php | 1 - src/DTO/V3/Responses/BalanceResponseDTO.php | 1 - .../V3/Responses/BalanceTypeResponseDTO.php | 1 - .../Responses/CategoryResponseCollection.php | 1 - src/DTO/V3/Responses/CategoryResponseDTO.php | 1 - .../ContentItemResponseCollection.php | 1 - .../V3/Responses/ContentItemResponseDTO.php | 1 - .../V3/Responses/CouponPoolResponseDTO.php | 1 - src/DTO/V3/Responses/CouponResponseDTO.php | 1 - .../V3/Responses/CreditCardResponseDTO.php | 1 - .../CustomerActionResponseCollection.php | 1 - .../Responses/CustomerActionResponseDTO.php | 1 - ...ustomerBalanceChangeResponseCollection.php | 1 - .../CustomerBalanceChangeResponseDTO.php | 1 - .../CustomerIdentityResponseCollection.php | 1 - .../Responses/CustomerIdentityResponseDTO.php | 1 - src/DTO/V3/Responses/CustomerResponseDTO.php | 4 +-- ...CustomerSegmentationResponseCollection.php | 1 - .../CustomerSegmentationResponseDTO.php | 1 - .../DiscountCardResponseCollection.php | 1 - .../V3/Responses/DiscountCardResponseDTO.php | 1 - .../DiscountCardStatusResponseDTO.php | 1 - .../Responses/DiscountCardTypeResponseDTO.php | 1 - .../DiscountInfoResponseCollection.php | 1 - .../V3/Responses/DiscountInfoResponseDTO.php | 1 - src/DTO/V3/Responses/GiftCardResponseDTO.php | 1 - .../Responses/GiftCardStatusResponseDTO.php | 1 - .../V3/Responses/IssuedCouponResponseDTO.php | 1 - .../V3/Responses/LineResponseCollection.php | 1 - src/DTO/V3/Responses/LineResponseDTO.php | 1 - .../V3/Responses/LineStatusResponseDTO.php | 1 - .../V3/Responses/OrderResponseCollection.php | 1 - src/DTO/V3/Responses/OrderResponseDTO.php | 1 - .../PaymentInfoResponseCollection.php | 1 - .../V3/Responses/PaymentInfoResponseDTO.php | 1 - .../Responses/PaymentResponseCollection.php | 1 - src/DTO/V3/Responses/PaymentResponseDTO.php | 1 - .../PlaceholderResponseCollection.php | 1 - .../V3/Responses/PlaceholderResponseDTO.php | 1 - .../Responses/PointOfContactResponseDTO.php | 1 - .../Responses/ProductIdentityResponseDTO.php | 1 - .../ProductListItemResponseCollection.php | 1 - .../Responses/ProductListItemResponseDTO.php | 1 - src/DTO/V3/Responses/ProductResponseDTO.php | 4 +-- .../V3/Responses/PromoActionResponseDTO.php | 1 - src/DTO/V3/Responses/PromotionResponseDTO.php | 1 - src/DTO/V3/Responses/SegmentResponseDTO.php | 1 - .../V3/Responses/SegmentationResponseDTO.php | 1 - .../Responses/SmsConfirmationResponseDTO.php | 1 - .../SubscriptionResponseCollection.php | 1 - .../V3/Responses/SubscriptionResponseDTO.php | 1 - .../ValidationMessageResponseCollection.php | 1 - .../ValidationMessageResponseDTO.php | 1 - src/DTO/V3/SubscriptionDTO.php | 1 - src/Exceptions/IMindboxException.php | 1 - src/Exceptions/MindboxBadRequestException.php | 1 - .../MindboxClientErrorException.php | 1 - src/Exceptions/MindboxClientException.php | 1 - src/Exceptions/MindboxConfigException.php | 1 - src/Exceptions/MindboxConflictException.php | 1 - src/Exceptions/MindboxException.php | 1 - src/Exceptions/MindboxForbiddenException.php | 1 - src/Exceptions/MindboxHttpClientException.php | 1 - src/Exceptions/MindboxNotFoundException.php | 1 - .../MindboxTooManyRequestsException.php | 1 - .../MindboxUnauthorizedException.php | 1 - .../MindboxUnavailableException.php | 1 - src/Helpers/ProductListHelper.php | 8 ++--- src/HttpClients/MindboxStream.php | 2 +- src/MindboxRequest.php | 1 - src/XMLHelper/MindboxXMLSerializer.php | 1 - tests/DTO/DTOTest.php | 2 +- 144 files changed, 38 insertions(+), 198 deletions(-) delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0efe21..2e21f33 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,24 +8,26 @@ name: Check code style and tests - master jobs: - build_8_0: + build: runs-on: ubuntu-latest + strategy: + matrix: + php_version: + - '8.4' + - '8.5' + steps: - - uses: actions/checkout@v2 - - uses: php-actions/composer@v6 - with: - php_version: 8.0 - version: 2 + - uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.0 + php-version: ${{ matrix.php_version }} - name: Update packages - run: sudo composer update + run: composer update --prefer-dist --no-interaction - name: PHP version run: php -v @@ -34,8 +36,4 @@ jobs: run: vendor/bin/phpcs - name: Run tests - uses: php-actions/phpunit@v3 - with: - version: 9 - php_version: 8.0 - + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index e30d2f2..8f81fdd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ vendor/ composer.lock src/Clients/getDeviceUUID -.idea \ No newline at end of file +.idea.phpunit.result.cache diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e6400e5..0000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Project language -language: php - -# List of PHP version we want to test -php: - - 7.3 - - 7.4 - - 8.0 - -# Allows use container-based infrastructure -sudo: false - -# Cache composer packages so "composer install" is faster -cache: - directories: - - $HOME/.composer/cache - -# Update composer -before_install: - - travis_retry composer self-update - -# Install composer dependencies -install: - - travis_retry composer install --prefer-dist --no-interaction - -before_script: - - export XDEBUG_MODE=coverage - -# Run scripts -script: - - vendor/bin/phpcs - - vendor/bin/phpunit diff --git a/README.md b/README.md index eef064c..87764b1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ PHP библиотека для упрощённого взаимодейтсв ### Зависимости -* PHP версии 7.3 или выше +* PHP версии 8.4 или выше * [psr/log](https://github.com/php-fig/log) * [ext-json](http://php.net/manual/ru/json.installation.php) * [ext-simplexml](http://php.net/manual/ru/simplexml.installation.php) diff --git a/composer.json b/composer.json index 6202ca7..c4d22b0 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "keywords": ["mindbox", "sdk"], "type": "library", "require": { - "php": ">=8.0", + "php": ">=8.4", "psr/log": "^1.1|^2|^3", "ext-json": "*", "ext-simplexml": "*", diff --git a/docs/getting_started.md b/docs/getting_started.md index 6920174..08e7eb0 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -6,7 +6,7 @@ ## Системные зависимости -* PHP версии 7.3 или выше +* PHP версии 8.4 или выше * [psr/log](https://github.com/php-fig/log) * [ext-json](http://php.net/manual/ru/json.installation.php) * [ext-simplexml](http://php.net/manual/ru/simplexml.installation.php) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 727c11f..723ef50 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -3,5 +3,5 @@ src/ tests/ - + \ No newline at end of file diff --git a/src/Clients/AbstractMindboxClient.php b/src/Clients/AbstractMindboxClient.php index 23a6b48..9c366a7 100644 --- a/src/Clients/AbstractMindboxClient.php +++ b/src/Clients/AbstractMindboxClient.php @@ -88,7 +88,7 @@ public function __construct($secretKey, IHttpClient $httpClient, LoggerInterface public function prepareRequest( $method, $operationName, - \Mindbox\DTO\DTO $body = null, + ?\Mindbox\DTO\DTO $body = null, $additionalUrl = '', $queryParams = [], $isSync = true, @@ -211,7 +211,7 @@ abstract protected function prepareAuthorizationHeader(); * * @return string */ - abstract protected function prepareBody(\Mindbox\DTO\DTO $body = null); + abstract protected function prepareBody(?\Mindbox\DTO\DTO $body = null); /** * Инициализация экземпляра запроса. diff --git a/src/Clients/MindboxClientFactory.php b/src/Clients/MindboxClientFactory.php index e87cf90..061e00d 100644 --- a/src/Clients/MindboxClientFactory.php +++ b/src/Clients/MindboxClientFactory.php @@ -1,6 +1,5 @@ toXML() : ''; } diff --git a/src/Clients/MindboxClientV3.php b/src/Clients/MindboxClientV3.php index ac55b0c..76272df 100644 --- a/src/Clients/MindboxClientV3.php +++ b/src/Clients/MindboxClientV3.php @@ -1,6 +1,5 @@ toJson() : ''; } diff --git a/src/DTO/DTO.php b/src/DTO/DTO.php index dfea20d..6fb3aa7 100644 --- a/src/DTO/DTO.php +++ b/src/DTO/DTO.php @@ -1,6 +1,5 @@ createOperation(); @@ -128,7 +128,7 @@ public function setProductList( public function setWishList( ProductListItemRequestCollection $products, $operationName, - CustomerIdentityRequestDTO $customerIdentity = null, + ?CustomerIdentityRequestDTO $customerIdentity = null, $addDeviceUUID = true ) { $operation = $this->createOperation(); @@ -154,7 +154,7 @@ public function setWishList( */ public function clearWishList( $operationName, - CustomerIdentityRequestDTO $customerIdentity = null, + ?CustomerIdentityRequestDTO $customerIdentity = null, $addDeviceUUID = true ) { $operation = $this->createOperation(); @@ -175,7 +175,7 @@ public function clearWishList( */ public function clearCart( $operationName, - CustomerIdentityRequestDTO $customerIdentity = null, + ?CustomerIdentityRequestDTO $customerIdentity = null, $addDeviceUUID = true ) { $operation = $this->createOperation(); diff --git a/src/HttpClients/MindboxStream.php b/src/HttpClients/MindboxStream.php index 7f92754..59c4d57 100644 --- a/src/HttpClients/MindboxStream.php +++ b/src/HttpClients/MindboxStream.php @@ -42,7 +42,7 @@ public function contextCreate($options) public function fileGetContents($url) { $rawBody = file_get_contents($url, false, $this->stream); - $rawHeaders = !empty($http_response_header) ? $http_response_header : []; + $rawHeaders = http_get_last_response_headers() ?? []; $this->setRawHeaders($rawHeaders); return trim((string)$rawBody); diff --git a/src/MindboxRequest.php b/src/MindboxRequest.php index 9710e4b..64d045f 100644 --- a/src/MindboxRequest.php +++ b/src/MindboxRequest.php @@ -1,6 +1,5 @@ dtoClassName)->getXmlName(); + return (new $this->dtoClassName())->getXmlName(); } /**