New Code Style Options in PhpStorm 2017.1
PhpStorm 2017.1 brings a smorgasbord of new code style settings so you can get your code looking just how you like it.
We all know that having your code formatted the right way is important – after all, the Tabs vs Spaces debate has divided many communities (it’s spaces for what it’s worth). PhpStorm 2017.1 gives you some new code style options so you can get your code looking just so. Most of these changes were requested by users on our issue tracker, YouTrack.
We’ve added a new option in code styles which will remove the `()` from a `new` call when you don’t pass any constructor arguments. You can find the setting under Settings | Code Style | PHP | Wrapping and Braces | Function/constructor call arguments | Place ‘()’ for constructor.
To make sure you consistently use `elseif` or `else if` (whichever you prefer), you can configure PhpStorm to format `elseif` to `else if` (or vice versa) using Code Style | PHP | Other | Convert else if/elseif to: and then selecting the format you want to use.
Something that’s been annoying me slightly is PhpStorm not letting me enforce a new line between `<?php` and the namespace declaration. You can find the setting under Code Style | PHP | Blank Lines | Before namespace. In writing this very blog post we also realised that this won’t solve the problem for everyone because of PHP 7’s `declare(strict_types=1)` declaration being the first line in a file – we’ve opened a ticket for that so look out for it in the future.
And speaking about PHP 7, there’s a new feature to enforce spaces around the equals sign in a `declare(strict_types=1)` declaration. The proposed PSR-12 standard does say that these declarations should have no whitespace in them, but if your own coding style differs, you can enforce the spaces using Code Style | PHP | Spaces | Around Operators | Assignment in declare statement.
We’re trying to make sure your code style looks exactly how you want it to, so let us know what you think – or if we’re missing anything.
– Gary & The PhpStorm Team
Subscribe to Blog updates
Thanks, we've got you!
Qodana Clone Finder: Early Access Program
In December 2020, we announced the EAP for Qodana, which is rapidly evolving into a comprehensive platform that allows companies to perform multi-level evaluations of the quality of code they own, contract, or purchase. Qodana helps you detect bugs without relying on an IDE, either on a local machi…
PhpStorm 2020.2 EAP #3
The Early Access Program for PhpStorm 2020.2 is in full swing and today we’ve got the third build of the 2020.2 EAP for you. In this blog post, you can read about improvements for Git installed in WSL2 and Search Everywhere. Download PhpStorm 2020.2 EAP (more…)…
PhpStorm 2019.3.3 Preview
We’ve just rolled out a preview for the third minor update for PhpStorm 2019.3. Please give the PhpStorm 2019.3.3 Preview build 193.6494.5 a try and share your feedback with us. (more…)…
How to Upgrade to PHP 7.4 with PhpStorm
Check out our fresh video with a few nice tips and tricks on how to update your codebase to PHP 7.4. It combines materials from the PhpStorm 2019.2 and PhpStorm 2019.3 releases, with a few cool bonuses to boot. Nikita drew our attention to the fact that setters are slower than assigning prop…