Skip to content

Commit a6be70b

Browse files
authored
Merge pull request #267 from clue-labs/php8.4
Run tests on PHP 8.4 and update test environment
2 parents 96dd718 + db5cefa commit a6be70b

8 files changed

Lines changed: 45 additions & 24 deletions

File tree

.github/workflows/ci.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ jobs:
1111
strategy:
1212
matrix:
1313
os:
14-
- ubuntu-22.04
14+
- ubuntu-24.04
1515
- windows-2022
1616
php:
17+
- 8.4
1718
- 8.3
1819
- 8.2
1920
- 8.1
@@ -43,10 +44,11 @@ jobs:
4344
4445
PHPStan:
4546
name: PHPStan (PHP ${{ matrix.php }})
46-
runs-on: ubuntu-22.04
47+
runs-on: ubuntu-24.04
4748
strategy:
4849
matrix:
4950
php:
51+
- 8.4
5052
- 8.3
5153
- 8.2
5254
- 8.1
@@ -66,10 +68,11 @@ jobs:
6668

6769
Built-in-webserver:
6870
name: Built-in webserver (PHP ${{ matrix.php }})
69-
runs-on: ubuntu-22.04
71+
runs-on: ubuntu-24.04
7072
strategy:
7173
matrix:
7274
php:
75+
- 8.4
7376
- 8.3
7477
- 8.2
7578
- 8.1
@@ -90,7 +93,7 @@ jobs:
9093

9194
Docker:
9295
name: Docker (${{ matrix.dockerfile }})
93-
runs-on: ubuntu-22.04
96+
runs-on: ubuntu-24.04
9497
strategy:
9598
matrix:
9699
dockerfile:
@@ -100,7 +103,7 @@ jobs:
100103
- uses: actions/checkout@v4
101104
- uses: shivammathur/setup-php@v2
102105
with:
103-
php-version: 8.3
106+
php-version: 8.4
104107
- run: composer install -d tests/integration/
105108
- run: docker build -f tests/integration/${{ matrix.dockerfile }} tests/integration/
106109
- run: docker run -d -p 8080:8080 -v "$PWD/composer.json":/app/composer.json $(docker images -q | head -n1)
@@ -112,7 +115,7 @@ jobs:
112115

113116
nginx-reverse-proxy:
114117
name: nginx (${{ matrix.config.name }})
115-
runs-on: ubuntu-22.04
118+
runs-on: ubuntu-24.04
116119
strategy:
117120
matrix:
118121
config:
@@ -124,7 +127,7 @@ jobs:
124127
- uses: actions/checkout@v4
125128
- uses: shivammathur/setup-php@v2
126129
with:
127-
php-version: 8.3
130+
php-version: 8.4
128131
- run: composer install -d tests/integration/
129132
- run: docker build -f tests/integration/Dockerfile-basics tests/integration/
130133
- run: docker run -d -p 8080:8080 -v "$PWD/composer.json":/app/composer.json $(docker images -q | head -n1)
@@ -139,10 +142,11 @@ jobs:
139142

140143
nginx-fpm:
141144
name: nginx + PHP-FPM (PHP ${{ matrix.php }})
142-
runs-on: ubuntu-22.04
145+
runs-on: ubuntu-24.04
143146
strategy:
144147
matrix:
145148
php:
149+
- 8.4
146150
- 8.3
147151
- 8.2
148152
- 8.1
@@ -166,10 +170,11 @@ jobs:
166170

167171
Apache-webserver:
168172
name: Apache webserver (PHP ${{ matrix.php }})
169-
runs-on: ubuntu-22.04
173+
runs-on: ubuntu-24.04
170174
strategy:
171175
matrix:
172176
php:
177+
- 8.4
173178
- 8.3
174179
- 8.2
175180
- 8.1
@@ -192,10 +197,11 @@ jobs:
192197

