Skip to content

Commit 736c99f

Browse files
committed
Test against PHP 8.4
1 parent 0288676 commit 736c99f

16 files changed

+128
-47
lines changed

.github/workflows/code-style.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-20.04
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1414
- name: Install PHP
1515
uses: shivammathur/setup-php@v2
1616
with:

.github/workflows/static-analysis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ jobs:
1010
runs-on: ubuntu-20.04
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1414
- name: Install PHP
1515
uses: shivammathur/setup-php@v2
1616
with:
1717
php-version: "7.1"
1818
ini-values: memory_limit=-1
1919
tools: composer:v2
2020
- name: Cache dependencies
21-
uses: actions/cache@v2
21+
uses: actions/cache@v4
2222
with:
2323
path: |
2424
~/.composer/cache

.github/workflows/test.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ jobs:
1515
- "7.2"
1616
- "7.3"
1717
- "7.4"
18+
- "8.4"
1819
steps:
1920
- name: Checkout
20-
uses: actions/checkout@v2
21+
uses: actions/checkout@v4
2122
- name: Install PHP
2223
uses: shivammathur/setup-php@v2
2324
with:
@@ -26,7 +27,7 @@ jobs:
2627
ini-values: memory_limit=-1
2728
tools: composer:v2
2829
- name: Cache dependencies
29-
uses: actions/cache@v2
30+
uses: actions/cache@v4
3031
with:
3132
path: |
3233
~/.composer/cache
@@ -39,6 +40,8 @@ jobs:
3940

4041
- name: Run PHPUnit
4142
run: make test-coveralls
43+
env:
44+
PHPUNIT_VERSION: "${{ matrix.php-version == '8.4' && '11' || '07' }}"
4245

4346
- name: Upload code coverage
4447
if: ${{ matrix.php-version == '7.1' }}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.phpunit.result.cache
12
build
23
composer.lock
34
vendor

CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# CHANGELOG
2+
3+
## 1.x to 2.0
4+
5+
### New requirements
6+
7+
- PHP 7.1+
8+
9+
### New features
10+
11+
None
12+
13+
### Backward Incompatible Changes
14+
15+
None
16+
17+
### Deprecated Features
18+
19+
None
20+
21+
### Other Changes
22+
23+
None

Dockerfile

+21-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
FROM php:7.1-cli-buster
1+
ARG PHP_TAG=7.1-cli-buster
2+
FROM php:${PHP_TAG}
23

3-
RUN docker-php-ext-enable opcache && \
4-
docker-php-source delete
4+
RUN <<-EOF
5+
docker-php-ext-enable opcache
6+
EOF
57

6-
RUN echo '\
7-
display_errors=On\n\
8-
error_reporting=E_ALL\n\
9-
date.timezone=UTC\n\
10-
' >> /usr/local/etc/php/conf.d/php.ini
8+
RUN <<-EOF
9+
cat <<-SHELL >> /usr/local/etc/php/conf.d/php.ini
10+
display_errors=On
11+
error_reporting=E_ALL
12+
date.timezone=UTC
13+
SHELL
14+
EOF
1115

1216
ENV COMPOSER_ALLOW_SUPERUSER 1
1317

14-
RUN apt-get update && \
15-
apt-get install unzip && \
16-
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
17-
mv composer.phar /usr/local/bin/composer && \
18-
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"\n' >> /root/.bashrc
18+
RUN <<-EOF
19+
apt-get update
20+
apt-get install unzip
21+
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet
22+
mv composer.phar /usr/local/bin/composer
23+
cat <<-SHELL >> /root/.bashrc
24+
export PATH="$HOME/.composer/vendor/bin:$PATH"
25+
SHELL
26+
EOF
1927

2028
RUN composer global require squizlabs/php_codesniffer

Makefile

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# customization
22

