From fa12332ec91da684a2b6b3373c8119c12f8511e8 Mon Sep 17 00:00:00 2001 From: Philippe S Date: Sun, 17 May 2026 15:34:28 +0200 Subject: [PATCH] feat(deps): support PHP 8.5 - Bump default PHP version to 8.5 in Makefile, docker-compose, Dockerfile and CI matrices - Bump xdebug from 3.4.0 to 3.5.1 (PHP 8.5 support added in 3.5.x) - Generalize pspell installation: PECL for PHP 8.4+, bundled for 8.2/8.3 - Update PHPStan and Scrutinizer matrices to test against PHP 8.5 - Move --display-deprecations PHPUnit flag to PHP 8.5 (highest supported) - Fix two static analysis issues surfaced by newer PHPStan: - LanguageToolApiClient::getSupportedLanguages now types the API response explicitly so array_unique receives an array of strings - preg_replace() return annotation aligned with native behavior (array preserves keys, not list) Tested with PHPUnit suite on PHP 8.5.6 + Symfony 7 (prefer-stable) and PHP 8.2.31 (prefer-lowest): 94/94 tests pass, zero deprecations. --- .github/workflows/phpstan.yml | 2 +- .github/workflows/run-tests.yml | 4 ++-- .scrutinizer.yml | 2 +- Makefile | 4 ++-- docker-compose.yml | 4 ++-- docker/php/Dockerfile | 8 ++++---- .../LanguageTool/LanguageToolApiClient.php | 17 ++++++++--------- src/Utils/php-functions.php | 2 +- 8 files changed, 21 insertions(+), 22 deletions(-) diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index c7d6f2d..1f43c29 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php: [ "8.2", "8.4" ] + php: [ "8.2", "8.5" ] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a4c3e4b..98253eb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: include: - - php: "8.4" + - php: "8.5" stability: --prefer-stable - php: "8.2" stability: --prefer-lowest @@ -49,7 +49,7 @@ jobs: - name: Run tests run: | - export WITH_COVERAGE=$(if [[ ("${{ matrix.php }}" = "8.4") && ("${{ matrix.stability }}" = "--prefer-stable") ]]; then echo "true"; else echo "false"; fi) + export WITH_COVERAGE=$(if [[ ("${{ matrix.php }}" = "8.5") && ("${{ matrix.stability }}" = "--prefer-stable") ]]; then echo "true"; else echo "false"; fi) echo "WITH_COVERAGE=${WITH_COVERAGE}" >> $GITHUB_ENV make vendor make tests diff --git a/.scrutinizer.yml b/.scrutinizer.yml index b5802ce..8479ec8 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -3,7 +3,7 @@ build: analysis: environment: php: - version: 8.4 + version: 8.5 cache: disabled: false directories: diff --git a/Makefile b/Makefile index 7316c21..1c1f89e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ DOCKER_COMPOSE ?= docker compose EXEC_PHP = $(DOCKER_COMPOSE) run --rm php -PHP_VERSION ?= 8.4 +PHP_VERSION ?= 8.5 DEPS_STRATEGY ?= --prefer-stable COMPOSER = $(EXEC_PHP) composer WITH_COVERAGE ?= "FALSE" @@ -25,7 +25,7 @@ setup: build .PHONY: build kill setup -PHPUNIT_FLAGS = $(if $(filter 8.4,$(PHP_VERSION)),--display-deprecations,) \ +PHPUNIT_FLAGS = $(if $(filter 8.5,$(PHP_VERSION)),--display-deprecations,) \ $(if $(filter true,$(WITH_COVERAGE)),--coverage-clover clover.xml,) tests: ## Run all tests diff --git a/docker-compose.yml b/docker-compose.yml index 5fe6fe3..e7dd2c7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,10 +1,10 @@ services: php: - image: tigitz/phpspellchecker:${PHP_VERSION:-8.4} + image: tigitz/phpspellchecker:${PHP_VERSION:-8.5} build: context: docker/php args: - PHP_VERSION: ${PHP_VERSION:-8.4} + PHP_VERSION: ${PHP_VERSION:-8.5} volumes: - .:/usr/src/myapp - ./cache:/root/composer/cache diff --git a/docker/php/Dockerfile b/docker/php/Dockerfile index 90dd230..3ad71c8 100644 --- a/docker/php/Dockerfile +++ b/docker/php/Dockerfile @@ -28,14 +28,14 @@ RUN apt-get update \ libpspell-dev RUN pecl channel-update pecl.php.net && \ - pecl install xdebug-3.4.0 && \ + pecl install xdebug-3.5.1 && \ docker-php-ext-enable xdebug -RUN if [ "${PHP_VERSION}" = "8.4" ]; then \ - pecl install pspell; \ - else \ +RUN if [ "${PHP_VERSION}" = "8.2" ] || [ "${PHP_VERSION}" = "8.3" ]; then \ docker-php-ext-configure pspell && \ docker-php-ext-install pspell; \ + else \ + pecl install pspell; \ fi && \ docker-php-ext-enable pspell && \ rm -r /var/lib/apt/lists/* diff --git a/src/Spellchecker/LanguageTool/LanguageToolApiClient.php b/src/Spellchecker/LanguageTool/LanguageToolApiClient.php index 2da4fb5..601cbf5 100644 --- a/src/Spellchecker/LanguageTool/LanguageToolApiClient.php +++ b/src/Spellchecker/LanguageTool/LanguageToolApiClient.php @@ -55,15 +55,14 @@ public function spellCheck(string $text, array $languages, array $options): arra */ public function getSupportedLanguages(): array { - /** @var array */ - return array_values(array_unique(array_column( - $this->requestAPI( - '/v2/languages', - 'GET', - 'Accept: application/json' - ), - 'longCode' - ))); + /** @var array $languages */ + $languages = $this->requestAPI( + '/v2/languages', + 'GET', + 'Accept: application/json' + ); + + return array_values(array_unique(array_column($languages, 'longCode'))); } /** diff --git a/src/Utils/php-functions.php b/src/Utils/php-functions.php index d538f7a..c303102 100644 --- a/src/Utils/php-functions.php +++ b/src/Utils/php-functions.php @@ -59,7 +59,7 @@ function preg_match_all(string $pattern, string $subject, &$matches = [], int $f * * @param-out 0|positive-int $count * - * @return ($subject is array ? list : string) + * @return ($subject is array ? array : string) */ function preg_replace(array|string $pattern, array|string $replacement, array|string $subject, int $limit = -1, ?int &$count = null): array|string {