@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.


Posted

in

by

Tags:

Comments

Leave a Reply

%d bloggers like this: