Exakat 1.1.8 review

After last week double edition’s review, we needed some quiet time. This week, we upgraded the ‘Randomly sorted arrays’, added two new extensions and closed two nasty bugs. So, here it is, your moment to read the Exakat 1.1.8 review.

Support for IBM Db2 and Leveldb

ext/ibm_db2 is an interface to IBM DB2 Universal Database, IBM Cloudscape, and Apache Derby databases. It is a family of SQL database, implemented by IBM, and also outsource as an apachesubproject.

ext/leveldb is an interface for using Google Leveldb. It’s a key-value storage library, that support ordered mapping.

Exakat now supports 155 extensions. Extensions are modules that can be added to PHP, that extends its capabilities. They often exposes external libraries in PHP, by providing functions, classes, constants or other structures.

Extension library is important, so exakat can provide recommendations for PHP compilation, PHP directives or avoid reporting unknown functions.

Check the list of extensions, and help us by mentioning any missing one that are important to you.

Randomly sorted arrays

‘Randomly sorted arrays’ were introduced last year, in Exakat 0.11.3. The concept is to report literal arrays, that only differ from the sorting order of its elements.


// some variable initializations
$cities = array(‘Paris’, ‘Montreal’, ‘Guangzhou’, ‘The Hague’);

// Another part of the code, probably another file
display_cities(array(‘Guangzhou’, ‘Montreal’, ‘Paris’, ‘The Hague’));

Quite often, especially with literal arrays, the same arrays are used at different point of the code, in order to initialize a variable. When the arrays have arbitrary sorting, but identical elements, it is more difficult to remember them across the code.

Eventually, once the arrays are sorted identically, it will appear that both are the same constant, but used at different point in the code. They were build by experience and testing strategies, but in the end, they do represent the same value. They should then be turned into a constant.

Reducing the data load when reading the code is a nice to have feature. It also bring consistency to the code.

UML diagrams

Exakat offers two different reports that build UML class diagram.

php exakat.phar report -p orientdb -format Uml
php exakat.phar report -p orientdb -format Plantuml

The result is stored in the projects// folder: + uml.dot, for a graphviz class diagram. + [exakat.puml], for a Plantuml diagram.

The diagram include all classes, methods, properties and constants. It also features the relation between the classes, and the namespaces delimitations.

Be careful when using them on large applications, as the resulting diagram may exceed your larger screen, by far.

Happy PHP code reviews

Exakat 1.1.8 includes two nasty bugs from the tokenizer layer: this is the layer that understand the PHP code, and build the graph database that powers the audit queries. That makes Exakat 1.1.8 the most stable Exakat ever.

All the 344 analyzers are presented in the docs, including the gentle Join file: avoid using join or implode on the file() function to read a whole file: file_get_contents() can do it faster and better. It’s a common PHP bug, rating at 15%, but it makes the code really cleaner.

Download Exakat on exakat.io, install it with Docker, upgrade it with ‘exakat.phar upgrade -u’ and like us on github: https://github.com/exakat/exakat.