September 2022 (version 1.68)

Downloads: https://www.devsense.com/download
Purchase: https://www.devsense.com/purchase

Welcome to the September 2022 release of PHP Tools for Visual Studio!

PHP 8.2 Support

The new version of PHP, the version 8.2, will be released soon (expecting November 2022). Our PHP editor is getting ready, and it already supports most of the new language syntax. You can try the new readonly classes, and even use the the latest development build of PHP 8.2 right in Visual Studio.

php readonly class in older PHP

Just go to your PHP project properties, and choose PHP 8.2 (x64) DEV. It will get installed and configured for debugging automatically.

PHP 8.2 installation

Diagnostics

Dynamic Properties

The editor checks accessing class dynamic properties, i.e. properties that were not declared, according to their access. When reading a property and there is no magic __get() method, the property gets reported. When writing to a property and there is no magic __set(), the property gets reported. This behavior can be improved by specifying the dynamic properties in the class DocComment, using @property, @property-read, @property-write tags.

Note, since PHP 8.2, use of dynamic properties (without __get(), or __set()) is deprecated (#rfc).

Annotating foreach Control Variables

Type of control variables can be annotated using inlined DocComment, i.e.:

foreach ($array as /* @var MyClass */$x) {
    //$x-> ...
}

or

/* @var MyClass $x */
foreach ($array as $x) {
    //$x-> ...
}

The same works for the key variable as well.

More Control Flow Diagnostics

Since v1.68, diagnostics treat finally block correctly and detects missing return with a value in more cases. Also, in case a function has a return type-hint mixed, missing return is reported as well.

Fixes

Debug

There are major fixes in debugging in combination with the new Xdebug extension.

  • Debug expression evaluation has been fixed.

Other Fixes & Improvements

  • Updated Attribute class definition.
  • Fixed colorization of attributes (#[]) above enum cases.
  • Generated getter/setter snippet (through a property code action) respects static keyword.
  • DocComments allow the type hints to be enclosed in parentheses (, ).
  • Memory usage optimizations.
  • Performance improvements.