Skip to content

Commit

Permalink
Support PHP 8.3, dropped 7.4 and 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tigitz committed May 4, 2024
1 parent 6902688 commit 3b5343d
Show file tree
Hide file tree
Showing 24 changed files with 112 additions and 174 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.3
coverage: none
tools: php-cs-fixer, cs2pr
tools: php-cs-fixer:3.54.x, cs2pr

- name: Restore PHP-CS-Fixer cache
uses: actions/cache@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ "7.4", "8.2" ]
php: [ "8.1", "8.3" ]
steps:
- uses: actions/checkout@v2

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php: ["7.4", "8.0", "8.1", "8.2"]
php: ["8.1", "8.2", "8.3"]
stability: [--prefer-lowest, --prefer-stable]
env:
PHP_VERSION: ${{ matrix.php }}
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:

- name: Run tests
run: |
export WITH_COVERAGE=$(if [[ ("${{ matrix.php }}" = "8.2") && ("${{ matrix.stability }}" = "--prefer-stable") ]]; then echo "true"; else echo "false"; fi)
export WITH_COVERAGE=$(if [[ ("${{ matrix.php }}" = "8.3") && ("${{ matrix.stability }}" = "--prefer-stable") ]]; then echo "true"; else echo "false"; fi)
echo "WITH_COVERAGE=${WITH_COVERAGE}" >> $GITHUB_ENV
make vendor
make tests
Expand Down
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'@PHP81Migration' => true,
'no_unused_imports' => true,
'blank_line_before_statement' => true,
'cast_spaces' => true,
Expand Down
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ build:
analysis:
environment:
php:
version: 7.4
version: 8.1
cache:
disabled: false
directories:
Expand Down
15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,22 @@ ti: vendor

vendor:
$(COMPOSER) update $(DEPS_STRATEGY)
$(EXEC_PHP) composer -d tools/php-cs-fixer update

PHP_CS_FIXER = docker-compose run --rm -T php tools/php-cs-fixer/vendor/bin/php-cs-fixer fix -vv --allow-risky=yes

phpcs:
PHP_VERSION=7.4 docker-compose run --rm -T php composer require --working-dir=tools/php-cs-fixer friendsofphp/php-cs-fixer
PHP_VERSION=7.4 $(PHP_CS_FIXER) --dry-run
PHP_VERSION=8.1 docker-compose run --rm -T php composer require --working-dir=tools/php-cs-fixer friendsofphp/php-cs-fixer
PHP_VERSION=8.1 $(PHP_CS_FIXER) --dry-run

phpcbf:
PHP_VERSION=7.4 $(PHP_CS_FIXER)
PHP_VERSION=8.1 $(PHP_CS_FIXER)

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

phpstan-all-php-versions:
PHP_VERSION=7.4 make phpstan
PHP_VERSION=8.2 make phpstan
$(EXEC_PHP) vendor/bin/phpstan analyse src -c phpstan.neon -a vendor/autoload.php

phpstan-baseline: vendor
$(EXEC_PHP) vendor/bin/phpstan analyse src -c phpstan.$(PHP_VERSION).neon -a vendor/autoload.php --generate-baseline
$(EXEC_PHP) vendor/bin/phpstan analyse src -c phpstan.neon -a vendor/autoload.php --generate-baseline

infection: vendor
$(EXEC_PHP) vendor/bin/phpunit --coverage-xml=build/coverage/coverage-xml --log-junit=build/coverage/phpunit.junit.xml
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
],
"require": {
"php": "^7.4 | ^8.0",
"php": "^8.1",
"nyholm/psr7": "^1.3",
"psr/http-client": "^1.0",
"symfony/process": "^4.4.30 | ^5.0 |^6.0 | ^7.0",
Expand Down
6 changes: 3 additions & 3 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG PHP_VERSION

FROM php:${PHP_VERSION}-cli-buster
FROM php:${PHP_VERSION}-cli-bookworm

ENV XDEBUG_MODE=coverage
RUN echo "memory_limit=-1" > "$PHP_INI_DIR/conf.d/memory-limit.ini" \
Expand Down Expand Up @@ -28,8 +28,8 @@ RUN apt-get update \
libpspell-dev
RUN set -eux; \
case "$PHP_VERSION" in \
8.2*) pecl install xdebug-3.2.2;; \
*) pecl install xdebug-3.1.1;; \
8.1*) pecl install xdebug-3.1.1;; \
*) pecl install xdebug-3.3.2;; \
esac
RUN docker-php-ext-configure pspell \
&& docker-php-ext-enable xdebug \
Expand Down
8 changes: 4 additions & 4 deletions examples/markdown_remover_text_processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
);

