z-engine dev-master now exposes the engine's dimension object handlers as userland hooks. Implementing ObjectReadDimensionInterface, ObjectWriteDimensionInterface and ObjectHasDimensionInterface on Matrix would allow reading a row with $matrix[0] and replacing one with $matrix[0] = [1, 2, 3] (with the same shape/type validation the constructor performs).
Notes for implementation:
- Nested cell writes (
$matrix[0][1] = 5;) require handling the read-for-write access type on ReadDimensionHook — this should be scoped and documented explicitly (either supported or rejected with a clear message).
ObjectUnsetDimensionInterface::__dimensionUnset() must reject the operation: removing a row would break the non-empty rectangular matrix invariant. Note that PHP 8.4 does not allow throwing from FFI callbacks (it halts with a fatal error), so "rejecting" here means a hard abort — the behavior should be documented, or signaled via trigger_error if a softer failure mode is wanted.
- Handlers are auto-wired by
ReflectionClass::installExtensionHandlers() in bootstrap.php; implementing the interfaces is enough.
z-engine dev-master now exposes the engine's dimension object handlers as userland hooks. Implementing
ObjectReadDimensionInterface,ObjectWriteDimensionInterfaceandObjectHasDimensionInterfaceonMatrixwould allow reading a row with$matrix[0]and replacing one with$matrix[0] = [1, 2, 3](with the same shape/type validation the constructor performs).Notes for implementation:
$matrix[0][1] = 5;) require handling the read-for-write access type onReadDimensionHook— this should be scoped and documented explicitly (either supported or rejected with a clear message).ObjectUnsetDimensionInterface::__dimensionUnset()must reject the operation: removing a row would break the non-empty rectangular matrix invariant. Note that PHP 8.4 does not allow throwing from FFI callbacks (it halts with a fatal error), so "rejecting" here means a hard abort — the behavior should be documented, or signaled viatrigger_errorif a softer failure mode is wanted.ReflectionClass::installExtensionHandlers()inbootstrap.php; implementing the interfaces is enough.