3-
PACKAGE_NAME = icanboogie/inflector
4-
PHPUNIT = vendor/bin/phpunit
3+
PHPUNIT = vendor/bin/phpunit --configuration=phpunit$(PHPUNIT_VERSION).xml
54

65
# do not edit the following lines
76

@@ -13,24 +12,32 @@ test-dependencies: vendor
1312

1413
.PHONY: test
1514
test: test-dependencies
16-
@$(PHPUNIT)
15+
@XDEBUG_MODE=none $(PHPUNIT)
1716

1817
.PHONY: test-coverage
1918
test-coverage: test-dependencies
2019
@mkdir -p build/coverage
21-
@$(PHPUNIT) --coverage-html build/coverage
20+
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-html build/coverage
2221

2322
.PHONY: test-coveralls
2423
test-coveralls: test-dependencies
2524
@mkdir -p build/logs
26-
@$(PHPUNIT) --coverage-clover build/logs/clover.xml
25+
@XDEBUG_MODE=coverage $(PHPUNIT) --coverage-clover build/logs/clover.xml
2726

2827
.PHONY: test-container
29-
test-container:
30-
@docker-compose run --rm app bash
28+
test-container: test-container-71
29+
30+
.PHONY: test-container-71
31+
test-container-71:
32+
@-docker-compose run --rm app71 bash
33+
@docker-compose down -v
34+
35+
.PHONY: test-container-84
36+
test-container-84:
37+
@-docker-compose run --rm app84 bash
3138
@docker-compose down -v
3239

3340
.PHONY: lint
3441
lint:
35-
@phpcs
36-
@vendor/bin/phpstan
42+
@XDEBUG_MODE=off phpcs -s
43+
@XDEBUG_MODE=off vendor/bin/phpstan

UPGRADING.md

