Commit Graph
2 Commits
Author SHA1 Message Date
DarkZmaj 7c6327d58e Do not require PHP 8.4 for the extension OpenAPI generator script (#7252)
## Problem

`packages/sdk/openapi.spec.ts` ("extracts all four extension API areas
without matching another extension") fails on PHP 8.3 with `Call to
undefined function mb_trim()` from
`scripts/generate-extension-openapi.php`. `composer.json` allows PHP
`^8.3`, but `mb_trim()` only exists natively from PHP 8.4. The frontend
job of the Tests workflow uses PHP 8.4, so the failure is not visible
there.

## Reproduction

On PHP 8.3 (for example `shivammathur/setup-php` with `php-version:
8.3`) run `npm ci` and `npm test`. One test fails with `PHP Fatal error:
Uncaught Error: Call to undefined function mb_trim() in
scripts/generate-extension-openapi.php:76`.

## Root cause

The script is meant to run standalone, and it only loads the Composer
autoloader when YAML input or output is involved. The autoloader is what
provides the `mb_trim()` polyfill, so the JSON only path calls an
undefined function on PHP 8.3.

## Fix

Use `trim()` for the generated API title. The title is built from the
original title, a fixed separator and a validated extension id, so ASCII
whitespace trimming gives the same result and no longer depends on the
polyfill.

## Testing

* `npx vitest run packages/sdk/openapi.spec.ts` on PHP 8.3: the
extraction test now passes. (The second test in that file also fails on
my Windows machine for a separate reason that does not occur on Linux,
so it is not part of this change.)
* Linux CI on PHP 8.3 reproduced the original failure as the only
failing frontend test.

## Compatibility considerations

None. The output is the same for any normal title, which cannot start
with Unicode only whitespace.
2026-10-06 22:47:54 -04:00
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00