Tag Archives: PHP

Type the List: A Proposal to support type-casting in PHP’s list language construct

I wrote recently about some changes that I’d like to propose for list() in core PHP for version 8.3: namely that it should work with iterables as well with arrays, and that it should allow a variadic “argument” that would … Continue reading

Posted in PHP | Tagged , , , , | 2 Comments

Default the List: A Proposal to support default values in PHP’s list language construct

I wrote recently about some changes that I’d like to propose for list() in core PHP for version 8.3: namely that it should work with iterables as well with arrays, and that it should allow a variadic “argument” that would … Continue reading

Posted in PHP | Tagged , , , | 3 Comments

Splat the List: A Proposal to support Variadics in PHP’s list language construct

I was thinking recently about how useful PHP’s splat operator (…), also known as variadics or array packing/unpacking, can be. I’ve written about variadics before, here and here. Variadics are incredibly powerful and useful; but there are still some limitations … Continue reading

Posted in PHP | Tagged , , , , , | 3 Comments

List-o-mania

The list() language construct is one of the most powerful constructs in PHP, allowing you to assign one or more elements from an array to specific named variables in a single step; but it may not work in quite the … Continue reading

Posted in PHP | Tagged , | 4 Comments

PHP 8.2 – The Release of Deprecations

The release date for PHP 8.2 has been announced, with General Availability set for the 24th November 2022; the release managers have been elected with Ben Ramsey (@ramsey) as the “veteran” supporting Pierrick Charron (@adoyy) and Sergey Panteleev (@s_panteleev) as … Continue reading

Posted in PHP | Tagged , , , | Leave a comment

The Wonderful World of Callbacks

Anybody that has read any of my previous blog posts or looked at my code samples before should know that I’m a big fan of using callbacks. Whether it’s simply using callbacks with those standard functions that accept them as … Continue reading

Posted in PHP | Tagged , , , , , | 1 Comment

ReadOnly Gotchas – A few more limitations with PHP 8.1 ReadOnly Properties

Last month I wrote about the new readonly properties in PHP 8.1, and the difficulties if you want to clone an object that uses them (together with a couple of potential solutions to that problem). The inability to clone an … Continue reading

Posted in PHP | Tagged , , | 2 Comments

Constant Constants. Finally! (On the inconstancy of constants)

One of the many new features of PHP 8.1 is the ability to declare class constants as final, so that they can no longer be overridden in child classes. The same applies when constants are defined as final in an … Continue reading

Posted in PHP | Tagged , , , , | 1 Comment

The Tears of a Clone

On the face of it, the new readonly properties in PHP 8.1 seem really useful for Value Objects and Data Transfer Objects: both should be immutable; setting property values should always be handled in the constructor, so no setters; and … Continue reading

Posted in PHP | Tagged , , , | 2 Comments

Closure Binding for Unit testing of Private and Protected Methods

Some years ago, I wrote about using closure binding to access protected and private properties when unit testing an object, to verify internal state; and I created the SpyMaster library to simplify that task. One feature that I didn’t include … Continue reading

Posted in PHP | Tagged , , , , | Leave a comment