Closed Amegatron closed 2 years ago
Fixed in #19
It's actually another bug, not fixed in #19. #19 fixed the case, when type is FQN itself without import. But this issue is about referencing classes in the same namespace.
The case you're mentioning looks good to me.
<?php
namespace My\Intersecting {
class OneClass {}
class AnotherClass {
public function __construct(private OneClass|null $attribute)
{
}
}
}
namespace Another {
class ThirdClass {}
}
When running
bin/phuml phuml:dot -a src example.gv
It produces the file
digraph "c28524bef61d29a872d30f67acff34c4d8586c58" {
splines = true;
overlap = false;
mindist = 0.6;
"My\Intersecting\OneClass" [label=<<TABLE CELLSPACING="0" BORDER="0" ALIGN="LEFT"><TR><TD BORDER="1" ALIGN="CENTER" BGCOLOR="#8892BF"><B><FONT COLOR="#FFFFFF" FACE="Helvetica" POINT-SIZE="12">OneClass</FONT></B></TD></TR><TR><TD BORDER="1" ALIGN="LEFT" BGCOLOR="#f2f2f2"> </TD></TR><TR><TD BORDER="1" ALIGN="LEFT" BGCOLOR="#f2f2f2"> </TD></TR></TABLE>> shape=plaintext color="#2e3436"]
"My\Intersecting\OneClass" -> "My\Intersecting\AnotherClass" [dir=back arrowtail=none style=solid color="#2e3436"]
"My\Intersecting\AnotherClass" [label=<<TABLE CELLSPACING="0" BORDER="0" ALIGN="LEFT"><TR><TD BORDER="1" ALIGN="CENTER" BGCOLOR="#8892BF"><B><FONT COLOR="#FFFFFF" FACE="Helvetica" POINT-SIZE="12">AnotherClass</FONT></B></TD></TR><TR><TD BORDER="1" ALIGN="LEFT" BGCOLOR="#f2f2f2"><FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="10">-$attribute: OneClass|null</FONT><BR ALIGN="LEFT"/></TD></TR><TR><TD BORDER="1" ALIGN="LEFT" BGCOLOR="#f2f2f2"><FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="10">+__construct($attribute: OneClass|null)</FONT><BR ALIGN="LEFT"/></TD></TR></TABLE>> shape=plaintext color="#2e3436"]
"Another\ThirdClass" [label=<<TABLE CELLSPACING="0" BORDER="0" ALIGN="LEFT"><TR><TD BORDER="1" ALIGN="CENTER" BGCOLOR="#8892BF"><B><FONT COLOR="#FFFFFF" FACE="Helvetica" POINT-SIZE="12">ThirdClass</FONT></B></TD></TR><TR><TD BORDER="1" ALIGN="LEFT" BGCOLOR="#f2f2f2"> </TD></TR><TR><TD BORDER="1" ALIGN="LEFT" BGCOLOR="#f2f2f2"> </TD></TR></TABLE>> shape=plaintext color="#2e3436"]
}
Which includes the right namespace for all classes in associations.
Do you have an example?
Hm, interesting. Right now I don't have exact example with a generated graph, cause I use just internals of the library to generate my own graphs. And I faced situations working with Codebase
, when getting attributes' or method parameters' references
, it returned truncated classnames in the described scenario. I'll try to give some concrete example later if I face it again.
If I have a namespaced class and somewhere inside of it (attributes, methods, whatever) I reference another class from that same namespace (so no import is needed), that referenced entity is resolved without FQN.