Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster
by Vinnl on Sunday July 30, 2017 @08:02AM
(#14885579)
Does PHP have linters or something that force you to use the practices you described? I find in Javascript that works pretty well to restrict the language to a sane subset.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster
by _cereal on Sunday July 30, 2017 @08:31AM
(#14885662)
You can use phpmd: https://phpmd.org/ or phpcs: http://cs.sensiolabs.org/
Further, avoid == completely, pass the strict argument to functions that do comparison like in_array(). You don't want https://3v4l.org/mcpi7 to happen. You want https://3v4l.org/Yo6tI instead.
Your functions in 7.1 finally can typehint for iterable (array or Traversable object) although the array_* functions still only accept arrays. There are nice little libraries papering that over and installing libraries is easier thanks to composer.
PhpStorm gives you a fantastic IDE. The language is still ridiculously easy to deploy thanks to a zero share model.
Basically: most of the landmines can be cordoned off with putting declare(strict_types=1) on top of your files or bridged over by libraries like nikic/iter. A few are left but they are easy to avoid.