@@ -7,7 +7,7 @@ class Doc extends \PHPFUI\InstaDoc\Section
77
88 private $ factory ;
99 private $ reflection ;
10- private $ fullClassPath ;
10+ private $ class ;
1111
1212 public function generate (\PHPFUI \Page $ page , string $ fullClassPath ) : \PHPFUI \Container
1313 {
@@ -17,15 +17,19 @@ public function generate(\PHPFUI\Page $page, string $fullClassPath) : \PHPFUI\Co
1717// $page->addStyleSheet("highlighter/styles/{$parameters['CSS']}.css");
1818 $ page ->addStyleSheet ("highlighter/styles/qtcreator_light.css " );
1919 $ this ->factory = \phpDocumentor \Reflection \DocBlockFactory::createInstance ();
20- $ this -> fullClassPath = $ fullClassPath ;
21- $ this ->fullClassPath = str_replace ([ ' / ' , ' .php ' ], [ '\\' , '' ], $ this -> fullClassPath ) ;
22- $ start = strpos ( $ this -> fullClassPath , ' . ' );
23- if ( $ start !== false )
20+ $ parameters = $ this -> controller -> getParameters () ;
21+ $ this ->class = $ parameters [\ PHPFUI \ InstaDoc \Controller:: NAMESPACE ] . '\\' . $ parameters [\ PHPFUI \ InstaDoc \Controller:: CLASS_NAME ] ;
22+
23+ try
2424 {
25- $ this ->fullClassPath = substr ($ this ->fullClassPath , $ start + 3 );
25+ $ this ->reflection = new \ ReflectionClass ($ this ->class );
2626 }
27+ catch (\throwable $ e )
28+ {
29+ $ container ->add (new \PHPFUI \SubHeader ("{$ this ->class } is not a class " ));
2730
28- $ this ->reflection = new \ReflectionClass ($ this ->fullClassPath );
31+ return $ container ;
32+ }
2933
3034 $ table = new \PHPFUI \Table ();
3135 $ table ->addClass ('hover ' );
@@ -52,6 +56,15 @@ public function generate(\PHPFUI\Page $page, string $fullClassPath) : \PHPFUI\Co
5256
5357 $ container ->add ($ table );
5458
59+ $ comments = $ this ->reflection ->getDocComment ();
60+ if ($ comments )
61+ {
62+ $ docblock = $ this ->factory ->create ($ comments );
63+ $ callout = new \PHPFUI \Callout ('secondary ' );
64+ $ callout ->add ($ docblock ->getSummary ());
65+ $ container ->add ($ callout );
66+ }
67+
5568 $ tabs = new \PHPFUI \Tabs ();
5669 $ tabs ->addTab ('Public ' , $ this ->getContent ('isPublic ' ), true );
5770 $ tabs ->addTab ('Protected ' , $ this ->getContent ('isProtected ' ));
@@ -77,7 +90,7 @@ private function getContent(string $accessType) : \PHPFUI\Table
7790 $ section = 'Constants ' ;
7891 foreach ($ constants as $ name => $ value )
7992 {
80- $ constant = new \ReflectionClassConstant ($ this ->fullClassPath , $ name );
93+ $ constant = new \ReflectionClassConstant ($ this ->class , $ name );
8194
8295 if ($ accessType != 'isStatic ' && $ constant ->$ accessType ())
8396 {
@@ -280,9 +293,9 @@ private function getValueString($value) : string
280293 case 'array ' :
281294 $ text = '[ ' ;
282295 $ comma = '' ;
283- foreach ($ value as $ part )
296+ foreach ($ value as $ key => $ part )
284297 {
285- $ text .= $ comma . $ this ->getValueString ($ part );
298+ $ text .= $ comma . $ this ->getValueString ($ key ) . ' => ' . $ this -> getValueString ( $ part );
286299 $ comma = ', ' ;
287300 }
288301 $ text .= '] ' ;
@@ -295,7 +308,15 @@ private function getValueString($value) : string
295308 $ value = $ span ;
296309 break ;
297310 case 'object ' :
298- $ value = $ this ->getClassName (get_class ($ value ));
311+ $ class = get_class ($ value );
312+ if ($ class == 'ReflectionNamedType ' )
313+ {
314+ $ value = ($ value ->allowsNull () ? '? ' : '' ) . $ value ->getName ();
315+ }
316+ else
317+ {
318+ $ value = $ this ->getClassName (get_class ($ value ));
319+ }
299320 break ;
300321 case 'resource ' :
301322 $ value = 'resource ' ;
0 commit comments