php-plantumlwriter
php-plantumlwriter copied to clipboard
PHP Trait support
First of all, I like the php plantuml writer. Works better than I expected.
One thing I did notice is how it worked on traits that were introduced in PHP 5.4. They do show up as regular classes with no dependencies. It would be nice to see what classes use what traits (or traits using other traits).
Hm. I've been thinking about this as well but I'm not sure how to represent traits in uml.
Currently this code
<?php
trait traitAlpha
{
function traitMethodOne()
{
}
function traitMethodTwo()
{
}
}
trait traitBeta
{
function traitMethodThree()
{
}
}
class aClassUsingATrait
{
use traitAlpha, traitBeta {
traitAlpha::traitMethodTwo as traitMethodRenamed;
}
}
Will result in this UML:
@startuml
abstract class traitAlpha {
+traitMethodOne()
+traitMethodTwo()
}
abstract class traitBeta {
+traitMethodThree()
}
class aClassUsingATrait {
}
@enduml
There are some discussions on how to display traits in uml:
- http://programmers.stackexchange.com/questions/215968/is-there-a-representation-for-mixins-or-traits-on-uml
- http://stackoverflow.com/questions/2690249/how-do-i-represent-a-mixin-role-trait-with-uml-properly
Any suggestions on how the php code above should be rendered in uml?
I think the multiple inheritance with a << trait >> marker (or something similar) is the simplest solution, but it is indeed interesting to think how it should be shown. I'm not sure how you would display the insteadof operator thing (besides renames, it can also change it's accessibility)