0

I'm trying to find out how to properly document an array property in a class for phpdocumentor.

Ex:

<?php
class foo {
   /**
    * This holds something important
    * @var string
    */
    protected $junk;
   /**
    * This holds an important array of strings
    * @var ???????
    */
    protected $stuff = array();
    // ...
}
?>

I couldn't find anything in the phpdoc manual about array properties.

7
  • 3
    Have you tried * @var string[] ? See as well: PHPDoc type hinting for array of objects? Commented Mar 3, 2012 at 21:37
  • In netbeans, it seems to accept the @var string[]. Thanks Commented Mar 3, 2012 at 21:49
  • 1
    But you have asked for PHPDocumentor, not Netbeans. Commented Mar 3, 2012 at 21:55
  • Well, there are about 30 properties in the parent class and only one is an array. In the multiple classes extending the parent I can quickly see what I'm dealing with. Commented Mar 3, 2012 at 21:57
  • I'm hoping it will work with both.. will let you know soon if PHPDocuemntor accepts this Commented Mar 3, 2012 at 21:59

1 Answer 1

2

/** @var array */ for your protected $stuff is the proper syntax. The phpDocumentor manual page for @var shows "The datatype should be a valid PHP type (int, string, bool, etc),", and "array" is such a valid PHP type.

Some IDEs have also begun recognizing /** @var ElementType[] */ to indicate "this is an array, whose elements are all of type ElementType". This syntax will be available in an upcoming version of phpDocumentor.

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.