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

PDFF : PHP Document File Format details

PDFF : PHP Document File Format details In the first episode, we have presented the origin of the PDFF: how it emerges to be a convenient format to describe PHP component, with a good level of details, some versioning and a dual-readability human/machine. In this second episode, we’ll introduce the format and the content 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 […]

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

Literal candidates for constants

Literal candidates for constants Literals are hard coded values in the source. Once they are written, they can’t be changed without altering the source code. This is always fine, initially, while building the first implementations. Yet, later, it may arise that such literal have to be managed from different points of the code. This is […]

6 unicity traps that sideline PHP code

Thorny issues

6 unicity traps that sideline PHP code Sometimes, code is being ignored by PHP : code is painstakingly written but never gets executed. How is that even possible? May be, because it was not so painstakingly coded. Indeed, there are some PHP coding structures which natively and silently overwrites or ignore code. This leads to […]