What's New - PHP in Visual Studio Code (February 2023)#
We're continuously adding new and new features to both the Visual Studio Code and Visual Studio IDEs. Today we're going to summarize recently added features for PHP developers in Visual Studio Code!
Inlay Hints#
Newly Inlay Hints for PHP code are available!
The inlays are available for parameter names, by-reference arguments, and inferred function return types.
To enable or disable the inlay hints, change the following settings:
"editor.inlayHints.enabled"
"php.inlayHints.parameters.enabled"
"php.inlayHints.parameters.byReference"
"php.inlayHints.types.return"
"php.inlayHints.types.variable"
See the documentation for more details.
Quick Fixes#
There are lots of new quick fixes and code actions!
New Code Actions#
More useful refactorings are coming to the PHP extension and VS Code. Following are refactorings introducing common PHP 8 syntax to your code.
Condition ?:
can be replaced with ?->
Simplifying conditional expressions like the one below:
Assignments can be simplified
Simplifying assignments:
Converting switch
to match
In certain cases, switch
statement can be converted to the new match
expression.
Add missing Doc Comments#
New code action adds missing doc comments with infered type information and summary placeholders. The functionality is the same as by typing `
## IntelliSense Improvements
**Respecting `@internal` annotation**
Symbols annotated with `@internal` doc comment tag are hidden in the completion list now;
**Correct ordering**
We have updated how the code completion is ordered depending on context and so-far typed text; Symbols from imported namespaces are listed first, then top-level symbols, and at the end there are symbols that can be auto-imported.
**Deprecated classes**
Additionally, deprecated classes and interfaces and striked-out in the code completion list, and when used in the source code. Previously, we did that only for functions.

**Performance**
More frequent operations have been moved to a background thread to make the user experience fluent and uninterrupted.
### IntelliSense & Enums
The PHP 8.1 `enum` objects implicitly implements `UnitEnum` and `BackedEnum` interfaces. The `BackedEnum<TValue>` interface is annotated with a template type argument so it can be used in Doc Comments with the backed type for better type analysis. E.g.:
```php
function foo($e) {
return $e->value // -> string
}
enum MyEnum : string {
case A;
}
foo( MyEnum::A );
Generic Types & Doc Comments Type Annotations
The type annotations in PHP Doc Comments have been reimplemented, so even complex constructs are handled, can be completed, refactored, highlighted, and previewed. Highlighting occurences works even in nested generic types, as well as rename refactoring and code completion.
More Generic Annotations#
Standard types got annotated with generic template types; this is especially helpful in Laravel and Symfony frameworks, where it provides type inferring for all the collections, iterables, Generator
, DOMNodeList
, etc.
This improves value inferred within foreach
for all kinds of iterables.