$mdFormattedString = <<<MD
# Mispelling Heading
# Mispelling Heading
**mispelling bold**
**mispelling bold**
* mispelling list item
MD;
* mispelling list item
MD;

// using a string
$misspellingFinder->find($mdFormattedString, ['en_US']);
Expand Down
2 changes: 1 addition & 1 deletion examples/multisource_mispelling_finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
new \PhpSpellcheck\Source\MultiSource(
[
new \PhpSpellcheck\Source\File(__DIR__ . '/../tests/Fixtures/Text/mispelling1.txt'),
new \PhpSpellcheck\Source\Directory(__DIR__ . '/../tests/Fixtures/Text/Directory')
new \PhpSpellcheck\Source\Directory(__DIR__ . '/../tests/Fixtures/Text/Directory'),
]
),
['en_US'],
Expand Down
44 changes: 0 additions & 44 deletions phpstan.8.2.neon

This file was deleted.

19 changes: 0 additions & 19 deletions phpstan.base.neon

This file was deleted.

37 changes: 20 additions & 17 deletions phpstan.7.4.neon → phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
includes:
- phpstan.base.neon
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
- vendor/phpstan/phpstan-strict-rules/rules.neon
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon
- vendor/phpstan/phpstan-phpunit/extension.neon

parameters:
level: max
treatPhpDocTypesAsCertain: false

ignoreErrors:
# php 8.1 code
# Missing strict comparison
- '#^Construct empty\(\) is not allowed. Use more strict comparison.$#'

# function_exists call
-
message: "#^Class PhpSpellcheck\\\\t not found\\.$#"
count: 1
path: src/Text/functions.php

-
message: "#^Function pspell_config_create is unsafe to use\\. It can return FALSE instead of throwing an exception\\. Please add 'use function Safe\\\\pspell_config_create;' at the beginning of the file to use the variant provided by the 'thecodingmachine/safe' library\\.$#"
count: 1
Expand All @@ -25,32 +39,21 @@ parameters:
path: src/Spellchecker/PHPPspell.php

-
message: "#^Parameter \\#1 \\$conf of function pspell_config_ignore expects int, int\\|false given\\.$#"
count: 1
path: src/Spellchecker/PHPPspell.php

-
message: "#^Parameter \\#1 \\$conf of function pspell_config_mode expects int, int\\|false given\\.$#"
message: "#^Parameter \\#1 \\$dictionary of function pspell_check expects PSpell\\\\Dictionary, PSpell\\\\Dictionary\\|false given\\.$#"
count: 1
path: src/Spellchecker/PHPPspell.php

-
message: "#^Parameter \\#1 \\$config of function pspell_new_config expects int, int\\|false given\\.$#"
message: "#^Parameter \\#1 \\$dictionary of function pspell_check expects PSpell\\\\Dictionary, int given\\.$#"
count: 1
path: src/Spellchecker/PHPPspell.php

-
message: "#^Parameter \\#1 \\$pspell of function pspell_check expects int, int\\|false given\\.$#"
message: "#^Parameter \\#1 \\$dictionary of function pspell_suggest expects PSpell\\\\Dictionary, PSpell\\\\Dictionary\\|false given\\.$#"
count: 1
path: src/Spellchecker/PHPPspell.php

-
message: "#^Parameter \\#1 \\$pspell of function pspell_suggest expects int, int\\|false given\\.$#"
message: "#^Parameter \\#1 \\$dictionary of function pspell_suggest expects PSpell\\\\Dictionary, int given\\.$#"
count: 1
path: src/Spellchecker/PHPPspell.php

