native-php-matrix CLAUDE.md

Project instructions for a PHP extension that provides a Matrix class with arithmetic operators such as addition, multiplication, powers, and comparison. It explains how the extension connects PHP’s engine to the class through FFI, a way for code to call low-level native interfaces.

In plain words
What is it for?
Use it when changing native-php-matrix, running its tests, working with .phpt test files, or checking PHP and z-engine compatibility.
Why use it?
It highlights the strict PHP-version and memory-layout requirements that prevent subtle or unsafe failures when developing or testing the extension.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/lisachenko/native-php-matrix/claude-md
Clone the repo
git clone --depth 1 https://github.com/lisachenko/native-php-matrix
Per session 2,438 This file is loaded in full into every session.
When invoked 2,438 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.02438 $0.02438
Opus 5 $0.01219 $0.01219
Sonnet 5 $0.00488 $0.00488
Haiku 4.5 $0.00244 $0.00244

Measured 2d ago against content hash 8b5135b31ae6, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

native-php-matrix CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 211 lines

How it starts

The opening of the file, as written. The whole thing — 211 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Working on native-php-matrix

This library gives PHP a Matrix class with real operator overloading — +, -, *, /, ** and == are dispatched by the Zend Engine itself, not emulated in userland. It does that by using z-engine to install create_object, do_operation and compare handlers directly onto the Matrix class entry through PHP FFI. The matrix arithmetic underneath is ordinary, readable PHP; the only unusual part is how the engine is convinced to call it.

The one rule that is non-negotiable: PHP minor and z-engine line move together

composer.json requires php: ^8.4, and PHP 8.4 and 8.5 are supported in parallel — each minor riding its own z-engine line. z-engine reads engine structures (zend_class_entry, zval, zend_object_handlers) by byte offset, and those offsets change on every PHP minor release. Running against the wrong minor does not throw a nice exception; it reads and writes the wrong memory.

That is why z-engine is required as ~8.4.2 || ~8.5.0: Composer resolves the release line matching the running PHP (8.4.x on PHP 8.4, 8.5.x on PHP 8.5 — each tag declares its own ~8.4.0/~8.5.0 platform requirement, so only one line can ever satisfy a given runtime). ZEngine\Core::init() (called from bootstrap.php) enforces the exact match and aborts with a clear message. Never "fix" an initialization failure by loosening the constraints past the minors z-engine has definitions for, skipping Core::init(), or defeating the guard. If the environment's PHP does not satisfy ^8.4 (8.4 or 8.5), the environment is wrong — say so and stop.

Running tests

composer test

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.

Read the full file on GitHub · 211 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 211 lines · 2,438 tokens per session scan A 8b5135b31ae6

Subscribe to this mod's changes

native-php-matrix CLAUDE.md is an instructions file published in the GitHub repository lisachenko/native-php-matrix (43 stars, last pushed 13d ago), licensed MIT. It adds 2,438 tokens to every session, about $0.0122 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.