193198
PHP-webserver:
194199
name: PHP webserver (PHP ${{ matrix.php }})
195-
runs-on: ubuntu-22.04
200+
runs-on: ubuntu-24.04
196201
strategy:
197202
matrix:
198203
php:
204+
- 8.4
199205
- 8.3
200206
- 8.2
201207
- 8.1

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"react/socket": "^1.15"
2020
},
2121
"require-dev": {
22-
"phpstan/phpstan": "1.10.47 || 1.4.10",
22+
"phpstan/phpstan": "1.12.11 || 1.4.10",
2323
"phpunit/phpunit": "^9.6 || ^7.5",
2424
"psr/container": "^2 || ^1",
2525
"react/promise-timer": "^1.11"

docs/best-practices/deployment.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ If you're not already running an Apache server, you can run your X project with
229229
Apache in a temporary Docker container like this:
230230

231231
```bash
232-
$ docker run -it --rm -p 80:80 -v "$PWD":/srv php:8.3-apache sh -c "rmdir /var/www/html;ln -s /srv/public /var/www/html;ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
232+
$ docker run -it --rm -p 80:80 -v "$PWD":/srv php:8.4-apache sh -c "rmdir /var/www/html;ln -s /srv/public /var/www/html;ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled; apache2-foreground"
233233
```
234234

235235
In order to check your web application responds as expected, you can use your
@@ -313,10 +313,10 @@ limit to match your concurrency workload. On Ubuntu- or Debian-based systems,
313313
you may change your PHP configuration like this:
314314

315315
```bash
316-
$ sudoedit /etc/php/8.3/cli/php.ini
316+
$ sudoedit /etc/php/8.4/cli/php.ini
317317
```
318318

319-
```diff title="/etc/php/8.3/cli/php.ini"
319+
```diff title="/etc/php/8.4/cli/php.ini"
320320
- memory_limit = 128M
321321
+ memory_limit = -1
322322
```
@@ -552,7 +552,7 @@ be achieved by using a `Dockerfile` with the following contents:
552552

553553
```docker title="Dockerfile"
554554
# syntax=docker/dockerfile:1
555-
FROM php:8.3-cli
555+
FROM php:8.4-cli
556556

557557
WORKDIR /app/
558558
COPY public/ public/
@@ -574,7 +574,7 @@ be achieved by using a `Dockerfile` with the following contents:
574574
COPY composer.json composer.lock ./
575575
RUN composer install --no-dev --ignore-platform-reqs --optimize-autoloader
576576

577-
FROM php:8.3-alpine
577+
FROM php:8.4-alpine
578578

579579
# recommended: install optional extensions ext-ev and ext-sockets
580580
RUN apk --no-cache add ${PHPIZE_DEPS} libev linux-headers \

tests/AppTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,9 +1437,11 @@ public function testInvokeWithMatchingRouteReturnsInternalServerErrorResponseWhe
14371437
{
14381438
$app = $this->createAppWithoutLogger();
14391439

1440-
$line = __LINE__ + 3;
1440+
// expect error on next line (should yield PromiseInterface)
1441+
// return on same line because PHP < 8.4 reports error on statement *after* invalid yield
1442+
$line = __LINE__ + 2;
14411443
$app->get('/users', function () {
1442-
yield null;
1444+
return yield null;
14431445
});
14441446

14451447
$request = new ServerRequest('GET', 'http://localhost/users');

tests/ContainerTest.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ public function __construct(\stdClass $data)
12841284
$callable = $container->callable(get_class($controller));
12851285

12861286
$this->expectException(\BadMethodCallException::class);
1287-
$this->expectExceptionMessage('Argument 1 ($username) of {closure}() is not defined');
1287+
$this->expectExceptionMessageMatches('/Argument 1 \(\$username\) of {closure(:[^{}]+)?}\(\) is not defined$/');
12881288
$callable($request);
12891289
}
12901290

@@ -1770,7 +1770,7 @@ public function testCallableReturnsCallableThatThrowsWhenFactoryRequiresUntypedA
17701770
$callable = $container->callable(\stdClass::class);
17711771

17721772
$this->expectException(\BadMethodCallException::class);
1773-
$this->expectExceptionMessage('Argument 1 ($undefined) of {closure}() has no type');
1773+
$this->expectExceptionMessageMatches('/Argument 1 \(\$undefined\) of {closure(:[^{}]+)?}\(\) has no type$/');
17741774
$callable($request);
17751775
}
17761776

@@ -1788,7 +1788,7 @@ public function testCallableReturnsCallableThatThrowsWhenFactoryRequiresUndefine
17881788
$callable = $container->callable(\stdClass::class);
17891789

17901790
$this->expectException(\BadMethodCallException::class);
1791-
$this->expectExceptionMessage('Argument 1 ($undefined) of {closure}() is not defined');
1791+
$this->expectExceptionMessageMatches('/Argument 1 \(\$undefined\) of {closure(:[^{}]+)?}\(\) is not defined$/');
17921792
$callable($request);
17931793
}
17941794

@@ -1803,7 +1803,7 @@ public function testCallableReturnsCallableThatThrowsWhenFactoryRequiresRecursiv
18031803
$callable = $container->callable(\stdClass::class);
18041804

18051805
$this->expectException(\BadMethodCallException::class);
1806-
$this->expectExceptionMessage('Argument 1 ($data) of {closure}() is recursive');
1806+
$this->expectExceptionMessageMatches('/Argument 1 \(\$data\) of {closure(:[^{}]+)?}\(\) is recursive$/');
18071807
$callable($request);
18081808
}
18091809

@@ -2233,4 +2233,16 @@ public function testCtorWithInvalidValueThrows(): void
22332233
$this->expectExceptionMessage('Argument #1 ($loader) must be of type array|Psr\Container\ContainerInterface, stdClass given');
22342234
new Container((object) []); // @phpstan-ignore-line
22352235
}
2236+
2237+
public function expectExceptionMessageMatches(string $regularExpression): void
2238+
{
2239+
if (method_exists(parent::class, 'expectExceptionMessageMatches')) {
2240+
// @phpstan-ignore-next-line PHPUnit 8.4+
2241+
parent::expectExceptionMessageMatches($regularExpression);
2242+
} else {
2243+
// legacy PHPUnit
2244+
assert(method_exists($this, 'expectExceptionMessageRegExp'));
2245+
$this->expectExceptionMessageRegExp($regularExpression);
2246+
}
2247+
}
22362248
}

tests/Io/LogStreamHandlerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ public function testLogWithPathToExistingFileWillAppendLogMessageWithCurrentDate
257257
assert(is_resource($stream));
258258
fwrite($stream, 'First' . PHP_EOL);
259259

260+
/** @var array{uri:string} */
260261
$meta = stream_get_meta_data($stream);
261262
assert(is_string($meta['uri']));
262263

tests/integration/Dockerfile-basics

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1
2-
FROM php:8.3-cli
2+
FROM php:8.4-cli
33

44
WORKDIR /app/
55
COPY public/ public/

tests/integration/Dockerfile-production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ COPY composer.json composer.lock ./
88
# dev environment already has dependencies installed:
99
COPY vendor/ vendor/
1010

11-
FROM php:8.3-alpine
11+
FROM php:8.4-alpine
1212

1313
# recommended: install optional extensions ext-ev and ext-sockets
1414
RUN apk --no-cache add ${PHPIZE_DEPS} libev linux-headers \

0 commit comments

Comments
 (0)