How to hint array of objects with phpdoc?

is there a way to document an array of objects of a certain class?

e.g. @param $foo Someclass[] Array of objects of type Someclass

I tried various things but couldn't get anything definitive working and somehow phpdoc itself seems sparse on it too.



You must use correct order of elements:

* @param SomeClass[] $foo Bla-bla-description
public function sayWhat ($foo) {


Thanks, this works. And now I've the next problem. I'm providing a magic __call() and thus don't have documentation und must use @method . I'm failing to understand how can provide hinting for array of classes as a parameter for a magic method. The following does not work for me:

* @method Foo[] bar() bar(Foo[] $bla)
class Foo {
  public function __call() {
    # ...

$f = new Foo;

I get a red underwaved marker here:

* @method Foo[] bar() bar(Foo[] $bla)
marker placed here------------+

The marker says: "Expected: variable"


TBH -- I do not know.

I suggest just using normal array there -- should be no difference when using for code completion.

In any case: feel free to submit new ticket to the Issue Tracker describing your issue -- devs will tell for sure if this is an expected behaviour or it is a bug.


Please sign in to leave a comment.