MontealegreLuis / phuml

phUML is a UML diagram generator. It takes arbitrary object oriented PHP code and creates fully blown class diagrams of it.
BSD 3-Clause "New" or "Revised" License
100 stars 19 forks source link

[BUG] FQN is lost when dealing with union types in TypeDeclaration::references() #18

Closed Amegatron closed 2 years ago

Amegatron commented 2 years ago

In union types, FQN of it's components is lost when getting their referecnes(). For example, if I have a class property (attribute) with type My\Intersting\SuperType|null, references() will return type just SuperType with the rest part of FQN truncated.

I believe this is because of this line: https://github.com/MontealegreLuis/phuml/blob/master/src/Code/Variables/TypeDeclaration.php#L74

When casting Name to string, it uses only the last part of it. Not sure if it's inteded or not, but seems ->fullName() should be used there.

MontealegreLuis commented 2 years ago

Hi @Amegatron you're absolutely right that's the line with the issue, and the solution is the one you suggested.

This test case is missing one entry with a class with a namespace: https://github.com/MontealegreLuis/phuml/blob/master/tests/unit/Code/Variables/TypeDeclarationTest.php#L107

This is a good first issue for anyone looking to start contributing to phUML.

MontealegreLuis commented 2 years ago

Fixed in #19