Giustino Borzacchiello

return tag for methods returning array of objects

2017-02-03

I always wondered how to write the @return tag for methods that return an array of objects. Today I discovered that you have to write:

<?php

class AnotherClass {

  /**
   * @return MyClass[]
   */
  public function getClasses() {
    // logic here
    return $array_of_classes;
  }
}

You can read the relevant docs here.