Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .claude/agents/phpt-author.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ One-line description of the behaviour, in the present tense
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down Expand Up @@ -52,12 +51,13 @@ array(1) {

## Rules

- **`--INI--` is mandatory, all three lines.** `ffi.enable` cannot be set at runtime, the
JIT rewrites the executor internals z-engine hooks, and
`error_reporting=E_ALL & ~E_DEPRECATED` hides a deprecation that z-engine `dev-master`
itself triggers on PHP 8.4 (implicitly nullable parameters). PHPUnit's `.phpt` runner
forces `display_errors=1`, so without that third line the dependency's deprecation is
prepended to your captured output and the test fails on noise.
- **`--INI--` is mandatory, both lines.** `ffi.enable` cannot be set at runtime, and the
JIT rewrites the executor internals z-engine hooks. There is no `error_reporting` line
any more: it existed only to hide a deprecation z-engine's development line raised
(implicitly nullable parameters), and the stable releases this package requires
(`~8.4.2 || ~8.5.0`) raise none. Do not add one back — PHPUnit's `.phpt` runner forces
`display_errors=1`, so a diagnostic reaching your captured output is real information,
not noise to suppress.
- **An operator cannot throw into userland.** `__doOperation`/`__compare` run inside an FFI
callback, and PHP 8.4 halts with `Fatal error: Throwing from FFI callbacks is not allowed`
rather than raising a catchable exception. Never write `try`/`catch` around `$a + $b` in a
Expand Down
38 changes: 21 additions & 17 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,31 @@ say so and stop.
composer test
```

The suite is PHPUnit 12 driving `.phpt` files in `tests/Functional/`. Three INI
The suite is PHPUnit 12 driving `.phpt` files in `tests/Functional/`. Two INI
settings must hold in **both** the parent PHPUnit process and every `.phpt` child
process it spawns:

- `ffi.enable=1` — FFI cannot be turned on at runtime.
- `opcache.jit=off` — the JIT rewrites the very executor internals z-engine hooks.
- `error_reporting=E_ALL & ~E_DEPRECATED` — a guard against dependency deprecations
leaking into captured output. PHPUnit's `.phpt` runner forces `display_errors=1`,
so a deprecation raised by a dependency is prepended to the captured output of
**every** test and each `--EXPECT--` block fails on noise that has nothing to do
with this library. The specific offender that motivated it — z-engine declaring
implicitly nullable parameters (e.g. `ZEngine\Type\OpLine::__construct()`) — is
fixed as of the stable releases (`~8.4.2 || ~8.5.0`), and the suite passes with
`error_reporting=E_ALL` forced on both minors, so the line is now belt-and-braces
rather than a requirement.

Both are load-bearing: PHPUnit's `.phpt` runner forces `display_errors=1`, so
anything a child process emits before its own output — a startup error, a warning, a
deprecation from a dependency — is prepended to the captured output and the
`--EXPECT--` block fails on noise that has nothing to do with this library.

The suite used to carry a third line, `error_reporting=E_ALL & ~E_DEPRECATED`, for
exactly that reason: z-engine's development line declared implicitly nullable
parameters (e.g. `ZEngine\Type\OpLine::__construct()`) and PHP reported the
deprecation into every test's output. The stable releases now required
(`~8.4.2 || ~8.5.0`) declare those parameters `?Type`, the suite passes with
`error_reporting=E_ALL` forced on both minors, and the line has been removed. **Do
not add it back to silence a new diagnostic** — a deprecation appearing in the
captured output is a signal about a dependency or about this library, and hiding it
only moves the failure somewhere harder to find.

CI supplies the FFI and JIT pair as `ini-values` on the PHP setup step, and **every
`.phpt` file carries its own `--INI--` section** — all three lines — so the child
processes inherit nothing by luck. The deprecation suppression only ever matters in
the children, because those are the processes whose output is compared.
`.phpt` file carries its own `--INI--` section** — both lines — so the child
processes inherit nothing by luck.

For a local one-off run without touching `php.ini`:

Expand Down Expand Up @@ -93,7 +98,6 @@ Matrices can be added with "+" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down Expand Up @@ -123,9 +127,9 @@ array(1) {

Rules for a new test:

- `--INI--` is **mandatory, all three lines** — without them the child process has no
FFI, runs the JIT over hooked internals, or drowns the expected output in a
z-engine deprecation, and the test fails in a way that looks like a library bug.
- `--INI--` is **mandatory, both lines** — without them the child process has no FFI
or runs the JIT over hooked internals, and the test fails in a way that looks like
a library bug.
- Include the autoloader with the relative path `__DIR__ . '/../../vendor/autoload.php'`;
that is what triggers `bootstrap.php` and installs the handlers.
- Prefer `--EXPECT--` (exact match). Use `--EXPECTREGEX--` only when the output
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanAddMatrices.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrices can be added with "+" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanCastMatrixToArray.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrix can be cast to array with "(array)" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanCastMatrixToBool.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrix can be cast to bool with "(bool)" operator and is always truthy
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Numeric casts of a Matrix fall back to the default engine behaviour (warning and
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanCastMatrixToString.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrix can be cast to string with "(string)" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanDivideMatrixByNumber.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrix can be divided by a number with "/" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanMultiplyCompatibleMatrices.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Compatible matrices can be multiplied with "*" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanMultiplyMatrixByNumber.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrix can be multiplied by a number with "*" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanMultiplyNumberByMatrix.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Number can be multiplied by a matrix with "*" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanPowMatrixByNumber.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrix can be raised to the power with "**" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testCanSubtractMatrices.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrices can be subsctracted with "-" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Incompatible matrices cannot be multiplied with "*" operator
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrices with incompatible dimensions can not be added
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testFailsOnEmptyMatrix.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrix can not be created from an empty array
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testFailsOnRaggedMatrix.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrix can not be created from rows with a different number of columns
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Matrices with incompatible dimensions can not be subtracted
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
1 change: 0 additions & 1 deletion tests/Functional/testKeepsDefaultDebugOutput.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Debugging a Matrix keeps the default engine property table with visibility marke
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ get_object_vars() on a Matrix returns the public view even for class-scoped call
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ get_object_vars() on a Matrix keeps default property visibility for outside call
--INI--
ffi.enable=1
opcache.jit=off
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
declare(strict_types=1);
Expand Down