在另一个文件中扩展PHPDoc / PHPStorm文档

问题描述:

I have a class (which I'll call Example) which implements the __call() method. This method allows the class to be extended to have additional calls (based on other data). For this question, I'll assume one of those is getDemoData().

This getDemoData() function would be available if it had a value in an array with a key Demo. The return value would be a specific class, in this case, named Demo.

Is it possible to some how extend the PHPDoc documentation (either due to PHPDoc directly, or something special in PHPStorm itself) which would allow me to say in Demo that Example has a method named Example::getDemoData().

I know I can use the @method tag from within the class itself, but I don't know if I can use it outside of that class (if I can, I'm not sure the syntax).

Thanks.

我有一个实现 Example code>) > __ call() code>方法。 此方法允许将类扩展为具有其他调用(基于其他数据)。 对于这个问题,我假设其中一个是 getDemoData() code>。 p>

如果 getDemoData() code>函数可用,如果 它在一个数组中有一个值,其中包含一个键 Demo code>。 返回值将是一个特定的类,在本例中,名为 Demo code>。 p>

是否有可能扩展PHPDoc文档(由于PHPDoc直接 ,或者PHPStorm本身的特殊内容),这将允许我在 Demo code>中说 Example code>有一个名为 Example :: getDemoData() code>的方法。 p>

我知道我可以在类本身中使用 @method code>标签,但我不知道是否可以在该类之外使用它(如果 我可以,我不确定语法。 p>

谢谢。 p> div>

I think the best you can do in that scenario is to use the @see tag in Demo's class docblock:

/**
 * @see Example::getDemoData()
 */
class Demo {}

assuming that you did indeed put @method in Example's class docblock:

/**
 * @method Demo getDemoData()
 */
class Example {}