PHP is one of the most used languages at Liip, but also on the internet at large. An update is always a big thing, and a larger one happened when PHP 7 was released on the 3rd of December 2015. With PHP 7 now 2 years old, and version 7.1 slightly older than a year (1st December 2016) and also 7.2 just released on the 30th of November 2017, I found it a good time to have a look back at what PHP 7 has brought to daily work at Liip for my colleagues and me.
I started coding with PHP before the year 2000 when PHP 3 was still a thing and files ended in .php3 as well. With PHP 4 I finally had classes available to me, something I was familiar with from early Visual Basic days. Though it was a "special" implementation, it did the job well enough. PHP 5 gave real classes into the mix, later adding traits and many more things that today I can't work without in a modern PHP application. The version 5 of the language served a long while as the pinnacle but also spawned a lot of side shows, like HHVM and lots of optimization tools. Already complex applications got even more complex and sometimes more fragile.
Thankfully PHP 7 arrived in late 2015. Its speed improvements came down from the improved Zend Engine 3, which forms the heart of PHP. The potential pitfalls of HHVM incompatibilities no longer plagued me and I still got faster applications, nice.
One of the bigger changes that first took me a bit to get used to and now are second nature, are type hints, of common scalars. Before PHP 7, it was only possible to use classes (and interfaces) as type hints, alongside arrays (though nothing more precise, such as a vector type or something like that). Where I had to write a lot of checks to make sure that the parameter a function got is truly what I want, now the type hint makes sure I get an integer or string, making my code cleaner, easier to understand and less error prone.
Many times already scalar type hints have shown me mistakes and bugs before I even opened a merge request for my code changes. It has also helped with a mindset of being more precise in many instances, making testing more effective and easier to do overall.
And of course there are return type hints too now. With 7.1 improving that even more, I can specify what exactly a function returns. What I had to document in extra blocks before, the function now explains often all just by its signature. I know that I can trust a function to return only one thing and again a lot of checking code goes away.
PHP 7 has made my daily life as a developer better, brought more performance to my customers and makes me hopeful for the even brighter future of the language as a whole.
Thank you PHP and happy birthday!