logoalt Hacker News

bakugo • today at 11:18 AM • 2 replies • view on HN

How does that solve the problem? You can't declare an array of strings inside a class, either.


Replies

eithed • today at 2:27 PM

You can annotate the method as `@return array<array-key,string>` or even `@return list<string>` (array of strings = indexed via anything that can be used as a key in PHP vs list of strings = indexed via incrementing integers, starting from 0). I guess the OP suggestion was to use Arrayable / Iterable interfaces, which I guess would work as well, but would require more effort (= yes, declare a class)

lofaszvanitt • today at 12:04 PM

Do some research :D.

➕ show 1 reply