0

is it possible to get code hinting if you have a parameter of array of objects.

This works:

/**
 * @return MyObject[]
 */
public function moo() {
   return array(new MyObject(), new MyObject());
}

public function bla() {
  foreach ($this->moo() as $obj) {
     $obj->IGetCodeHintingHere(); 
  }
}

Is the same way possible with @param like @return? For example like this:

/**
 * @param $MyObject[]
 */
public function bla(array $aaa) {
  foreach ($aaa as $a) {
     $a->IWantGetCodeHintingHereToo(); 
  }
}

1 Answer 1

0

Possible duplicate of:

PHPDoc type hinting for array of objects?

and

How can I specify array of objects in PhpDoc

To give you an answer, you can see and try if your IDE supports this doc syntax:

/**
 * @param $aaa MyObject[]
 */
public function bla(array $aaa) {
  foreach ($aaa as $a) {
     $a->IWantGetCodeHintingHereToo(); 
  }
}

Good luck and have fun!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.