When Generators Actually Makes Sense

When Generators Actually Makes Sense Generators are one of PHP 8 best-loved features. Sprinkle a yield into a function and suddenly you’re processing millions of rows with constant memory. At least, that’s the promise. The reality is more nuanced: lazy evaluation only pays off when the underlying data source can produce records incrementally. If the […]

Method Fossilisation in 2026

Method Fossilisation in 2026 [This is an updated version of this article ‘Method fossilisation’] Method fossilisation happens when methods get harder to update, due to sprawling overwriting. It is a process, more than a final state. In particular, it happens to methods when the signature is shared across multiple classes, via inheritance and interfaces. As […]

Using a vector database with PHP

Using a vector database with PHP

Using a vector database with PHP PHP has roughly 80 array functions: eight – zero. array_map, array_walk, array_reduce,array_filter, array_each… wait, that last one was deprecated and removed in PHP 7.2. Or not? And some new functions came up in PHP 8.5, last november. The real problem is discoverability. You know the task, “find the first […]

PHP Types and Tests: Not Rivals, Just Working Different Shifts

Types and tests

Types and Tests: Not Rivals, Just Working Different Shifts A common source of confusion in PHP development is the relationship between static analysis and unit testing. Are they redundant? Does adding types mean fewer tests? Does a comprehensive test suite make a type checker unnecessary? No to all three. They cover different grounds. The interesting […]

php-typos: a fast spellchecker for PHP codebases (Tool Review)

php-typos: A Fast Spellchecker for PHP Codebases (Tool Review) There’s a particular kind of embarrassment reserved for the typo that ships to production. A recievePayment() method. A config key spelled treshold. A comment that confidently explains the “lenght” of an array. None of it breaks anything, all of it makes the codebase look a little […]

Five Ways to Write a PHP Type

Five Ways to Write a PHP Type PHP’s type system is grown up. PHP 7.0 started the ball rolling with parameter and return types. PHP 7.4 added property types. PHP 8.3 added the class constant types, though we’ll omit this for now. PHP has quietly accumulated five distinct syntaxes where you can write something that […]

PHP and AI: What Actually Exists at the Language Level

Elephpant and AI

PHP and AI: What Actually Exists at the Language Level PHP runs about three-quarters of the web, and yet whenever AI comes up in conversation, PHP is the friend who wasn’t invited to the party. The received wisdom is that AI belongs to Python and that PHP developers are limited to politely calling someone else’s […]

Filtering Empty Arrays Before array_merge()?

Filtering Empty Arrays Before array_merge()? Picture this: you’re looping through something, calling a function each time. It always returns an array, and, sometimes it gives back an empty array. At the end, all these array will be array_merge(…$results) together. The first point is to avoid array_merge() inside the loop, as it is one of the […]