News for hackers. Stuff that matters.
Re:Benchmarks of PHP 7.2 Beta: PHP Is Still Getting Faster by chx on Sunday July 30, 2017 @02:36AM (#14884709)
The biggest grievances stem from PHP wanting to please you and convert things from one type to another even when it really, really shouldn't. Adding variadics in 5.6, return and scalar types in PHP 7 tunes down this sort of crazy. Not fully, though. String comparison is still broken -- use strcmp() and be happy. Using anything else is dark and full of terrors. Well, at least it's not transitive https://3v4l.org/goSYX

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.

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/