PhpStorm 2021.3

Adiciona suporte para PHP 8.1, melhor manuseio de genéricos em PHP e melhorias de implantação.
Dezembro 6, 2021
Nova versão

Recursos

  • PHP 8.1
    • A new version of the interpreter has just been released.
    • Enums - Support for enums was introduced in PhpStorm 2021.2, offering code suggestions and validation to protect you from using them incorrectly. An enum in PHP contains a set of cases, can have methods, and can be used as a type hint. In all of these cases, PhpStorm now provides error highlighting and proper suggestions to save you time.
    • Readonly properties - Readonly properties are the properties that cannot be changed after initialization, that is, after a value is assigned to them. This release will help you make use of readonly properties in your code and make sure they are used correctly. A dedicated inspection will check that a readonly property is initialized only in the same scope where it’s declared, either the property declaration itself or in a class method. Since readonly properties must always be typed, PhpStorm will check if the type declaration is specified. A readonly property cannot have a default value, but you can initialize it in the constructor as a promoted property, so PhpStorm provides a quick-fix for this.
    • `new` operator in initializers - In PHP 8.1, you can use new expressions when initializing default parameters’ values, static variables, global constants, and attribute arguments. PhpStorm will now verify such usages and highlight invalid cases such as providing a new object as a class constant or property.
    • First-class callables - PHP 8.1 lets you get a reference to any function by means of the first-class callable syntax. Now, instead of writing $fn = Closure::fromCallable('strlen');, you can use a shorter $fn = strlen(...); form, and PhpStorm will provide you with an Alt+Enter quick-fix to convert your code to the new syntax.
    • Pure intersection types - PHP 8.1 brings intersection types, whose value must satisfy multiple type constraints instead of just a single one. PhpStorm will now provide code completion for these constructs and check that an intersection type is not combined with a union type. And if you have an intersection type specified as a PHPDoc annotation, PhpStorm will interpret it correctly, too.
    • New return type: `never` - PHP 8.1 introduces a never type for return values. If a function is declared with the never type, then it will not return a value and will either throw an exception or end the script’s execution (just like the die(), exit(), or trigger_error() functions do).
    • Final constants - In PHP 8.1 you can declare final class constants so that they cannot be overridden in child classes, and PhpStorm will verify such cases.
    • Deprecations:
      • Deprecated usage of Serializable interfaces - Instead of Serializable interfaces, it’s recommended to use the __serialize() and __unserialize() magic methods. In PHP 8.1, you can still use Serializable, but only if the implementing class uses both __serialize() and __unserialize(). This release highlights incorrect code and offers an Alt+Enter quick-fix for adding the magic methods.
      • Restricted GLOBALS usage - Using the $GLOBALS superglobal variable in PHP 8.1 is now restricted – it is not allowed to perform write or read/write operations on the $GLOBALS taken as a whole. PhpStorm will highlight such problematic usages.
  • Generics for PHP
    • Improved support for Doctrine Collections - PhpStorm brings support for the IteratorAggregate interface and iterating over Doctrine Collections now works out of the box.
    • Support for Laravel collections - In the upcoming Laravel release, the illuminate/collections package will support generics annotations. PhpStorm 2021.3 provides better code completion for such collections.
    • Inferring generic types from constructor - If there is a generic @template parameter in a constructor and you want to specify the type by passing an object as an argument, PhpStorm will now infer the correct type and provide code completion.
  • Refactorings
    • Move classes via drag and drop - Previously, to move a class and update its namespace, your only option was to use the move refactoring (F6) in the code editor. In this release, you can use drag and drop in the Project view instead. This way, the project structure would be visible during operation. And what's more, you can move several classes or entire folders using this technique, and PhpStorm will correctly update all the references.
    • Inline function or method - The Inline method refactoring lets you replace the calls to the method with the method’s content and delete the method itself. In this release, the refactoring received multiple improvements and will cover even more cases. For example, non-static methods, method chains, and arrow/anonymous functions passed as parameters are now supported.
    • Inline variable - The Inline variable refactoring lets you replace the references to a variable with the actual variable’s value. In this release, this refactoring supports inlining NOWDOC/HEREDOC variables and includes several usability enhancements. In addition, PhpStorm will now detect variables with a single usage and provide you with an Inline Variable quick-fix, which you can apply via Alt+Enter.
  • Deployment
    • Support for rsync - When using an SFTP server for deployment, you can enable rsync for uploading and downloading files and folders, which will significantly increase transfer speeds. The corresponding Use rsync for download/upload option is located in the Advanced section of the deployment server configuration. The path to the rsync executable can be configured under Settings/Preferences | Tools | Rsync. For Apple macOS and Linux, it should be available right away. For Microsoft Windows, it is recommended to use Cygwin and OpenSSH.
    • Retransmit files that failed to upload - This release lets you retransmit the files that failed to upload. In such cases, click the Retry link in the File Transfer tool window.
    • Proxy support for SSH connections - You can now specify an HTTP or SOCKS proxy server for your SSH configuration under Settings/Preferences | Tools | SSH Configurations. It’s also possible to use the global IDE-wide proxy.
    • Quickly switch default server for project - This release provides a new status bar widget that shows the current default server. When you need to deal with multiple environments, you can switch between them right from there without going to the settings.
  • HTTP Client
    • Binary responses in the HTTP client - The HTTP client can now detect images in responses and display previews of them in the response console.
    • Output redirection to custom file or directory in the HTTP client - In the HTTP client, it is now possible to redirect output to a custom file or directory.
      • You can use two operators for forced and soft redirects:
        • The >> operator always creates a new file, adding an -n suffix to the file name if the requested file name already exists.
        • The >>! operator rewrites the file if it already exists.
      • In addition to providing explicit file paths, you can now use new predefined variables: {{$projectRoot}} points to the project root folder and {{$historyFolder}} points to the requests history folder.
    • Support for HTTP request identifiers - You can now add request identifiers either as comments via @name or as text in the first separator (###). The IDE understands these identifiers and allows you to invoke requests by them from the Services tool window, as well as from the Run Configuration, Run Anything, and Search Everywhere dialogs.
  • User Experience
    • New Bookmarks tool window - In this release, the Favorites and Bookmarks functionality has been merged into one – Bookmarks. You can add a bookmark on a specific line, file, or folder by pressing F11. All the added bookmarks will be available in the unified Bookmarks tool window.
    • Source preview for Show Usages - The Show Usages dialog, which you can invoke by Ctrl+clicking a symbol, can now display the source code preview per found usage. To enable the preview, click the Icon of the toolbar button toolbar button.
  • VCS
    • Align Changes Highlighting - Added the new Align Changes Highlighting option to the Diff screen settings that can be found under the gear icon. This feature makes the Diff easier to read, especially when there are complex modifications, because it aligns the unchanged lines so that they are displayed next to each other. This helps you see the code that has been added or removed more clearly.
    • Checkout and Rebase onto Current for remote branches - The Checkout and Rebase onto Current action lets you check out the selected branch and rebase it on top of a branch that is currently checked out. This was only possible for local branches before, but in PhpStorm 2021.3, this action can be applied to remote branches as well.
    • New ‘Push All up to Here’ action - If you have several commits that are ready to be shipped while others are still work in progress, then you may want to push only the ones you are sure about. PhpStorm 2021.3 will let you push commits up to the one you have selected in the Log tab of the Git tool window. Select the necessary commit, right-click it and use the new Push All up to Here action.
    • Reorganized VCS settings - The Version Control page in Settings/Preferences has been streamlined for better usability and now lists all of the available settings. The Git node is now divided into sections that account for the most important processes: Commit, Push, and Update. A separate node for Directory mappings has been added. Since the background operations are now switched on by default, the Background node has been removed.
PHP 8.1 support

PhpStorm

IDE PHP com refatoração, preenchimento de código, análise de código em tempo real e orientação para produtividade de codificação.

PhpStorm também está disponível em:

Tem alguma pergunta?

Chat ao vivo com nossos especialistas de licenciamento de JetBrains.