Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Trait support #4

Open
pjordaan opened this issue Dec 3, 2014 · 2 comments
Open

PHP Trait support #4

pjordaan opened this issue Dec 3, 2014 · 2 comments

Comments

@pjordaan
Copy link

pjordaan commented Dec 3, 2014

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).

@davidfuhr
Copy link
Owner

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

trait

There are some discussions on how to display traits in uml:

Any suggestions on how the php code above should be rendered in uml?

@pjordaan
Copy link
Author

pjordaan commented Dec 9, 2014

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants