refactor!: require PHP 8.4
Tests / PHP 8.4 (push) Failing after 1m26s

Drop support for PHP 8.3 and lower. The package now declares >=8.4, and CI runs
only on 8.4.

- composer.json: require php >=8.4.
- mago.toml: php-version = "8.4", matching the minimum supported version.
- phpstan.neon: phpVersion 80400.
- Upgrade phpstan/phpstan to ^2.3: 1.x cannot parse `new Foo()->bar()`, which the
  8.4 formatter now emits.
- Narrow ArrayGateway::count() to int, matching what the fixture actually returns.
- CI: single PHP 8.4 job using the php:8.4-cli container instead of setup-php,
  which failed with a TLS handshake timeout on the runner.

BREAKING CHANGE: PHP 8.4 is now required.
This commit is contained in:
dgarcia committed 2026-11-15 10:58:17 -03:00
1 parent a20762a715
commit 807992ecab
15 files changed
+57 -62

No files matched your search

+5 -17
View File
@@ -6,39 +6,27 @@ on:
pull_request: pull_request:
branches: [main] branches: [main]
jobs:
check:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: ['8.3', '8.4']
name: PHP ${{ matrix.php }}
# The PHP version comes from the job container image instead of shivammathur/setup-php: # The PHP version comes from the job container image instead of shivammathur/setup-php:
# the runner in this Gitea instance reaches github.com intermittently and setup-php # the runner in this Gitea instance reaches github.com intermittently and setup-php
# failed with "TLS handshake timeout". Fewer external actions, fewer failure modes. # failed with "TLS handshake timeout". Fewer external actions, fewer failure modes.
container: php:${{ matrix.php }}-cli jobs:
check:
runs-on: ubuntu-latest
name: PHP 8.4
container: php:8.4-cli
steps: steps:
- name: Install system packages - name: Install system packages
run: | run: |
apt-get update -qq apt-get update -qq
apt-get install -y -qq --no-install-recommends git unzip libxml2-dev > /dev/null apt-get install -y -qq --no-install-recommends git unzip libxml2-dev > /dev/null
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Install Composer - name: Install Composer
run: | run: |
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer --quiet php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer --quiet
composer --version
- name: Install dependencies - name: Install dependencies
run: composer update --prefer-dist --no-interaction --no-progress run: composer update --prefer-dist --no-interaction --no-progress
- name: Run gate - name: Run gate
run: composer check run: composer check
+8 -7
View File
@@ -37,8 +37,8 @@ salvo lo que difiere abajo. Léelos antes de tocar el toolchain.
| | aquí | en `../orm` | | | aquí | en `../orm` |
|---|---|---| |---|---|---|
| PHP declarado | `>=8.3` | `>=8.3` (su prosa dice 8.2: gana el composer.json) | | PHP declarado | `>=8.4` | `>=8.4` |
| Parser Mago / PHPStan | 8.2 / `80300` | 8.2 / `80200` | | Parser Mago / PHPStan | 8.4 / `80400` | 8.4 / `80400` |
| `mago-baseline.toml` | **no existe**, y no debe crearse | existe | | `mago-baseline.toml` | **no existe**, y no debe crearse | existe |
## Independencia del ORM (decisión de diseño, no descuido) ## Independencia del ORM (decisión de diseño, no descuido)
@@ -65,8 +65,8 @@ la app conecta el ORM por composición. Consecuencias que un agente rompería po
## Entorno local ## Entorno local
- PHP: `C:\php8.4\php.exe` (8.4.19), Composer 2.10.3. La librería declara `>=8.3`, así que **no** - PHP: `C:\php8.4\php.exe` (8.4.19), Composer 2.10.3. La librería declara `>=8.4`, así que toda la
uses sintaxis exclusiva de 8.4; por eso `(new Foo())->bar()` conserva los paréntesis. sintaxis de 8.4 está disponible.
- `declare(strict_types=1)` en todo archivo, incluidos los tests. - `declare(strict_types=1)` en todo archivo, incluidos los tests.
- Sin `.env` ni servicios externos. Los tests son unitarios y puros: no levantan servidor, ni base, - Sin `.env` ni servicios externos. Los tests son unitarios y puros: no levantan servidor, ni base,
ni red. Un test que necesite un socket real está mal ubicado aquí. ni red. Un test que necesite un socket real está mal ubicado aquí.
@@ -87,9 +87,10 @@ vendor/bin/phpunit --configuration phpunit.xml.dist --filter NombreDelTest
## Trampas del toolchain ## Trampas del toolchain
- **`php-version = "8.2"` en `mago.toml` es obligatorio.** Subirlo a 8.4 hace que `mago fmt` - **`php-version = "8.4"` en `mago.toml` debe coincidir con el mínimo declarado.** El paquete
reescriba `(new X())->m()` como `new X()->m()`, que rompe el soporte declarado y ni siquiera parsea promete `>=8.4`, así que `mago fmt` puede emitir `new X()->m()`. Si el soporte mínimo bajara,
cuando el resultado se asigna. `php-version` tendría que bajar con él: con 8.4 el formatter elimina los paréntesis de
`(new X())->m()`, sintaxis que no parsea en 8.3 ni inferiores.
- `mago analyze` excluye `tests/` (no carga el autoloader de Composer): reportaría `TestCase` como - `mago analyze` excluye `tests/` (no carga el autoloader de Composer): reportaría `TestCase` como
clase inexistente. PHPStan sí cubre los tests. clase inexistente. PHPStan sí cubre los tests.
- **Sin baseline.** El baseline del ORM acepta `mixed` inherente a PDO. Aquí no hay PDO como - **Sin baseline.** El baseline del ORM acepta `mixed` inherente a PDO. Aquí no hay PDO como
+1 -1
View File
@@ -9,7 +9,7 @@ Framework-agnostic REST controller toolkit: routing, request parsing, validation
over any data source. Vanilla PHP, no framework. over any data source. Vanilla PHP, no framework.
- **Package:** `camelia/controllers` — **Namespace:** `Camelia\Controllers` - **Package:** `camelia/controllers` — **Namespace:** `Camelia\Controllers`
- **PHP** `>=8.3`, extension `json` - **PHP** `>=8.4`, extension `json`
## What it is ## What it is
+2 -2
View File
@@ -11,12 +11,12 @@
} }
], ],
"require": { "require": {
"php": ">=8.3", "php": ">=8.4",
"ext-json": "*" "ext-json": "*"
}, },
"require-dev": { "require-dev": {
"carthage-software/mago": "^1.60", "carthage-software/mago": "^1.60",
"phpstan/phpstan": "^1.11", "phpstan/phpstan": "2.3",
"phpunit/phpunit": "^10.5 || ^11.0" "phpunit/phpunit": "^10.5 || ^11.0"
}, },
"autoload": { "autoload": {
Generated
+18 -7
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "c828e25914c9dd9e5cf7667b446f40ad", "content-hash": "15c8e8773869cdb0c6dab80f2e5211b7",
"packages": [], "packages": [],
"packages-dev": [ "packages-dev": [
{ {
@@ -308,15 +308,15 @@
}, },
{ {
"name": "phpstan/phpstan", "name": "phpstan/phpstan",
"version": "1.12.34", "version": "2.3.0",
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/4dd89ca7aa30fdc6760be21550d583bcc32e8476", "url": "https://api.github.com/repos/phpstan/phpstan/zipball/b1f9890d9af53a25c58129e78f0aadd31f90d7f4",
"reference": "4dd89ca7aa30fdc6760be21550d583bcc32e8476", "reference": "b1f9890d9af53a25c58129e78f0aadd31f90d7f4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.2|^8.0" "php": "^7.4|^8.0"
}, },
"conflict": { "conflict": {
"phpstan/phpstan-shim": "*" "phpstan/phpstan-shim": "*"
@@ -335,6 +335,17 @@
"license": [ "license": [
"MIT" "MIT"
], ],
"authors": [
{
"name": "Ondřej Mirtes"
},
{
"name": "Markus Staab"
},
{
"name": "Vincent Langlet"
}
],
"description": "PHPStan - PHP Static Analysis Tool", "description": "PHPStan - PHP Static Analysis Tool",
"keywords": [ "keywords": [
"dev", "dev",
@@ -357,7 +368,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2026-07-28T10:04:39+00:00" "time": "2026-10-06T06:15:36+00:00"
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
@@ -1967,7 +1978,7 @@
"prefer-stable": true, "prefer-stable": true,
"prefer-lowest": false, "prefer-lowest": false,
"platform": { "platform": {
"php": ">=8.3", "php": ">=8.4",
"ext-json": "*" "ext-json": "*"
}, },
"platform-dev": {}, "platform-dev": {},
+2 -3
View File
@@ -1,9 +1,8 @@
# Mago toolchain configuration — camelia/controllers # Mago toolchain configuration — camelia/controllers
# Docs: https://mago.carthage.software # Docs: https://mago.carthage.software
# The library promises PHP >= 8.3. Pinning the parser to 8.2 keeps the formatter from emitting # The library promises PHP >= 8.4.
# syntax the package cannot ship (for example `new Foo()->bar()`, which needs 8.4). php-version = "8.4"
php-version = "8.2"
[source] [source]
paths = ["src", "tests"] paths = ["src", "tests"]
+2 -3
View File
@@ -1,8 +1,7 @@
parameters: parameters:
level: 8 level: 8
# The library promises PHP >= 8.3, so analysis targets the oldest supported version. # The library promises PHP >= 8.4, so analysis targets the only supported version.
# This is why `(new Foo())->bar()` keeps its parentheses: `new Foo()->bar()` only parses on 8.4+. phpVersion: 80400
phpVersion: 80300
paths: paths:
- src - src
- tests - tests
+1 -1
View File
@@ -61,7 +61,7 @@ final class ArrayGateway implements ResourceGateway
return true; return true;
} }
public function count(array $query = []): ?int public function count(array $query = []): int
{ {
return count($this->records); return count($this->records);
} }
+1 -1
View File
@@ -158,7 +158,7 @@ final class CrudControllerTest extends TestCase
private function withId(string $method, string $id): Request private function withId(string $method, string $id): Request
{ {
return (new JsonRequest(method: $method, path: '/articulos/' . $id))->withAttribute( return new JsonRequest(method: $method, path: '/articulos/' . $id)->withAttribute(
'id', 'id',
$id, $id,
); );
+1 -1
View File
@@ -52,7 +52,7 @@ final class JsonRequestTest extends TestCase
public function testWithAttributeKeepsPreviousAttributes(): void public function testWithAttributeKeepsPreviousAttributes(): void
{ {
$request = (new JsonRequest()) $request = new JsonRequest()
->withAttribute('a', '1') ->withAttribute('a', '1')
->withAttribute('b', '2'); ->withAttribute('b', '2');
@@ -19,7 +19,7 @@ final class ContentNegotiationTest extends TestCase
public function testAddsContentType(): void public function testAddsContentType(): void
{ {
$response = (new ContentNegotiation())->process(new JsonRequest(), self::ok(...)); $response = new ContentNegotiation()->process(new JsonRequest(), self::ok(...));
self::assertSame(200, $response->status()); self::assertSame(200, $response->status());
self::assertSame('application/json; charset=utf-8', $response->headers()['Content-Type']); self::assertSame('application/json; charset=utf-8', $response->headers()['Content-Type']);
@@ -27,14 +27,14 @@ final class ContentNegotiationTest extends TestCase
public function testMissingAcceptHeaderIsAccepted(): void public function testMissingAcceptHeaderIsAccepted(): void
{ {
$response = (new ContentNegotiation())->process(new JsonRequest(), self::ok(...)); $response = new ContentNegotiation()->process(new JsonRequest(), self::ok(...));
self::assertSame(200, $response->status()); self::assertSame(200, $response->status());
} }
public function testJsonAcceptIsAccepted(): void public function testJsonAcceptIsAccepted(): void
{ {
$response = (new ContentNegotiation())->process( $response = new ContentNegotiation()->process(
new JsonRequest(headers: ['accept' => 'application/json']), new JsonRequest(headers: ['accept' => 'application/json']),
self::ok(...), self::ok(...),
); );
@@ -46,7 +46,7 @@ final class ContentNegotiationTest extends TestCase
{ {
$accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; $accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
$response = (new ContentNegotiation())->process( $response = new ContentNegotiation()->process(
new JsonRequest(headers: ['accept' => $accept]), new JsonRequest(headers: ['accept' => $accept]),
self::ok(...), self::ok(...),
); );
@@ -56,7 +56,7 @@ final class ContentNegotiationTest extends TestCase
public function testIncompatibleAcceptIs406(): void public function testIncompatibleAcceptIs406(): void
{ {
$response = (new ContentNegotiation())->process( $response = new ContentNegotiation()->process(
new JsonRequest(headers: ['accept' => 'application/xml']), new JsonRequest(headers: ['accept' => 'application/xml']),
static function (): Response { static function (): Response {
self::fail('The handler must not run when the client rejects JSON.'); self::fail('The handler must not run when the client rejects JSON.');
@@ -69,7 +69,7 @@ final class ContentNegotiationTest extends TestCase
public function testZeroQualityIsRejected(): void public function testZeroQualityIsRejected(): void
{ {
$response = (new ContentNegotiation())->process( $response = new ContentNegotiation()->process(
new JsonRequest(headers: ['accept' => 'application/json;q=0']), new JsonRequest(headers: ['accept' => 'application/json;q=0']),
static function (): Response { static function (): Response {
self::fail('A q=0 entry means not acceptable.'); self::fail('A q=0 entry means not acceptable.');
@@ -81,7 +81,7 @@ final class ContentNegotiationTest extends TestCase
public function testNonZeroQualityIsAccepted(): void public function testNonZeroQualityIsAccepted(): void
{ {
$response = (new ContentNegotiation())->process( $response = new ContentNegotiation()->process(
new JsonRequest(headers: ['accept' => 'application/json;q=0.5']), new JsonRequest(headers: ['accept' => 'application/json;q=0.5']),
self::ok(...), self::ok(...),
); );
@@ -91,7 +91,7 @@ final class ContentNegotiationTest extends TestCase
public function testExistingContentTypeIsPreserved(): void public function testExistingContentTypeIsPreserved(): void
{ {
$response = (new ContentNegotiation())->process( $response = new ContentNegotiation()->process(
new JsonRequest(), new JsonRequest(),
static fn(): Response => new Response(['ok' => true], 200, [ static fn(): Response => new Response(['ok' => true], 200, [
'Content-Type' => 'application/problem+json', 'Content-Type' => 'application/problem+json',
@@ -103,7 +103,7 @@ final class ContentNegotiationTest extends TestCase
public function testContentTypeCanBeDisabled(): void public function testContentTypeCanBeDisabled(): void
{ {
$response = (new ContentNegotiation(addContentType: false))->process( $response = new ContentNegotiation(addContentType: false)->process(
new JsonRequest(), new JsonRequest(),
self::ok(...), self::ok(...),
); );
+2 -2
View File
@@ -88,7 +88,7 @@ final class BearerAuthTest extends TestCase
public function testRouterRejectsBeforeReachingController(): void public function testRouterRejectsBeforeReachingController(): void
{ {
$router = (new Router())->withMiddleware( $router = new Router()->withMiddleware(
new BearerAuth(static fn(string $token): ?array => null), new BearerAuth(static fn(string $token): ?array => null),
); );
$router->get('/x', static fn(): Response => new Response(['leaked' => true])); $router->get('/x', static fn(): Response => new Response(['leaked' => true]));
@@ -101,7 +101,7 @@ final class BearerAuthTest extends TestCase
public function testRouterAllowsValidToken(): void public function testRouterAllowsValidToken(): void
{ {
$router = (new Router())->withMiddleware(new BearerAuth(static fn(string $token): array => [ $router = new Router()->withMiddleware(new BearerAuth(static fn(string $token): array => [
'id' => 1, 'id' => 1,
])); ]));
$router->get( $router->get(
+1 -1
View File
@@ -38,7 +38,7 @@ final class CorsTest extends TestCase
public function testWildcardOriginIsAddedToResponse(): void public function testWildcardOriginIsAddedToResponse(): void
{ {
$response = (new Cors())->process( $response = new Cors()->process(
new JsonRequest(headers: ['origin' => 'https://app.test']), new JsonRequest(headers: ['origin' => 'https://app.test']),
self::passThrough(...), self::passThrough(...),
); );
+2 -2
View File
@@ -89,8 +89,8 @@ final class RateLimitTest extends TestCase
public function testBucketsAreSeparatedByClientAddress(): void public function testBucketsAreSeparatedByClientAddress(): void
{ {
$limiter = $this->limiter(1); $limiter = $this->limiter(1);
$first = (new JsonRequest())->withAttribute('client_ip', '10.0.0.1'); $first = new JsonRequest()->withAttribute('client_ip', '10.0.0.1');
$second = (new JsonRequest())->withAttribute('client_ip', '10.0.0.2'); $second = new JsonRequest()->withAttribute('client_ip', '10.0.0.2');
self::assertSame(200, $limiter->process($first, self::passThrough(...))->status()); self::assertSame(200, $limiter->process($first, self::passThrough(...))->status());
self::assertSame(200, $limiter->process($second, self::passThrough(...))->status()); self::assertSame(200, $limiter->process($second, self::passThrough(...))->status());
+2 -5
View File
@@ -19,15 +19,12 @@ final class RequireRoleTest extends TestCase
private static function withUser(mixed $user): Request private static function withUser(mixed $user): Request
{ {
return (new JsonRequest())->withAttribute('user', $user); return new JsonRequest()->withAttribute('user', $user);
} }
public function testNoIdentityIs401(): void public function testNoIdentityIs401(): void
{ {
$response = (new RequireRole(['admin']))->process( $response = new RequireRole(['admin'])->process(new JsonRequest(), self::passThrough(...));
new JsonRequest(),
self::passThrough(...),
);
self::assertSame(401, $response->status()); self::assertSame(401, $response->status());
self::assertStringContainsString( self::assertStringContainsString(