proomt

Search

Search posts, papers, and topics

All posts

Freek Van der Herten1 min readintermediate

Immutability in PHP Beyond readonly

Summary

The article walks through practical ways to achieve immutability in PHP beyond the built‑in readonly keyword, covering interior mutability, immutable value objects, collections, dates, and cloning. It also shows how to enforce and test these patterns in real codebases.

  • Readonly properties give shallow immutability; they prevent reassignment but not mutation of referenced objects.
  • Avoid interior mutability by never exposing mutable references from value objects or collections.
  • Implement true immutable value objects by making all fields private, final, and returning new instances on changes.
  • Use cloning or named constructors to create modified copies without altering the original instance.

PHP developers who want more predictable, side‑effect‑free code should read this to learn enforceable immutability techniques.

6/10

Related reading

  1. What's new in PHP 8.6

    This post previews PHP 8.6 features, highlighting partial function application, a new polling API, and readonly property defaults. It also mentions other improvements and deprecations expected in the upcoming release.

    Freek Van der Hertenfreek.dev1 min
  2. RecreationWorld: Scalable and Verifiable Environments for Hybrid Computer-Use Agents

    The paper presents RecreationWorld, a five‑platform framework that lets hybrid computer‑use agents learn by recreating the behavior of a running reference, and introduces RecreationBench, a 250‑task benchmark with programmatic and visual assertions. Experiments show GPT‑6 Astra reaches 58.1% overall but struggles with deeper programmatic tests, highlighting gaps in current agents.

    Hugging Face Daily Papersarxiv.org2 minpaper
  3. Building Deterministic Multi-Agent State Machines in TypeScript

    The article shows how to build a deterministic, checkpoint‑backed finite state machine engine in TypeScript for orchestrating multi‑agent AI workflows. It uses Zod for schema validation, better‑sqlite3 for atomic persistence, and a pure transition function to make workflows traceable and recoverable in serverless environments.

    SitePointsitepoint.com18 min