简体   繁体   中英

type hinting array with 2 entries / phpdoc for array

say i have this

function foo(){
   return [1, 'bippo'];

}

how can I write phpdoc that it creates automatically on autocomplete something like this

list($x, $y) = foo();

phpDocumentor: Defining a 'Type' section Array 中所述,您可以将包含多种类型的数组指定为@return (int|string)[] ,这意味着此函数的返回类型是一个数组,其中可以包含以下元素intstring类型

You should be able to define the function with a return of something like...

@return array[int, string]

How this will work with autocomplete may depend on your IDE.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM