UML representation of a PHP property

I am creating projects with Symfony2 / Doctrine and trying to implement features. There is still no problem with small attempts, but I usually do class diagrams and UML diagrams before deep complex projects.

What is a UML design object that will be used to denote PHP traits that can be seen, as far as I know, how the behavior is? Is there any clean way to do this?

Thanks so much for your answers!

Nicholas

+5
source share
3 answers

PHP Trait is basically UML An abstract class or UML class template connected to the class in use with UML generalization relationships using multiple inheritance notation

enter image description here

See also:

  • Figure β€œUML Chart with Tag” in Brendan Bates's article : Traits: The Right Way

  • Programmers: is there a view for mixins or tags in UML?

  • PHP Manual β†’ Language Reference β†’ Classes and Objects β†’ Features

    Starting with PHP 5.4.0, PHP implements a code reuse method called Traits .

    Traits are code reuse mechanisms in single inheritance languages ​​such as PHP . A Trait designed to reduce some of the limitations of single inheritance , allowing the developer to freely use many methods in several independent classes that live in different class hierarchies. The semantics of the combination of Traits and classes is defined in a way that reduces complexity and avoids the typical problems associated with multiple inheritance, and Mixins .

    A Trait is similar to a class, but is intended only to group functionality subtly and consistently. It is not possible to instantiate a Trait yourself. This addition to traditional inheritance provides a horizontal composition of behavior; that is, the use of classes that do not require inheritance

+5
source

In the earliest document I saw in the Roles / Traits explanations, they are presented in UML with a line connecting the role / trait to the method / function within the class. http://scg.unibe.ch/archive/papers/Scha03aTraits.pdf

0
source

As I see it, a PHP attribute is nothing more than a protocol definition that you will find in other languages. The protocol is some functional extension for the class. Usually you model this using the interface (Trait) and the class, using it where you draw the <> relation from class to Trait.

0
source

Source: https://habr.com/ru/post/1214753/


All Articles