6 new PHP analyzers in Exakat 0.10.3 Exakat 0.10.3 shipped with 6 new PHP analyzers : see the changelog. Here is a short presentation of them : Use array_column() array_column() is a little known PHP native function. Read about the story : Ben Rasmey tells it himself : https://benramsey.com/projects/array-column/. When you plan to contribute to the PHP code with a new […]
There are always several ways to do the same things in PHP. Some of them are so close that one even wonder which one to choose. In fact, if they are interchangeable, why even choose ? Here is a list of seven syntax you can choose in PHP, freely. The choice relies first on technical ground, […]
This is the third part of our series about last features in PHP 7.1. See ‘Upcoming features in PHP 7.1 (part a)‘ and ‘More upcoming features in PHP 7.1 (part b)‘. PHP 7.1 is now RC1 since our last article, so better dive into the code fast. We are now presenting the last batch of […]
Const behavior in PHP 7 I always thought const behavior to be like class. Well, of course, beside the obvious differences, const and class were compile-time structures. They are complete at compilation, and could be op-coded and cached. This is unlike the slower define() function (for const), which requires PHP execution to be creating constants. This […]
Static analysis helps migrate to PHP 7 Static analysis is the analyze of PHP code without running it. The traditional way to do this is to read the code and understand it. The modern way is to use a static analysis software. Including static analysis as a regular sanity check in your coding process raises […]
7 new PHP static analysis No less than 7 new analyzers for Exakat, since last week version. Here is a quick review, as they are both varied and interesting. Identical conditions Identical conditions spots members of an complex logical expression that are identical. When several conditions are chained, it happens that some of the conditions […]
PHP bug-fixes help your code Ever wondered which PHP bug-fixes help your code? What is the actual impact of a PHP minor version on your code ? Every month, or more, PHP provides a new version, covering about thirty bugs and various upgrades. Sometimes, features request make it to a version. Still, who has time to review […]
Confusing variable names Did you ever meet that awful situation, where you try to understand why the SQL query fails, until you realize that $res and $req are simply too confusing ? There are confusing variable names, notably those that are one letter close from each other. Problems ranges from $data and $date in the same […]
When testing the exakat static analysis engine, we need to run it on real code : even better, use the largest PHP code base available. Open Source projects are a real blessing there, since they come in different shapes and stripes. Some projects dates back from PHP 3 and evolved until now, some are directly […]
Heredoc PHP Heredoc PHP 语法是PHP里面写入一大块的文字的方式,不是传统的使用单引号,双引号字符串分隔符。他依赖于 <<< 和一个用来表示这个字符串的结束的标示符。 <?php $string = <<<STRING $x elephpants STRING ; ?> Heredoc 还有一个Nowdoc替代, 它是Heredo的“单引号版本”。 它实际上在标示符定义上就是用了单引号,并且不会替换它里面的变量值。 <?php $string = <<<‘STRING’ $x elephpants STRING ; ?> Nowdoc 很少被使用。在Heredoc/Nowdoc的使用中,仅仅只有3%使用Nowdoc的语法。这个可能是因为Nowdoc最近才被加到语言中(PHP 5.3),又或者是典型的担心未来可能会要使用字符串中的变量。