Php – multiple subpackages for phpdoc

PHPphpdoc

Is it possible to have a file belong to multiple subpackages? For example:

/**
 * Name
 *
 * Desc
 *
 * @package    Core
 * @subpackage  Sub1
 * @subpackage  Sub2
 */

Thanks!

Best Answer

It appears that PHPDoc does not allow you to do it for namespacing reasons. From the PHPDoc Docs:

NOTE: The @subpackage tag is intended to help categorize the elements that are in an actual @package value. Since PHP itself doesn't allow you to have two functions with the same name in the same script, PhpDocumentor also requires all names in an @package to be unique... meaning, @subpackage does not allow further "naming separation" inside that @package. What it does do is allow a level of visual grouping/separation of the elements inside that @package.

It seems that because PHPDoc's @package is a way to pseudo-namespace your functions and classes, but @subpackage is simply for categorization. Have you tried adding more than one subpackage? If so, what were the results?

Related Topic