-7
This file was deleted.

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
"ext-mbstring": "*"
2626
},
2727
"require-dev": {
28-
"icanboogie/common": "^2.0",
29-
"phpstan/phpstan": "^0.12.92",
30-
"phpunit/phpunit": "^7.5"
28+
"icanboogie/common": "^2.1",
29+
"phpstan/phpstan": "^0.12.100|^2.0",
30+
"phpunit/phpunit": "^7.5.20|^11.4"
3131
},
3232
"conflict": {
3333
"icanboogie/common": "<2.0"

docker-compose.yaml

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
---
2-
version: "3.2"
32
services:
4-
app:
5-
build: .
3+
app71:
4+
build:
5+
context: .
6+
args:
7+
PHP_TAG: "7.1-cli-buster"
68
environment:
79
PHP_IDE_CONFIG: 'serverName=icanboogie-inflector'
8-
volumes:
10+
PHPUNIT_VERSION: "07"
11+
volumes: &vol
912
- .:/app:delegated
1013
- ~/.composer:/root/.composer:delegated
1114
working_dir: /app
15+
app84:
16+
build:
17+
context: .
18+
args:
19+
PHP_TAG: "8.4.0RC4-cli-bookworm"
20+
environment:
21+
PHP_IDE_CONFIG: 'serverName=icanboogie-inflector'
22+
PHPUNIT_VERSION: "11"
23+
volumes: *vol
24+
working_dir: /app

lib/InflectionsNotFound.php

-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,4 @@
1515

1616
class InflectionsNotFound extends LogicException
1717
{
18-
1918
}

lib/Inflector.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* The Inflector transforms words from singular to plural, class names to table names, modularized
2121
* class names to ones without, and class names to foreign keys. Inflections can be localized, the
22-
* default english inflections for pluralization, singularization, and uncountable words are
22+
* default English inflections for pluralization, singularization, and uncountable words are
2323
* kept in `lib/Inflections/en.php`.
2424
*
2525
* @property-read Inflections $inflections Inflections used by the inflector.
@@ -67,7 +67,7 @@ public static function get(string $locale = self::DEFAULT_LOCALE): self
6767
*/
6868
private $inflections;
6969

70-
public function __construct(Inflections $inflections = null)
70+
public function __construct(?Inflections $inflections = null)
7171
{
7272
$this->inflections = $inflections ?? new Inflections();
7373
}

phpunit.xml renamed to phpunit07.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
executionOrder="depends,defects"
66
beStrictAboutOutputDuringTests="true"
77
verbose="true"
8-
colors="true">
8+
colors="true"
9+
>
910
<testsuites>
1011
<testsuite name="icanboogie/inflector">
1112
<directory>./tests</directory>

phpunit11.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
4+
beStrictAboutCoverageMetadata="true"
5+
beStrictAboutOutputDuringTests="true"
6+
bootstrap="tests/bootstrap.php"
7+
colors="true"
8+
displayDetailsOnTestsThatTriggerDeprecations="true"
9+
displayDetailsOnTestsThatTriggerNotices="true"
10+
displayDetailsOnTestsThatTriggerWarnings="true"
11+
displayDetailsOnPhpunitDeprecations="true"
12+
executionOrder="depends,defects"
13+
>
14+
<testsuites>
15+
<testsuite name="icanboogie/inflector">
16+
<directory>tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
<source>
20+
<include>
21+
<directory>lib</directory>
22+
</include>
23+
</source>
24+
</phpunit>

tests/HelpersTest.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,29 @@
1111

1212
namespace Tests\ICanBoogie;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\Group;
1416
use PHPUnit\Framework\TestCase;
1517

1618
use function ICanBoogie\capitalize;
1719

1820
/**
1921
* @group helpers
2022
*/
23+
#[Group('helpers')]
2124
final class HelpersTest extends TestCase
2225
{
2326
/**
2427
* @dataProvider provide_test_capitalize
2528
*/
29+
#[DataProvider('provide_test_capitalize')]
2630
public function test_capitalize(string $str, bool $preserve_str_end, string $expected): void
2731
{
2832
$this->assertSame($expected, capitalize($str, $preserve_str_end));
2933
}
3034

3135
// @phpstan-ignore-next-line
32-
public function provide_test_capitalize(): array
36+
public static function provide_test_capitalize(): array
3337
{
3438
return [
3539

tests/InflectionsTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
use ICanBoogie\Inflections;
1515
use ICanBoogie\InflectionsNotFound;
16+
use PHPUnit\Framework\Attributes\DataProvider;
17+
use PHPUnit\Framework\Attributes\Group;
1618
use PHPUnit\Framework\TestCase;
1719

1820
use function ICanBoogie\pluralize;
@@ -21,6 +23,7 @@
2123
/**
2224
* @group integration
2325
*/
26+
#[Group('integration')]
2427
final class InflectionsTest extends TestCase
2528
{
2629
public function test_fail_on_undefined_inflections(): void
@@ -33,6 +36,7 @@ public function test_fail_on_undefined_inflections(): void
3336
/**
3437
* @dataProvider provide_singular_and_plural
3538
*/
39+
#[DataProvider('provide_singular_and_plural')]
3640
public function test_singular_to_plural(string $locale, string $singular, string $plural): void
3741
{
3842
$this->assertEquals($plural, pluralize($singular, $locale));
@@ -41,13 +45,14 @@ public function test_singular_to_plural(string $locale, string $singular, string
4145
/**
4246
* @dataProvider provide_singular_and_plural
4347
*/
48+
#[DataProvider('provide_singular_and_plural')]
4449
public function test_plural_to_singular(string $locale, string $singular, string $plural): void
4550
{
4651
$this->assertEquals($singular, singularize($plural, $locale));
4752
}
4853

4954
// @phpstan-ignore-next-line
50-
public function provide_singular_and_plural(): array
55+
public static function provide_singular_and_plural(): array
5156
{
5257
$locales = explode(' ', 'en es fr nb pt tr');
5358
$rc = [];

0 commit comments

Comments
 (0)