Collateral behavior changes with PHP 8.0 switch()

Collateral behavior changes with PHP 8.0 switch() PHP 8.0 introduced a modernisation of the comparison between integers and strings. It changes the result of comparisons when a string is compared to an integer. Obviously, it includes comparing 0 and ” (empty string). This means that some comparisons were true in PHP 7, and are not […]

array_filter() versus Loop Condition Checks

array_filter() versus Loop Condition Checks Optimizing your code for performance is important, especially when dealing with large arrays or complex data structures. One common dilemma developers face is whether to use array_filter() to preprocess an array before a loop or to check a condition inside the loop and skipping the unwanted values. In this blog […]

Well-Structured Switch Command in PHP

Ensuring a Well-Structured Switch Command in PHP In PHP, the switch statement is a powerful tool for controlling program flow, especially when dealing with multiple conditional branches. However, achieving a clean and efficient switch has its own snags. This post explores essential tips and practices for checking the quality of a ‘switch’ command to ensure […]

New PHP error messages in PHP 8.3

WIndow onto PHP 8.2

New PHP errors messages in PHP 8.3 The upcoming PHP 8.3 is bringing some new errors messages. They originate from new features, deprecated ones, and extra checks on the source code. Let’s review the new PHP error messages in PHP 8.3 and get our code ready for November 2023. Previous review New error messages in […]

The Clean Code Solution for Your DevOps Workflow in PHP

devops php

Introduction In today’s fast-paced software development landscape, DevOps has become a vital part of ensuring efficient and seamless delivery of applications. While DevOps practices enable collaboration and automation between development and operations teams, maintaining clean and high-quality code remains a challenge. This is especially true for PHP developers, who often encounter difficulties in identifying code […]

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 […]