November 2023 (version 1.76)

Welcome to the November 2023 release of PHP Tools for Visual Studio!

Improvements

  • Structured object Type: dynamic objects can be annotated within doc comment using object{property:type,} syntax.
  • Global @type Aliases: type aliases can be defined in the scope of entire file using doc comment @type, @phpstan-type, @phpstan-import-type, @psalm-type, @psalm-import-type. Previously, it only worked above classes and functions. Now it is also valid in a doc comment /** */ at anywhere in global file scope.
  • New PHP 8.3 syntax is supported by the formatter.
  • list{} doc comment shape.
  • Navigation and completion in @see tag when in a namespace.
  • array_multisort() does not treat the first argument as strictly passed by reference (#1729).
  • go to and code completion of file paths improvements (#1735).

Formatting

Comments

In this update, we've made improvements to how comments are handled. Now, comments that follow after an expression are preserved in their original positions, giving users the flexibility to indent them as they prefer.

$x = [
  1  => 'one'      // first comment
  42 => 'fortytwo' // second comment
]

Align match arm bodies

The formatter now offers "Align Match Arm Bodies" to align the bodies (results) within match expressions for enhanced code clarity and structure. To enable this feature, navigate to Tools | Options in Visual Studio, then go to Text Editor | PHP | Formatting | Wrapping | Match expression, and select Align match arm bodies.

match ($day) {
    'Monday'    => 'Work',
    'Tuesday'   => 'Tacos',
    'Wednesday' => 'Waffles'
};

Fixes

  • Fixes the wrapping behavior, ensuring that comments are maintained on their original lines when they follow an expression. #1760
  • Fixes code indentation after applying "Implement abstracts" code action.
  • False named argument error in case the method accepts variadic arguments (#1722).
  • Fixed analysis of generators return type.
  • Fixes improper formatting when named argument as a keyword #408
  • Fixes incorrect indentation inside contructor #409
  • Visual Studio crash fixes