Exakat 0.10.8
Exakat 0.10.8 (King of spiritual touch) is here. This week, we worked on speed improvement with a simple trick: replace an array by a class. Arrays were the usual structure for data set with a lot of empty slots, but classes are indeed better. Then, we ran into a lesser-known PHP features: the binary strings from PHP 6. Indeed, PHP 6 never became a reality, but it has legacy in the current versions. PHP 7.2, Slim and Zend Framework 3 received new analysis. Read to learn more!
Support for the u string operator
Back in the days of pre-PHP 6, an new operator was introduced : u. It is also known as the (binary) operator, and works like this :
<?php $a = u' a string'; $b = ( binary ) 'another string'; ?>
The two operators were introduced for forward compatibility, preparing code to be compatible with PHP 6. The latter died, but the operators are still here, scanned and ignored. There was a RFC ‘binary string deprecation‘ to remove them. Eventually, it was declined, due to impact on the phar extension.
This notation has never been encountered by Exakat, even after checking half a billion tokens. It did mess with the string delimiter detection, and it is now supported.
Loading speed up
While searching for a way to speed up the loading phase of Exakat, we ran into another tweet from Nikita Popov . It shows that classes are getting faster and leaner compared to arrays. Since the loading phase makes heavy usage of arrays to describe tokens, it seemed an promising idea. The refactoring lead to several changes in the code, which is the subject of an upcoming post. The results are in : the refactor yields a 10% acceleration and 50% memory usage reduction.
30 Zend Framework 3 components audited
Exakat now processes 30 components of the Zend framework 3 during its audits. Feed Exakat with ZF3 code (versions 2.5 and later), and it provides the full table of compatibility, version by version, component by component : zend-dom, zend-di, zend-console, etc.. This is so helpful to review the composer.json and keep up to date. More to come next week.
Slim framework route inventory
Slim Framework presents its first inventory : the inventory of defined routes. Inventories are one kind of analysis. They are the collection of all values used in the code, and presented as a list. Here, they are the routes defined in the code. Routes may be scattered across several files or conditionally loaded, leading to a fragmented reading. The route inventory makes them available in one place, and easy to review.
‘No echo in callable route’ for Slim
At the same time, ‘No echo in callable route’ is a new analysis. Slim framework is moving toward a full PSR-7 adoption : with this approach, the response object must be returned by the route callable. At the moment, using echo in the route callable works, as the content is added to the outgoing stream. But this approach tends to short-circuit the PSR-7, and hides the possibility to set correctly HTTP response code, leading to confusion.
‘No echo in callable route’ is a preparation for Slim 4.
Happy PHP code reviews
Exakat 0.10.8 covers PHP better than ever. We’ll show more features about Zend Framework reviews during the Zend Days 2017 in Paris, on April 13th. Feel free to join us, for an afternoon of high level PHP.
We are looking for Slim and Zend Framework 3 open source software, so we can test exakat on them. Please, send them on twitter, to @exakat, for review.
All the 300+ analyzers are presented in the docs, including the classic ‘Timestamp difference‘. Download Exakat on exakat.io, upgrade it with ‘exakat.phar upgrade -u’ and like us on github : https://github.com/exakat/exakat.