@@ -516,23 +516,27 @@ protected function dumpMethods($methods)
516516 ? 'methods '
517517 : 'no methods ' ;
518518 $ str = '<dt class="methods"> ' .$ label .'</dt> ' ."\n" ;
519+ $ magicMethods = array_intersect (array ('__call ' ,'__callStatic ' ), array_keys ($ methods ));
520+ $ str .= $ this ->magicMethodInfo ($ magicMethods );
519521 foreach ($ methods as $ methodName => $ info ) {
520- $ paramStr = $ this ->dumpParams ($ info ['params ' ]);
522+ $ classes = array_keys (array_filter (array (
523+ 'method ' => true ,
524+ 'deprecated ' => $ info ['isDeprecated ' ],
525+ )));
521526 $ modifiers = array_keys (array_filter (array (
522527 'final ' => $ info ['isFinal ' ],
523528 $ info ['visibility ' ] => true ,
524529 'static ' => $ info ['isStatic ' ],
525530 )));
526- $ str .= '<dd '
527- .' class="method ' .implode (' ' , $ modifiers ).($ info ['isDeprecated ' ] ? ' deprecated ' : '' ).'" '
528- .' data-implements=" ' .$ info ['implements ' ].'"> '
531+ $ classes = array_merge ($ classes , $ modifiers );
532+ $ str .= '<dd class=" ' .implode (' ' , $ classes ).'" data-implements=" ' .$ info ['implements ' ].'"> '
529533 .implode (' ' , array_map (function ($ modifier ) {
530534 return '<span class="t_modifier_ ' .$ modifier .'"> ' .$ modifier .'</span> ' ;
531535 }, $ modifiers ))
532- .(isset ($ info ['phpDoc ' ]['return ' ][ 0 ] )
536+ .(isset ($ info ['phpDoc ' ]['return ' ])
533537 ? ' <span class="t_type" '
534- .' title=" ' .htmlspecialchars ($ info ['phpDoc ' ]['return ' ][0 ][ 'desc ' ]).'" '
535- .'> ' .$ info ['phpDoc ' ]['return ' ][0 ][ 'type ' ].'</span> '
538+ .' title=" ' .htmlspecialchars ($ info ['phpDoc ' ]['return ' ]['desc ' ]).'" '
539+ .'> ' .$ info ['phpDoc ' ]['return ' ]['type ' ].'</span> '
536540 : ''
537541 )
538542 .' <span class="method-name" '
@@ -542,7 +546,9 @@ protected function dumpMethods($methods)
542546 : ''
543547 ))).'" '
544548 .'> ' .$ methodName .'</span> '
545- .'<span class="t_punct">(</span> ' .$ paramStr .'<span class="t_punct">)</span> '
549+ .'<span class="t_punct">(</span> '
550+ .$ this ->dumpParams ($ info ['params ' ])
551+ .'<span class="t_punct">)</span> '
546552 .($ methodName == '__toString '
547553 ? '<br /><span class="indent"> ' .$ this ->dump ($ info ['returnValue ' ]).'</span> '
548554 : ''
@@ -572,13 +578,36 @@ protected function dumpParams($params)
572578 $ paramStr .= '<span class="t_parameter-name" '
573579 .' title=" ' .htmlspecialchars ($ info ['desc ' ]).'" '
574580 .'> ' .htmlspecialchars ($ info ['name ' ]).'</span> ' ;
575- if ($ info ['defaultValue ' ] != $ this ->debug ->abstracter ->UNDEFINED ) {
581+ if ($ info ['defaultValue ' ] !== $ this ->debug ->abstracter ->UNDEFINED ) {
576582 $ defaultValue = $ info ['defaultValue ' ];
577- if (is_string ($ defaultValue )) {
578- $ defaultValue = str_replace ("\n" , ' ' , $ defaultValue );
579- }
580583 $ paramStr .= ' <span class="t_operator">=</span> ' ;
581- $ paramStr .= '<span class="t_parameter-default"> ' .$ this ->dump ($ defaultValue ).'</span> ' ;
584+ if ($ info ['constantName ' ]) {
585+ /*
586+ only php >= 5.4.6 supports this...
587+ or via @method phpDoc
588+
589+ show the constant name / hover for value
590+ */
591+ $ title = '' ;
592+ $ type = $ this ->debug ->abstracter ->getType ($ defaultValue );
593+ if (!in_array ($ type , array ('array ' ,'resource ' ))) {
594+ $ title = $ this ->debug ->output ->outputText ->dump ($ defaultValue );
595+ $ title = htmlspecialchars ('value: ' .$ title );
596+ }
597+ $ paramStr .= '<span class="t_parameter-default t_const" '
598+ .' title=" ' .$ title .'" '
599+ .'> ' .$ info ['constantName ' ].'</span> ' ;
600+ } else {
601+ /*
602+ The constant's value is shown
603+ */
604+ if (is_string ($ defaultValue )) {
605+ $ defaultValue = str_replace ("\n" , ' ' , $ defaultValue );
606+ }
607+ $ classAndInner = $ this ->debug ->utilities ->parseAttribString ($ this ->dump ($ defaultValue ));
608+ $ classAndInner ['class ' ] = trim ('t_parameter-default ' .$ classAndInner ['class ' ]);
609+ $ paramStr .= '<span class=" ' .$ classAndInner ['class ' ].'"> ' .$ classAndInner ['innerhtml ' ].'</span> ' ;
610+ }
582611 }
583612 $ paramStr .= '</span>, ' ; // end .parameter
584613 }
@@ -587,7 +616,7 @@ protected function dumpParams($params)
587616 }
588617
589618 /**
590- * Dump phpDoc info as html
619+ * Dump object's phpDoc info as html
591620 *
592621 * @param array $phpDoc parsed phpDoc
593622 *
@@ -601,15 +630,27 @@ protected function dumpPhpDoc($phpDoc)
601630 continue ;
602631 }
603632 foreach ($ values as $ value ) {
604- $ str .= '<dd class="constant"> '
633+ if ($ k == 'link ' ) {
634+ $ value = '<a href=" ' .$ value ['uri ' ].'" target="_blank"> '
635+ .htmlspecialchars ($ value ['desc ' ] ?: $ value ['uri ' ])
636+ .'</a> ' ;
637+ } elseif ($ k == 'see ' && $ value ['uri ' ]) {
638+ $ value = '<a href=" ' .$ value ['uri ' ].'" target="_blank"> '
639+ .htmlspecialchars ($ value ['desc ' ] ?: $ value ['uri ' ])
640+ .'</a> ' ;
641+ } else {
642+ $ value = htmlspecialchars (implode (' ' , $ value ));
643+ }
644+ $ str .= '<dd class="phpdoc phpdoc- ' .$ k .'"> '
605645 .'<span class="phpdoc-tag"> ' .$ k .'</span> '
606- .' <span class="t_operator">= </span> '
607- .implode ( ' ' , array_map ( ' htmlspecialchars ' , $ value))
608- .'</dd> ' ;
646+ .'<span class="t_operator">: </span> '
647+ .$ value
648+ .'</dd> ' . "\n" ;
609649 }
610650 }
611651 if ($ str ) {
612- $ str = '<dt class="phpDoc">phpDoc</dt> ' .$ str ;
652+ $ str = '<dt class="phpDoc">phpDoc</dt> ' ."\n"
653+ .$ str ;
613654 }
614655 return $ str ;
615656 }
@@ -630,17 +671,15 @@ protected function dumpProperties($abs)
630671 $ label .= ' <span class="text-muted">(via __debugInfo)</span> ' ;
631672 }
632673 $ str = '<dt class="properties"> ' .$ label .'</dt> ' ."\n" ;
633- if (isset ($ abs ['methods ' ]['__get ' ])) {
634- $ str .= '<dd class="magic-method info">This object has a <code>__get()</code> method</dd> ' ."\n" ;
635- }
674+ $ magicMethods = array_intersect (array ('__get ' ,'__set ' ), array_keys ($ abs ['methods ' ]));
675+ $ str .= $ this ->magicMethodInfo ($ magicMethods );
636676 foreach ($ abs ['properties ' ] as $ k => $ info ) {
637677 $ isPrivateAncestor = $ info ['visibility ' ] == 'private ' && $ info ['inheritedFrom ' ];
638678 $ classes = array_keys (array_filter (array (
639- 'property ' => true ,
640- $ info ['visibility ' ] => $ info ['visibility ' ] != 'debug ' ,
641679 'debug-value ' => !empty ($ info ['viaDebugInfo ' ]),
642680 'private-ancestor ' => $ isPrivateAncestor ,
643- 'magic-property ' => $ info ['isMagic ' ],
681+ 'property ' => true ,
682+ $ info ['visibility ' ] => $ info ['visibility ' ] != 'debug ' ,
644683 )));
645684 $ str .= '<dd class=" ' .implode (' ' , $ classes ).'"> '
646685 .'<span class="t_modifier_ ' .$ info ['visibility ' ].'"> ' .$ info ['visibility ' ].'</span> '
@@ -662,6 +701,28 @@ protected function dumpProperties($abs)
662701 return $ str ;
663702 }
664703
704+ /**
705+ * Generate some info regarding the given method names
706+ *
707+ * @param string[] $methods method names
708+ *
709+ * @return string
710+ */
711+ private function magicMethodInfo ($ methods )
712+ {
713+ if (!$ methods ) {
714+ return '' ;
715+ }
716+ foreach ($ methods as $ i => $ method ) {
717+ $ methods [$ i ] = '<code> ' .$ method .'</code> ' ;
718+ }
719+ $ methods = implode (' and ' , $ methods );
720+ $ methods = $ i == 0
721+ ? 'a ' .$ methods .' method '
722+ : $ methods .' methods ' ;
723+ return '<dd class="magic info">This object has ' .$ methods .'</dd> ' ."\n" ;
724+ }
725+
665726 /**
666727 * Wrap classname in span.t_classname
667728 * if namespaced'd additionally wrap namespace in span.namespace
0 commit comments