What are interfaces ? Interfaces, in PHP as in all other OOP languages, specify what methods must be implemented in a class. Interfaces gives names and arguments counts, but no content : the actual code will be provided by the class. <?php interface movable { function move($distance) ; } class human implements movable { public function move($distance) […]
Static audit are a great tool to help with code quality. Audits means that the code being written is reviewed by an external auditor. Human auditors are usually the best, though they are not always available. Static auditing provides an automated way to review the code, and receive feedback on it. It checks every file […]
Caching with PHP static variables Whenever a methodcall is used repeatedly in a piece of code, you may wonder if it wouldn’t be more efficient to cache the value locally, avoid the functioncall altogether and speed up the process. Let us see how we can cache with PHP static variables. Functioncalls are rather intensive : PHP […]
Clear PHP reaches 100 rules Last week, we published the 100th rule in clear PHP. They represent recommendations to write clear PHP code. Such recommendations has various effect : avoid common pitfalls (No Unchecked Resources) prepare code for recent versions (Use Smart Autoload) complete some check that the engine doesn’t do ( No Switch With […]
One question that keeps coming back while collecting the rules for clearPHP is the domain of the rule. Coding convention and conception rules covered different domains and seldom overlay each other. ClearPHP rules aim a being close to the language and its tricks, away from semantics and architecture. How come ? Coding conventions Coding conventions are […]
array_unique function is a native function that will extract distinct values in an array. array_count_values is also a native function that will extract distinct values in an array, and count the number of occurrences. array_count_values actually does a lot more work than array_unique by providing a count of the distinct values, on top of finding […]
When reviewing code, the first step is to know what has to be checked, and what will be considered for fixing. There are lots of considerations to be taken into account, and it is often difficult to both agree on which code smells to check, and to collect all of them in the same time. […]
« We don’t have time for reviewing code » is both the most often and most reasonable excuse anyone may have. Think about it, features are already late : they are not being coded as you read this post. Then, when it’s done, there will be the other features that are stacking up while the current features […]
I’m already busy preparing for the international PHP conference, in Munchen, Germany. I’m giving two talks : on about PHP 5.6 and the second about static audits. Besides, being an impressive conference, I’ll be happy to visit one of my first conferences ever. Preparing for the next PHP Version Monday, October 27, 2014 […]
I’ll be giving a talk ‘automated PHP code audits‘ to the 010php user group, in Rotterdam. “Even nowadays, PHP code is mostly manually audited. Expert pore over actual code, in search for bugs or code smells. Actually, it is possible to have PHP do this work itself ! Strengthened with the internal Tokenizer, bolstered by […]