Features Releases

New Inspections and Quick Fixes in PhpStorm 2017.1

PhpStorm 2017.1 brings the usual improvements to inspections and quick fixes, let’s take a brief look at what was introduced.

PHP 7 deprecated the old PHP 4 style class constructors, where the name of the constructor method was the same as the class name. With these constructors being removed entirely in PHP 8, PhpStorm 2017.1 includes an inspection that will warn you if you’re using the old style constructor, along with a quick fix to correct the problem for you.

constructor-quick-fix

If you have a legacy codebase that uses this frequently, don’t forget that like any inspection, you can run this across your entire codebase and fix everything in one go by using Code | Run inspection by name… and then selecting Old style constructor usage.

When using an anonymous function I often forget to pass in any variables from outside the scope of the closure using the `use` keyword. While PhpStorm has always warned you of this, the new quick fix will solve the problem for you by prompting you to Add to closure ‘use’ constructquickfix-use

Lastly, when using the Add field or Add method quick fix to generate properties or methods of a class, PhpStorm will now generate the visibility using the most suitable access modifier (`private`, `protected` or `public`), and will allow you to overtype a different modifier if the generated one isn’t suitable.

overtype-v2

– Gary & The PhpStorm Team

 

image description