PHP 8 Attribute usage in 2023

PHP 8 attributes in 2023 PHP 8 introduced the attributes, in lieu of the phpdoc comments. They may be added to classes, methods, functions, parameters, properties and class constants and provide a PHP-way to write custom configurations. This is a way to provide contextual information inside the code, and make it available to the PHP […]

PHP extended classes

PHP extended classes Recently, I discovered that Datetime::createFromImmutable is now returning a static type : it returns an object of the type that called the method. This is only useful when the class has been extended by another class. This means that the Datetime class is extended enough for PHP to acknowledge it and adapts […]

14 PHP arguments that are not enough used

14 PHP arguments that are not enough used PHP has a few thousands functions under its belt, and there are even more arguments. And just like for functions, some of those arguments are not often used, while they provide a useful extension to the original behavior of the function. To catchup with them, here are […]

Semantic typing

Semantic typing Semantic typing is an old practice, where the name of the parameter would also tell what its type is. It is typing, because a $string is supposed to be typed, and it is semantic, because only the human reader is actually using the meaning : PHP doesn’t really care. The interesting part is […]

Unpacked, named and array of positional arguments are in a call…

mixed sorts of pumpkins

Unpacked, named and positional arguments are in a call… How to handle an array of positional arguments in PHP? Argument spread is the three dots operator, when used with arguments. Its primary usage is simple : it stands in front of a variable, and turns an array into a list of arguments. Recently, while checking […]

The three nothings of PHP

The three nothings of PHP Mathematicians have the concept of infinity, which represents something that cannot be topped. Strangely enough, infinities come in different sizes : some infinities are larger than others. That sounds quite paradoxical, yet somewhat understandable. And yet, there are no less than three nothings in PHP. On the other hand, PHPians, […]

Let’s make PHP more abstract

abstract

Let’s make PHP more abstract abstract is a conception keyword. It is decided during the conception phase that some classes and some methods uses the abstract keyword. Later, that keyword might disappear as needed, yet abstract never appears sponteanously. Nobody decides abstraction late in the coding phase. That seems to be a lack of practise […]