Mastering the (array) Cast Operator in PHP: A Comprehensive Guide PHP provides various tools and features to manipulate data efficiently. One such feature is the (array) cast operator, which transform data into an array. In this blog post, we are mastering the (array)cast operator in PHP, focusing on its applications with simple scalars, objects, arrays, […]
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 […]
Remove static variables One discreet update of PHP 8.1 is the upgrade of PHP static variables behavior in classes : Static variables in methods inheritance. Let’s review what are static variables in PHP, why they were problematic so far, and strategies to upgrade the code to remove this problem. PHP static variables While static properties […]
PHP Advent calendar With PHP 7.2 out of the oven, literally yesterday, and the final month of the year starting, it is time for a PHP advent calendar. Every day until the 25th of December, we’ll reveal a new smelly treat. Yes, smelly treat, like a code smell. Common anti-patterns in PHP code leads to […]
Exakat 0.12.4 review Exakat 0.12.4 for your pleasure. Exakat has progressed on multiples fronts last week : PHP 7.2 is now fully covered for migration. Exakat has now a new favorite : and / &&; a new report for the ‘object’ keyword, a suggestion to reduce isset() calls, and a magic error with arrays. Finally, […]
I’m sure you have experienced the ever-green art of steganography : a bug hiding in plain sight in your code. Yet, this is an invisible bug. The code compiles, IDE reports nothing wrong, unit tests are a failing everywhere, and you keep reading the sources without finding anything. And suddenly, it strikes you : YES, […]
PHP likes to sort. Of course, there is sort(), ksort() and all the cousins. But, PHP actually sorts too much. My first encounter with the problem is the infamous array_unique(). Now, this is also affecting glob() and scandir(). I’m looking for others. Until then, check your code. array_unique() is also sorting array_unique() collects distinct values […]