Skip to content

Commit a487fbf

Browse files
authored
feat(deps): support PHP to 8.4 and Symfony 5+ (#62)
- Upgrade minimum PHP version to 8.2 and Symfony framework to version 5+ - Upgrade PHPStan and PHPUnit - Remove Safe PHP library dependency due to maintenance issues and 8.4 deprecations - Implement custom safe PHP function wrappers for internal usage - Update testing strategy to use PHP 8.4 as default, while maintaining compatibility tests for minimum supported versions BREAKING CHANGE: Drops support for PHP 8.1
1 parent dfba2a6 commit a487fbf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+451
-269
lines changed

.github/workflows/php-cs-fixer.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ jobs:
1313
- name: Setup PHP
1414
uses: shivammathur/setup-php@v2
1515
with:
16-
php-version: 8.1
16+
php-version: 8.2
1717
coverage: none
18-
tools: php-cs-fixer:3.54.x, cs2pr
18+
tools: php-cs-fixer:3.67.x, cs2pr
1919

2020
- name: Restore PHP-CS-Fixer cache
2121
uses: actions/cache@v4

.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.1", "8.3" ]
19+
php: [ "8.2", "8.4" ]
2020
steps:
2121
- uses: actions/checkout@v4
2222

.github/workflows/run-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
php: ["8.1", "8.2", "8.3"]
11-
stability: [--prefer-lowest, --prefer-stable]
10+
include:
11+
- php: "8.4"
12+
stability: --prefer-stable
13+
- php: "8.2"
14+
stability: --prefer-lowest
1215
env:
1316
PHP_VERSION: ${{ matrix.php }}
1417
DEPS_STRATEGY: ${{ matrix.stability }}
@@ -46,7 +49,7 @@ jobs:
4649

4750
- name: Run tests
4851
run: |
49-
export WITH_COVERAGE=$(if [[ ("${{ matrix.php }}" = "8.3") && ("${{ matrix.stability }}" = "--prefer-stable") ]]; then echo "true"; else echo "false"; fi)
52+
export WITH_COVERAGE=$(if [[ ("${{ matrix.php }}" = "8.4") && ("${{ matrix.stability }}" = "--prefer-stable") ]]; then echo "true"; else echo "false"; fi)
5053
echo "WITH_COVERAGE=${WITH_COVERAGE}" >> $GITHUB_ENV
5154
make vendor
5255
make tests

.php-cs-fixer.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@
2424
'lowercase_cast' => true,
2525
'method_chaining_indentation' => true,
2626
'native_function_casing' => true,
27-
'native_function_invocation' => ['include' => ['@compiler_optimized']],
28-
'new_with_braces' => true,
27+
'native_function_invocation' => [
28+
'include' => ['@compiler_optimized'],
29+
'strict' => false
30+
],
31+
'new_with_parentheses' => true,
2932
'modernize_types_casting' => true,
3033
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
3134
'no_empty_statement' => true,

.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.1
6+
version: 8.4
77
cache:
88
disabled: false
99
directories:

Makefile

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
DOCKER_COMPOSE ?= docker compose
2-
EXEC_PHP = $(DOCKER_COMPOSE) run --rm -T php
3-
PHP_VERSION ?= 8.2
2+
EXEC_PHP = $(DOCKER_COMPOSE) run --rm php
3+
PHP_VERSION ?= 8.4
44
DEPS_STRATEGY ?= --prefer-stable
55
COMPOSER = $(EXEC_PHP) composer
66
WITH_COVERAGE ?= "FALSE"
77
EXAMPLES_DIR ?= "examples"
88

99
pull:
10-
@$(DOCKER_COMPOSE) pull languagetools jamspell php
10+
@$(DOCKER_COMPOSE) pull languagetools jamspell
1111

1212
build:
1313
$(DOCKER_COMPOSE) build --no-cache php
@@ -25,13 +25,16 @@ setup: build
2525

2626
.PHONY: build kill setup
2727

28+
PHPUNIT_FLAGS = $(if $(filter 8.4,$(PHP_VERSION)),--display-deprecations,) \
29+
$(if $(filter true,$(WITH_COVERAGE)),--coverage-clover clover.xml,)
30+
2831
tests: ## Run all tests
2932
tests:
30-
if [ $(WITH_COVERAGE) = true ]; then $(EXEC_PHP) vendor/bin/phpunit --coverage-clover clover.xml; else $(EXEC_PHP) vendor/bin/phpunit; fi
33+
$(EXEC_PHP) vendor/bin/phpunit $(PHPUNIT_FLAGS)
3134

3235
tests-dox: ## Run all tests in dox format
3336
tests-dox:
34-
if [ $(WITH_COVERAGE) = true ]; then $(EXEC_PHP) vendor/bin/phpunit --coverage-clover clover.xml --testdox; else $(EXEC_PHP) vendor/bin/phpunit --testdox; fi
37+
$(EXEC_PHP) vendor/bin/phpunit $(PHPUNIT_FLAGS) --testdox
3538

3639
# @TODO not optimized, it recreates a container for each example
3740
examples-test:
@@ -45,11 +48,11 @@ examples-test:
4548

4649
tu: ## Run unit tests
4750
tu: vendor
48-
$(EXEC_PHP) vendor/bin/phpunit --exclude-group integration
51+
$(EXEC_PHP) vendor/bin/phpunit --display-deprecations --exclude-group integration
4952

5053
ti: ## Run functional tests
5154
ti: vendor
52-
$(EXEC_PHP) vendor/bin/phpunit --group integration
55+
$(EXEC_PHP) vendor/bin/phpunit --display-deprecations --group integration
5356

5457
.PHONY: tests tests-dox examples-test tu ti
5558

@@ -59,12 +62,12 @@ vendor:
5962
PHP_CS_FIXER = docker-compose run --rm -T php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -vv --allow-risky=yes
6063

6164
phpcs:
62-
PHP_VERSION=8.1 $(EXEC_PHP) composer -d tools/php-cs-fixer update
63-
PHP_VERSION=8.1 $(PHP_CS_FIXER) --dry-run
65+
PHP_VERSION=8.2 $(EXEC_PHP) composer -d tools/php-cs-fixer update
66+
PHP_VERSION=8.2 $(PHP_CS_FIXER) --dry-run
6467

6568
phpcbf:
66-
PHP_VERSION=8.1 $(EXEC_PHP) composer -d tools/php-cs-fixer update
67-
PHP_VERSION=8.1 $(PHP_CS_FIXER)
69+
PHP_VERSION=8.2 $(EXEC_PHP) composer -d tools/php-cs-fixer update
70+
PHP_VERSION=8.2 $(PHP_CS_FIXER)
6871

6972
phpstan: vendor
7073
$(EXEC_PHP) vendor/bin/phpstan analyse src -c phpstan.neon -a vendor/autoload.php

composer.json

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "tigitz/php-spellchecker",
33
"type": "library",
4+
"version": "0.8.0",
45
"description": "Provides an easy way to spellcheck multiple text source by many spellcheckers, directly from PHP",
56
"keywords": [
67
"spelling",
@@ -21,28 +22,26 @@
2122
}
2223
],
2324
"require": {
24-
"php": "^8.1",
25+
"php": "^8.2",
2526
"nyholm/psr7": "^1.3",
2627
"psr/http-client": "^1.0",
27-
"symfony/process": "^4.4.30 | ^5.0 |^6.0 | ^7.0",
28-
"thecodingmachine/safe": "^1.0 | ^2.0",
28+
"symfony/process": "^6.4 | ^7",
2929
"webmozart/assert": "^1.11"
3030
},
3131
"require-dev": {
3232
"aptoma/twig-markdown": "^3.0",
3333
"cocur/slugify": "^3.2 || ^4.0",
3434
"erusev/parsedown": "^1.7",
3535
"erusev/parsedown-extra": "^0.8",
36-
"phpstan/phpstan": "^1.2.0",
37-
"phpstan/phpstan-strict-rules": "^1.1.0",
38-
"phpstan/phpstan-webmozart-assert": "^1.0.0",
39-
"phpstan/phpstan-phpunit": "^1.0.0",
40-
"phpunit/phpunit": "^9.5",
41-
"pixelrobin/php-feather": "^1.0",
42-
"symfony/filesystem": "^4.4 || ^5.0 || ^6.0",
43-
"symfony/finder": "^4.4 || ^5.0 || ^6.0",
44-
"symfony/http-client": "^5.0 || ^6.0",
45-
"thecodingmachine/phpstan-safe-rule": "^1.1"
36+
"phpstan/phpstan": "^2",
37+
"phpstan/phpstan-strict-rules": "^2",
38+
"phpstan/phpstan-webmozart-assert": "^2",
39+
"phpstan/phpstan-phpunit": "^2",
40+
"phpunit/phpunit": "^11.0",
41+
"pixelrobin/php-feather": "^2",
42+
"symfony/filesystem": "^5 |^6 | ^7",
43+
"symfony/finder": "^5 |^6 | ^7",
44+
"symfony/http-client": "^5 |^6 | ^7"
4645
},
4746
"suggest": {
4847
"symfony/http-client": "A PSR-18 Client implementation to use spellcheckers that relies on HTTP APIs"
@@ -51,7 +50,7 @@
5150
"psr-4": {
5251
"PhpSpellcheck\\": "src"
5352
},
54-
"files": [ "src/Text/functions.php" ]
53+
"files": [ "src/Text/functions.php" , "src/Utils/php-functions.php" ]
5554
},
5655
"autoload-dev": {
5756
"psr-4": {

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.1}
3+
image: tigitz/phpspellchecker:${PHP_VERSION:-8.4}
44
build:
55
context: docker/php
66
args:
7-
PHP_VERSION: ${PHP_VERSION:-8.1}
7+
PHP_VERSION: ${PHP_VERSION:-8.4}
88
volumes:
99
- .:/usr/src/myapp
1010
- ./cache:/root/composer/cache

docker/php/Dockerfile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@ RUN apt-get update \
2626
aspell-en \
2727
aspell-ru \
2828
libpspell-dev
29-
RUN set -eux; \
30-
case "$PHP_VERSION" in \
31-
8.1*) pecl install xdebug-3.1.1;; \
32-
*) pecl install xdebug-3.3.2;; \
33-
esac
34-
RUN docker-php-ext-configure pspell \
35-
&& docker-php-ext-enable xdebug \
36-
&& docker-php-ext-install pspell \
37-
&& docker-php-ext-install zip \
38-
&& rm -r /var/lib/apt/lists/*
29+
30+
RUN pecl channel-update pecl.php.net && \
31+
pecl install xdebug-3.4.0 && \
32+
docker-php-ext-enable xdebug
33+
34+
RUN if [ "${PHP_VERSION}" = "8.4" ]; then \
35+
pecl install pspell; \
36+
else \
37+
docker-php-ext-configure pspell && \
38+
docker-php-ext-install pspell; \
39+
fi && \
40+
docker-php-ext-enable pspell && \
41+
rm -r /var/lib/apt/lists/*
3942

4043
RUN cp /usr/share/hunspell/en_US.aff /usr/share/hunspell/en_US.aff.orig \
4144
&& cp /usr/share/hunspell/en_US.dic /usr/share/hunspell/en_US.dic.orig \

docs/generate-docs.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@
107107
}
108108

109109
// Generate index.html doc file from the readme while stripping some sections
110-
$readme = \Safe\file_get_contents(__DIR__.'/../README.md');
110+
$readme = \PhpSpellcheck\file_get_contents(__DIR__.'/../README.md');
111111

112-
$readme = \Safe\preg_replace('/(# Install[\s\S]+?)^# /m', '# ', $readme);
113-
$readme = \Safe\preg_replace('/(# Usage[\s\S]+?)^# /m', '# ', $readme);
114-
$readme = \Safe\preg_replace('/(# Testing[\s\S]+?)^# /m', '# ', $readme);
112+
$readme = \PhpSpellcheck\preg_replace('/(# Install[\s\S]+?)^# /m', '# ', $readme);
113+
$readme = \PhpSpellcheck\preg_replace('/(# Usage[\s\S]+?)^# /m', '# ', $readme);
114+
$readme = \PhpSpellcheck\preg_replace('/(# Testing[\s\S]+?)^# /m', '# ', $readme);
115115

116116
$fs->dumpFile(
117117
__DIR__.'/index.html',

0 commit comments

Comments
 (0)