phparraysphpstormpsalm-php

Psalm multiline associative array annotation


I'm using Psalm style annotations to document for instance return array types, such:

/**
  * @return array{ key1: type1, key2: type2, key3: array{ nestedKey1: array<string,string> } }
  */

This works like a charm for autocomplete / static analysis, including PhpStorm. However, these lines can get just absurly long and impossible to follow, especially where nested arrays are involved.

I'm looking for a multiline syntax for this annotation, where I can have something like:

/**
  * @return array{ 
  *    key1: type1, 
  *    key2: type2, 
  *    key3: array{ 
  *      nestedKey1: array<string,string> 
  *    } 
  *  }
  */

However as it's written this doesn't appear to be valid parsed syntax. Is there some syntax that would allow me to break the definition on multiple lines?


Solution

  • Unfortunately, no, there isn't. Here's a request for this on the PhpStorm tracker:
    https://youtrack.jetbrains.com/issue/WI-59784