问题
I currently have code where there is an abstract parent class that defines some concrete methods, and the children classes extend this parent class, and will use the concrete methods. For example:
<?php
abstract class abstract_class {
/**
* I document foo.
*/
public function foo() {
echo "I am the foo function!";
}
}
class child_class {
/**
* I document bar.
*/
public function bar() {
echo "I am the bar function!";
}
}
?>
In my documentation for child_class, I see my bar() function well documented, both in the Method summary and verbose description of the method...but my foo() function, which was inherited, is only stated to be inherited and I need to follow a link to see its full documentation, and even just see that it is callable by this function. An example of what I see is shown in the image here. (I can't put the image here because I am a new user...)
According to the PhpDocumentors documentation I should be able to see the Docblock somehow, but I don't know how to do so:
New in version 1.2.0, DocBlock's are inherited by child classes, variables, and methods.
I looked all over for a switch or something to run when calling phpdoc from a command-line but haven't found anything.
How can I display the information I want, in the way that I want?
回答1:
If you do not redeclare the method in the child class, then I think the structure of the various output converters will only show you a list of inherited methods. Some converters will include at least the Short Description of the method from the docblock (HTML:Smarty:PHP), whereas others do not (HTML:frames:default).
No, there is no runtime config or switch that you can use to modify this behavior. This is simply a matter of how the output converters are written to structure the resulting document.
Now, if you were to redeclare the method again in the child class, whether it be to override the parent method or to just actually implement a concrete method for a parent's abstract method, then many aspects that you had written in the parent method's docblock would then be visible in the child method's document.
Following your example, this may best be demonstrated by the abstract class having an abstract method, and it gets fully documented. Then, the child class implements the method, but has no docblock of its own (because by convention it should be perfectly following the description that's in the abstract parent's method docblock). This doc inheritance should be visible by the param and return tags being visibly inherited, for example.
This kind of inheritance behavior is also visible in IDEs like Eclipse. If phpDocumentor is failing to show this kind of inheritance in the child class docs, it is a bug.
回答2:
Try Docblox. It is similar, but the output is AJAX gold. The only thing missing is the Web interface. I installed it as a pear package.
来源:https://stackoverflow.com/questions/7781222/how-to-display-full-docblocks-for-inherited-methods-in-phpdocumentor