# preg_match_all can be null in php >8
-
message: "#^Casting to int something that's already int\\.$#"
count: 1
path: src/Utils/LineAndOffset.php
12 changes: 6 additions & 6 deletions src/Exception/ProcessHasErrorOutputException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class ProcessHasErrorOutputException extends \RuntimeException implements Except
public function __construct(string $errorOutput, string $parsedText, string $command)
{
$exceptionTemplateMessage = <<<'MSG'
Process has generated the following output errors:
Process has generated the following output errors:
%s
%s
With command: "%s"
With command: "%s"
For text:
"%s"
MSG;
For text:
"%s"
MSG;

parent::__construct(
\Safe\sprintf(
Expand Down
4 changes: 1 addition & 3 deletions src/MisspellingHandler/MisspellingHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ interface MisspellingHandlerInterface
{
/**
* @param MisspellingInterface[] $misspellings
*
* @return mixed|void
*/
public function handle(iterable $misspellings);
public function handle(iterable $misspellings): mixed;
}
12 changes: 6 additions & 6 deletions tests/Exception/ProcessHasErrorOutputExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ public function testException(): void
{
$exception = new ProcessHasErrorOutputException('error output', 'testt', 'ispell --encoding=utf-8 -a');
$this->assertSame(<<<MESSAGE
Process has generated the following output errors:
Process has generated the following output errors:
error output
error output
With command: "ispell --encoding=utf-8 -a"
With command: "ispell --encoding=utf-8 -a"
For text:
"testt"
MESSAGE
For text:
"testt"
MESSAGE
, $exception->getMessage());
}
}
10 changes: 6 additions & 4 deletions tests/Fixtures/Hunspell/check.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.7.0)
& Tigr 6 1: Ti gr, Ti-gr, Tiger, Trig, Tier, Tigris
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.7.1)
& Tigr 7 1: Tigre, Ti gr, Ti-gr, Tiger, Trig, Tier, Tigris
# страх 22

& theforests 6 4: the forests, the-forests, therefore, afforests, forests, forefathers

& imortal 4 6: mortal, immortal, i mortal, immoral
& eey 9 22: ea, eye, eel, hey, bey, fey, eek, key, Key
& eey 12 22: ea, eye, eel, ley, dey, gey, fey, hey, bey, eek, key, Key

& CCould 2 1: C Could, Could
& symmetry? 2 26: symmetry, symmetric


& mispell 10 2: mi spell, mi-spell, misspell, Ispell, misspells, misplay, spell, misapply, Aspell, dispel
& mispell 4 2: misspell, mi spell, mi-spell, spell

10 changes: 5 additions & 5 deletions tests/Spellchecker/HunspellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ private function assertWorkingSpellcheckENText($binaries, string $textInput, arr
$this->assertSame(21, $misspellings[1]->getOffset());
$this->assertSame(1, $misspellings[1]->getLineNumber());

$this->assertSame(['ctx'], $misspellings[6]->getContext());
$this->assertSame('mispell', $misspellings[6]->getWord());
$this->assertSame(1, $misspellings[6]->getOffset());
$this->assertSame(6, $misspellings[6]->getLineNumber());
$this->assertNotEmpty($misspellings[6]->getSuggestions());
$this->assertSame(['ctx'], $misspellings[7]->getContext());
$this->assertSame('mispell', $misspellings[7]->getWord());
$this->assertSame(1, $misspellings[7]->getOffset());
$this->assertSame(6, $misspellings[7]->getLineNumber());
$this->assertNotEmpty($misspellings[7]->getSuggestions());
}

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/TextProcessor/MarkdownRemoverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,16 @@ public function testShouldStripOrderedListLeadersKeepingIndentation(): void
public function testShouldStripCodeBlocks(): void
{
$string = <<<CODE
```js
test
```
CODE;
```js
test
```
CODE;

$expected = <<<CODE
test
test
CODE;
CODE;

$this->assertSame($expected, (new MarkdownRemover())->process(t($string))->getContent());
}
Expand Down
Loading

0 comments on commit 3b5343d

Please sign in to comment.