@return tag for methods returning array of objects

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.

Leave a Reply

Your email address will not be published. Required fields are marked *