PhpStorm 2020.2 EAP #7
Learn more about the brand-new Extract class refactoring, unassigned typed property inspection, and customizing generated getters/setters.
New refactoring: Extract class
Classes always start out neat and tidy. They do their job and do not interfere with other classes. Over time, however, new methods and fields may be added here and there. As a result, some classes get cluttered and burdened with a lot of additional responsibilities.
To fix this, at some point it can be useful to move method from a bloated class to a new one.
With the new Extract class refactoring it’s as easy as selecting the part of the code you’d like to move and pressing Ctrl+T -> Extract class. PhpStorm will prompt you to enter a name for the new class and choose a namespace.
You can extract methods and properties in this way.
The refactoring will create a new file, inject an instance of the class into the old one via a constructor, and replace the selected code with a new method call.
It is also possible to extract functions to a new class.
Learn more about refactorings in PhpStorm on this help page.
New inspection: Typed property might be unassigned
If a typed property does not have a default value, the property is considered to be uninitialized. Reading uninitialized properties will generate a
__get() is defined).
PhpStorm 2020.2 detects uninitialized properties and highlights code that attempts to read them.
Customizing generated getters and setters
You can adjust the naming and choose between
You can also define the order the generated getters and setters should go in.
Both options are available under Preferences(Settings) | Editor | Code Style | PHP on Code Generation tab.
The full list of changes in this build is available in the release notes.
- Important! PhpStorm EAP builds are not fully tested and may be unstable.
- You can install an EAP build side by side with a stable PhpStorm version to try out the latest features.
- EAP builds are free to use but expire 30 days after the build date.
Please report any problems you find to our issue tracker, or by commenting on this post!
Your JetBrains PhpStorm team
The Drive to Develop
Subscribe to Blog updates
Thanks, we've got you!
PhpStorm 2023.2 Beta
In this build, we’ve added new inspections for PHP assertions and revised the integration with third-party quality tools.
PhpStorm 2023.2 EAP #6
This build brings improvements for generating PHPDocs, support for Laravel Pint, a single point of access to all PHP framework plugins, and much more!
AI Features in PhpStorm: PhpStorm 2023.2 EAP #5
The next EAP build for PhpStorm 2023.2 is now available, and it’s an exciting one! It is the first build to include features leveraging the enormous potential of generative AI and large language models (LLMs). Our Early Access Program (EAP) allows you to try new features from the upcoming PhpStor…
PhpStorm 2023.2 EAP #4
This build includes a bunch of usability improvements, such as abilities to pin Run configurations and sort files by modification time in the Project view. The EAP allows you to try new features from the upcoming PhpStorm version, 2023.2. EAP builds are free to use and you can install them side b…