

Insights into mock objects will work even for partial mocks. PhpStorm will properly detect mocked interfaces for a given class and will be able to make suggestions based on the interface’s definition. PhpStorm will detect when you’re trying to use a protected method and will offer to add shouldAllowMockingProtectedMethods() for you. PhpStorm will suggest the right class name for you, autocomplete it, and offer the same insights into the mock object that you would see if you used the real class name. It’s also possible to pass class names by string in the mock() function. Both the mocked object’s methods and properties are available in the autocompletion menu, along with the functionality that Mockery provides through its mock objects. Proper autocompletion is now available for mocked objects. We’ve added support for autocompletion and code insights in many places, as well as some useful inspections. We’ve been working on implementing support for Mockery, one of the most popular mocking frameworks for unit testing in PHP. Either go to Run | Edit Configurations or choose Edit Configurations from the Actions menu: Since Rector is a run configuration, you have the option to configure it, as well. You can then review changes in PhpStorm, select individual files and folders, and finally apply all of the selected changes. When Rector is done scanning, PhpStorm will give you a list of files that it wants to change. Note that you can also run Rector straight from the rector.php config file with a handy gutter icon: PhpStorm can do this automatically for you – simply right-click the folder you want Rector to fix and then select Run | Rector: Next, you should create a new run configuration specifically for Rector. In order to use PhpStorm’s Rector support, you first need to install Rector and configure it. It’s an amazing tool, and we’re happy to provide built-in support in PhpStorm for it. Rector helps you with automatic PHP upgrades and code refactorings in bulk. You can download PhpStorm 2022.2 here and read through this post to learn about all the new features and improvements inside. PhpStorm 2022.2 is a major update that brings support for Mockery and Rector, enhanced support for generics and enums, improvements to our debugger and HTTP client, and more.
