@@ -104,7 +104,6 @@ public function generate(\PHPFUI\Instadoc\PageInterface $page, string $fullClass
104
104
$ accordion ->addTab ('Extends ' , $ table );
105
105
}
106
106
107
-
108
107
$ table = new \PHPFUI \Table ();
109
108
$ table ->addClass ('hover ' );
110
109
$ table ->addClass ('unstriped ' );
@@ -130,7 +129,6 @@ public function generate(\PHPFUI\Instadoc\PageInterface $page, string $fullClass
130
129
131
130
foreach ($ interfaces as $ interface )
132
131
{
133
- $ class = $ interface ->getName ();
134
132
$ table ->addRow ([$ this ->getClassName ($ interface ->getName ())]);
135
133
}
136
134
@@ -140,6 +138,26 @@ public function generate(\PHPFUI\Instadoc\PageInterface $page, string $fullClass
140
138
}
141
139
}
142
140
141
+ $ traits = $ this ->getTraits ($ this ->reflection );
142
+
143
+ if ($ traits )
144
+ {
145
+ ksort ($ traits , SORT_FLAG_CASE | SORT_STRING );
146
+ $ table = new \PHPFUI \Table ();
147
+ $ table ->addClass ('hover ' );
148
+ $ table ->addClass ('unstriped ' );
149
+
150
+ foreach ($ traits as $ trait )
151
+ {
152
+ $ table ->addRow ([$ this ->getClassName ($ trait ->getName ())]);
153
+ }
154
+
155
+ if (count ($ table ))
156
+ {
157
+ $ accordion ->addTab ('Traits ' , $ table );
158
+ }
159
+ }
160
+
143
161
if (count ($ accordion ))
144
162
{
145
163
$ container ->add ($ accordion );
@@ -414,4 +432,21 @@ protected function objectSort(array &$objects) : void
414
432
{
415
433
usort ($ objects , [$ this , 'objectCompare ' ]);
416
434
}
435
+
436
+ /**
437
+ * return traits for the entire inheritance tree, not just the current class
438
+ */
439
+ private function getTraits (\ReflectionClass $ reflection ) : array
440
+ {
441
+ $ traits = [];
442
+
443
+ $ parent = $ reflection ->getParentClass ();
444
+
445
+ if ($ parent )
446
+ {
447
+ $ traits = $ this ->getTraits ($ parent );
448
+ }
449
+
450
+ return array_merge ($ traits , $ reflection ->getTraits ());
451
+ }
417
452
}
0 commit comments