Initial PHP 5.5 support in PhpStorm
With the Early Access Program for PhpStorm 7, we’ve added initial support for PHP 5.5. When working in a project making use of the new PHP 5.5 language constructs, we can switch to the PHP 5.5 language level in PhpStorm and get full code completion and syntax checking support from the IDE.
Let’s have a look at these new language features!
Generators provide an easy and readable way for implementing iterators. Take a foreach: the iteration will be run for every value that was returned with the new yield keyword.
The following class can run a closure on every element of an array and “yields” the mapped value:
Some additional examples are available on the RFC page.
The finally keyword allows for cleaning up after an exception has been thrown. For example, when using a database connection we may end up with an Exception thrown by a called function. Using the finally keyword, we can gracefully close this connection regardless of the fact an exception occured or not.
Using list in foreach
A nice and handy new feature in PHP 5.5 is the ability to use list() in a foreach loop. Take the following code snippet:
Using PHP 5.5 we are able to transform each array entry into a list of variables which we can use in our code. Additionally, PhpStorm provides syntax highlighting as well as code completion!
Class name resolution as scalar
Reflection is great, and being able to instantiate a class from a string variable is even better. But why is that we always tend to make typos in strings… Using the ClassName::class syntax, we can get the class name as a string with full IDE support.
A number of other enhancements for PHP 5.5 language features have been added. PhpStorm now supports empty() and isset() on expressions. It can even resolve const array/string dereferencing, like for instance providing the output of str_repeat(“foobar”, 3)”).
Develop with pleasure!
– JetBrains PhpStorm Team
Subscribe to Blog updates
PhpStorm 2024.1 Early Access Program Is Now Open
This EAP build brings support for PHPUnit 11, improvements for the Pest test framework, and more.
PhpStorm 2023.3 Is Now Available
Explore the new features in PhpStorm 2023.3: support for PHP 8.3, the Pest test framework, improvements for Symfony projects and AI Assistant.
PhpStorm 2023.3 RC
PhpStorm 2023.3 Release Candidate bundles the Pest plugin into PhpStorm, so you'll now be able to enjoy it out of the box.