Skip to content

feat: array-style row access $matrix[$i] via dimension hooks #6

Description

@lisachenko

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions