Weekly report for the week from June 13th, 2022 to Jun 19th, 2022

weekly report 28

Weekly report for the week from 13-06-2022 to 19-06-2022 These are the focus rules for this week : Unthrown Exception Undefined static:: Or self:: Use Constant Reuse Existing Variable Empty Classes       Weekly reports are a list of 5 reviews, shared across the community of Exakat users. They represent a reasonable amount of […]

When does PHP check for Fatal Error?

Study hard that code

Late, later and latest PHP checks PHP applies various checks when processing source code. When those checks fail, they might generate a Fatal errorand stop execution. They are the bane of production servers, and every PHP developper tries to avoid them as much as possible (unlike static code analyser authors which try to generate them). […]

Reviewing Property Declaration In PHP

Reviewing Property Declaration In PHP Properties are a foundation part of classes. They are declared with their visibility, and their name. Then, they might be augmented with a default value, a type (even several), and may be also options like static or readonly. With hierarchies and large families of classes, we shall start reviewing property […]

The very useful variadic argument

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

Adoption of PHP 8 attributes in 2022

Adoption of PHP 8 attributes in 2022 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 great addition for the static analysis tools, and PHP in general. 18 months […]

Move that foreach() inside the method

loops goes inside

Move that foreach() inside the method Several PHP functions work with single or multiple values. For example, array_merge(), which merges several arrays into one. Or, isset(), which checks simultaneously the existence of several variables. str_replace() and preg_replace_callback() also come to mind. This is a good place to move that foreach() inside the method. This approach […]