PHPDoc provides the @var
tag, which should work even for variables declared outside of a class.
However, this does not seem to work if I define the variable as a magic member of an object:
/** @var $app->translator \Fortress\MessageTranslator */
$app->translator = new \Fortress\MessageTranslator();
Where $app
is a Slim object that supports arbitrary property assignment via magic setters and getters.
I know that I could add it to Slim
itself via the @property
tag, but then I would need to change the core Slim
code every time I create a new property.
Does PHPDoc support this kind of dynamic property documenting?
You don't need $app->translator in the doc block. It should look like this:
or
Link to the documentation.