@@ -156,7 +156,8 @@ public function display(array $classPagesToShow = Controller::VALID_CLASS_PAGES,
156
156
$ cell = new \PHPFUI \Cell ();
157
157
$ div ->add (' ' );
158
158
$ icon = new \PHPFUI \FAIcon ('far ' , 'clipboard ' );
159
- $ parameters = $ this ->getMethodParameters ($ fullClassName );
159
+ $ parameters = $ this ->getConstructorParameters ($ fullClassName );
160
+ $ parameters = \str_replace ("\n" , '' , $ parameters );
160
161
$ hidden = new \PHPFUI \Input ('text ' , 'clipboard ' , "new \\{$ fullClassName }( {$ parameters }); " );
161
162
$ hidden ->addClass ('hide ' );
162
163
$ div ->add ($ hidden );
@@ -455,7 +456,7 @@ public function getParameters() : array
455
456
/**
456
457
* Get parameters for the class and method
457
458
*/
458
- public function getMethodParameters (string $ className, $ methodName = ' __construct ' ) : string
459
+ public function getConstructorParameters (string $ className ) : string
459
460
{
460
461
try
461
462
{
@@ -466,43 +467,24 @@ public function getMethodParameters(string $className, $methodName = '__construc
466
467
return '' ;
467
468
}
468
469
470
+ $ methodName = '__construct ' ;
471
+
469
472
if (! $ reflection ->hasMethod ($ methodName ))
470
473
{
471
474
return '' ;
472
475
}
473
- $ method = $ reflection ->getMethod ($ methodName );
474
-
475
- $ info = '' ;
476
- $ comma = '' ;
477
-
478
- foreach ($ method ->getParameters () as $ parameter )
479
- {
480
- $ info .= $ comma ;
481
- $ comma = ', ' ;
482
476
483
- if ($ parameter ->hasType ())
484
- {
485
- $ type = $ parameter ->getType ();
486
- $ info .= $ type ->allowsNull () ? '? ' : '' ;
487
- $ info .= $ type ->getName ();
488
- $ info .= ' ' ;
489
- }
490
- $ name = $ parameter ->getName ();
491
- $ info .= '$ ' . $ name ;
492
-
493
- if ($ parameter ->isDefaultValueAvailable ())
494
- {
495
- $ value = $ parameter ->getDefaultValue ();
496
- $ info .= ' = ' . $ this ->getValueString ($ value );
497
- }
498
- }
477
+ $ method = $ reflection ->getMethod ($ methodName );
478
+ $ section = new \PHPFUI \InstaDoc \Section \CodeCommon ($ this , $ className );
479
+ $ parameters = $ section ->getMethodParameters ($ method );
480
+ $ html2Text = new \Html2Text \Html2Text ($ parameters , ['do_links ' => 'none ' ]);
499
481
500
- return $ info ;
482
+ return $ html2Text -> getText () ;
501
483
}
502
484
503
- /**
504
- * Get a section for display. Override to change layout
505
- */
485
+ /**
486
+ * Get a section for display. Override to change layout
487
+ */
506
488
public function getSection (string $ sectionName ) : Section
507
489
{
508
490
if (! \in_array ($ sectionName , Controller::SECTIONS ))
@@ -638,68 +620,4 @@ public function setParameters(array $parameters) : Controller
638
620
639
621
return $ this ;
640
622
}
641
-
642
- protected function getValueString ($ value ) : string
643
- {
644
- switch (\gettype ($ value ))
645
- {
646
- case 'array ' :
647
- $ index = 0 ;
648
- $ text = '[ ' ;
649
- $ comma = '' ;
650
-
651
- foreach ($ value as $ key => $ part )
652
- {
653
- $ text .= $ comma ;
654
-
655
- if ($ index !== $ key )
656
- {
657
- $ text .= $ this ->getValueString ($ key ) . ' => ' ;
658
- }
659
- ++$ index ;
660
- $ text .= $ this ->getValueString ($ part );
661
- $ comma = ', ' ;
662
- }
663
- $ text .= '] ' ;
664
- $ value = $ text ;
665
-
666
- break ;
667
-
668
- case 'string ' :
669
- $ value = "' {$ value }' " ;
670
-
671
- break ;
672
-
673
- case 'object ' :
674
- $ class = \get_class ($ value );
675
-
676
- if ('ReflectionNamedType ' == $ class )
677
- {
678
- $ value = ($ value ->allowsNull () ? '? ' : '' ) . $ value ->getName ();
679
- }
680
- else
681
- {
682
- $ value = $ class ;
683
- }
684
-
685
- break ;
686
-
687
- case 'resource ' :
688
- $ value = 'resource ' ;
689
-
690
- break ;
691
-
692
- case 'boolean ' :
693
- $ value = $ value ? 'true ' : 'false ' ;
694
-
695
- break ;
696
-
697
- case 'NULL ' :
698
- $ value = 'NULL ' ;
699
-
700
- break ;
701
- }
702
-
703
- return $ value ;
704
- }
705
623
}
0 commit comments