Skip to content

Commit 14a629d

Browse files
tigitzPhilippe S
andauthored
feat(deps): support PHP 8.5 (#67)
- 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<string> preserves keys, not list<string>) 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. Co-authored-by: Philippe S <philippe.segatori@wishgroupe.com>
1 parent 88e1d08 commit 14a629d

8 files changed

Lines changed: 21 additions & 22 deletions

File tree

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
php: [ "8.2", "8.4" ]
19+
php: [ "8.2", "8.5" ]
2020
steps:
2121
- uses: actions/checkout@v4
2222

.github/workflows/run-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
include:
11-
- php: "8.4"
11+
- php: "8.5"
1212
stability: --prefer-stable
1313
- php: "8.2"
1414
stability: --prefer-lowest
@@ -49,7 +49,7 @@ jobs:
4949

5050
- name: Run tests
5151
run: |
52-
export WITH_COVERAGE=$(if [[ ("${{ matrix.php }}" = "8.4") && ("${{ matrix.stability }}" = "--prefer-stable") ]]; then echo "true"; else echo "false"; fi)
52+
export WITH_COVERAGE=$(if [[ ("${{ matrix.php }}" = "8.5") && ("${{ matrix.stability }}" = "--prefer-stable") ]]; then echo "true"; else echo "false"; fi)
5353
echo "WITH_COVERAGE=${WITH_COVERAGE}" >> $GITHUB_ENV
5454
make vendor
5555
make tests

.scrutinizer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ build:
33
analysis:
44
environment:
55
php:
6-
version: 8.4
6+
version: 8.5
77
cache:
88
disabled: false
99
directories:

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
DOCKER_COMPOSE ?= docker compose
22
EXEC_PHP = $(DOCKER_COMPOSE) run --rm php
3-
PHP_VERSION ?= 8.4
3+
PHP_VERSION ?= 8.5
44
DEPS_STRATEGY ?= --prefer-stable
55
COMPOSER = $(EXEC_PHP) composer
66
WITH_COVERAGE ?= "FALSE"
@@ -25,7 +25,7 @@ setup: build
2525

2626
.PHONY: build kill setup
2727

28-
PHPUNIT_FLAGS = $(if $(filter 8.4,$(PHP_VERSION)),--display-deprecations,) \
28+
PHPUNIT_FLAGS = $(if $(filter 8.5,$(PHP_VERSION)),--display-deprecations,) \
2929
$(if $(filter true,$(WITH_COVERAGE)),--coverage-clover clover.xml,)
3030

3131
tests: ## Run all tests

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
services:
22
php:
3-
image: tigitz/phpspellchecker:${PHP_VERSION:-8.4}
3+
image: tigitz/phpspellchecker:${PHP_VERSION:-8.5}
44
build:
55
context: docker/php
66
args:
7-
PHP_VERSION: ${PHP_VERSION:-8.4}
7+
PHP_VERSION: ${PHP_VERSION:-8.5}
88
volumes:
99
- .:/usr/src/myapp
1010
- ./cache:/root/composer/cache

docker/php/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ RUN apt-get update \
2828
libpspell-dev
2929

3030
RUN pecl channel-update pecl.php.net && \
31-
pecl install xdebug-3.4.0 && \
31+
pecl install xdebug-3.5.1 && \
3232
docker-php-ext-enable xdebug
3333

34-
RUN if [ "${PHP_VERSION}" = "8.4" ]; then \
35-
pecl install pspell; \
36-
else \
34+
RUN if [ "${PHP_VERSION}" = "8.2" ] || [ "${PHP_VERSION}" = "8.3" ]; then \
3735
docker-php-ext-configure pspell && \
3836
docker-php-ext-install pspell; \
37+
else \
38+
pecl install pspell; \
3939
fi && \
4040
docker-php-ext-enable pspell && \
4141
rm -r /var/lib/apt/lists/*

src/Spellchecker/LanguageTool/LanguageToolApiClient.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ public function spellCheck(string $text, array $languages, array $options): arra
5555
*/
5656
public function getSupportedLanguages(): array
5757
{
58-
/** @var array<string> */
59-
return array_values(array_unique(array_column(
60-
$this->requestAPI(
61-
'/v2/languages',
62-
'GET',
63-
'Accept: application/json'
64-
),
65-
'longCode'
66-
)));
58+
/** @var array<array{longCode: string}> $languages */
59+
$languages = $this->requestAPI(
60+
'/v2/languages',
61+
'GET',
62+
'Accept: application/json'
63+
);
64+
65+
return array_values(array_unique(array_column($languages, 'longCode')));
6766
}
6867

6968
/**

src/Utils/php-functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function preg_match_all(string $pattern, string $subject, &$matches = [], int $f
5959
*
6060
* @param-out 0|positive-int $count
6161
*
62-
* @return ($subject is array ? list<string> : string)
62+
* @return ($subject is array ? array<string> : string)
6363
*/
6464
function preg_replace(array|string $pattern, array|string $replacement, array|string $subject, int $limit = -1, ?int &$count = null): array|string
6565
{

0 commit comments

Comments
 (0)