We have grown fond of Doxygen, it certainly appears to create the best looking documentation.
However, we use PHP and Traits are simply ignored / absent from generated documentation.
Are we missing a trick here, or are Traits simply not compatible?
Traits are just not supported by doxygen.
Since PHP does not support inheritance from multiple classes, traits are the way to extend a class by functions of multiple "classes".
C++ does support inheritance from multiple classes, so try this filter:
// make traits to classes
$regexp = '#trait([\s]+[\S]+[\s]*){#';
$replace = 'class$1{';
$source = preg_replace($regexp, $replace, $source);
// use traits by extending them (classes that not extending a class)
$regexp = '#class([\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#';
$replace = 'class$1 extends $3 $2 {';
$source = preg_replace($regexp, $replace, $source);
// use traits by extending them (classes that already extending a class)
$regexp = '#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*){[\s]+use([^;]+);#';
$replace = 'class$1, $3 $2{';
$source = preg_replace($regexp, $replace, $source);
This filter does:
Transforms traits to classes
trait MyTrait{ ... }
becomes
class MyTrait{ ... }
Transform "using" traits into "extending" traits
class MyClass{
use MyTrait1, MyTrait2;
...
}
becomes
class MyClass extends MyTrait, MyTrait2{
...
}
Doxygen documents this as a multiple inheritance. Maybe this works for you.
You can find this and some more doxygen filters for PHP in my repository on GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With