Updates for VS Code (September 2020)

Author by Jakub M.
3 minutes

There have been a lot of updates and improvements to PHP Tools on VS Code. Check what's new and how it can help you with your PHP projects.

In short, there is the support for PHP 8.0 syntax, new diagnostics, quick fixes, improved tooltips, support for "Go To Implementation" command, performance and code analysis improvements, PCRE syntax checker, Test Explorer improvements, and more.

Go To Implementation

goto implementatoin

VS Code introduces a useful command for quickly going to function overrides, interface implementors, or class sub-classes. It is fully supported and provides you workspace-wide search for implementations.

PCRE pattern check

pcre check

The code may be full of regullar expressions; and it's very easy to make a mistake. In addition to syntax highlighting, PHP Tools now validates the syntax for you and shows additional diagnostics in case anything may be wrong.

PHP 8.0 syntax

php 8.0 in vs code

There is an upcoming big release of PHP 8.0. The editor now supports the entire PHP 8.0 syntax including:

  • non-capturing catches: try { .. } catch (Exception) { ... }
  • attributes: #[PhpAttribute]
  • null-safe operator: ?->
  • union types
  • mixed type, static type
  • match expression
  • constructor property promotion
  • throw expression
  • ::class on objects
  • trailing comma in the parameter list

Note, in order to actually use the new syntax, you'll need the PHP 8.0 beta installed. Until then, the editor will report all the new features usage as problems.

Quick Fixes

php quick fixes in vs code

We have added several new quick fixes for common problems, and also a few refactoring quick actions. Now you can generate getters and setters for properties, shorten class names if possible, or implement missing abstract functions or whole interfaces.

And more ...

All the other fixes, new features, and improvements are listed in the changelog.