@@ -138,17 +138,15 @@ function add_warning($err_msg) { /* {{{ */
138
138
}
139
139
/* }}} */
140
140
141
- function create_markup_to_modifiers (ReflectionMethod $ method ) { /* {{{ */
142
- $ modifiers = Reflection::getModifierNames ($ method -> getModifiers () );
143
- $ markup = '' ;
141
+ function create_markup_to_modifiers (int $ modifierFlags ): array { /* {{{ */
142
+ $ modifiers = Reflection::getModifierNames ($ modifierFlags );
143
+ $ result = [] ;
144
144
145
- if ($ modifiers ) {
146
- foreach ($ modifiers as $ modifier ) {
147
- $ markup .= '<modifier> ' . $ modifier .'</modifier> ' ;
148
- }
149
- }
145
+ foreach ($ modifiers as $ modifier ) {
146
+ $ result [] = '<modifier> ' . $ modifier .'</modifier> ' ;
147
+ }
150
148
151
- return $ markup ;
149
+ return $ result ;
152
150
}
153
151
/* }}} */
154
152
@@ -395,7 +393,7 @@ function gen_method_markup(ReflectionMethod $method, $content) { /* {{{ */
395
393
$ content = preg_replace ('/\{METHOD_NAME\}/ ' , $ method ->name , $ content );
396
394
397
395
/* {MODIFIERS} */
398
- $ content = preg_replace ('/\{MODIFIERS\}/ ' , create_markup_to_modifiers ($ method ), $ content , 1 );
396
+ $ content = preg_replace ('/\{MODIFIERS\}/ ' , implode ( " " , create_markup_to_modifiers ($ method-> getModifiers ()) ), $ content , 1 );
399
397
400
398
/* {RETURN_TYPE} */
401
399
if (!$ method ->isConstructor ()) {
@@ -476,6 +474,7 @@ function gen_mapping_markup(ReflectionMethod $method, ReflectionFunction $functi
476
474
477
475
function gen_class_markup (ReflectionClass $ class , $ content ) { /* {{{ */
478
476
$ id = format_id ($ class ->getName ());
477
+ $ escapedName = addslashes ($ class ->getName ());
479
478
480
479
/* {CLASS_NAME} */
481
480
$ content = preg_replace ('/\{CLASS_NAME\}/ ' , $ class ->getName (), $ content );
@@ -573,7 +572,7 @@ function gen_class_markup(ReflectionClass $class, $content) { /* {{{ */
573
572
574
573
575
574
/* {PROPERTIES_LIST} */
576
- if ($ properties = $ class ->getProperties (ReflectionProperty:: IS_PUBLIC | ReflectionProperty:: IS_PROTECTED )) {
575
+ if ($ properties = $ class ->getProperties ()) {
577
576
$ ident = get_ident_size ('PROPERTIES_LIST ' , $ content );
578
577
$ inherited = array ();
579
578
@@ -587,17 +586,21 @@ function gen_class_markup(ReflectionClass $class, $content) { /* {{{ */
587
586
continue ;
588
587
}
589
588
590
- /* Get the modifier */
591
- preg_match ('/(\w+) \$/ ' , (string ) $ property , $ match );
592
-
593
589
$ markup .= str_repeat (' ' , $ ident ) ."<fieldsynopsis> " . PHP_EOL ;
594
- $ markup .= str_repeat (' ' , $ ident + 1 ) .'<modifier> ' . $ match [1 ] ."</modifier> " . PHP_EOL ;
595
- $ markup .= str_repeat (' ' , $ ident + 1 ) .'<varname linkend=" ' . $ id .'.props. ' . format_id ($ property ->getName ()) .'"> ' . $ property ->getName () ."</varname> " . PHP_EOL ;
596
- $ markup .= str_repeat (' ' , $ ident ) ."</fieldsynopsis> " . PHP_EOL ;
590
+ $ markup .= str_repeat (' ' , $ ident + 1 ) .
591
+ implode (
592
+ str_repeat (' ' , $ ident + 1 ) . PHP_EOL ,
593
+ create_markup_to_modifiers ($ property ->getModifiers ())
594
+ ) . PHP_EOL ;
595
+ if (PHP_VERSION_ID >= 74000 && $ property ->hasType ()) {
596
+ $ markup .= str_repeat (' ' , $ ident + 1 ) . get_type_as_xml_string ($ property ->getType ()). PHP_EOL ;
597
+ }
598
+ $ markup .= str_repeat (' ' , $ ident + 1 ) . '<varname linkend=" ' . $ id .'.props. ' . format_id ($ property ->getName ()) .'"> ' . $ property ->getName () ."</varname> " . PHP_EOL ;
599
+ $ markup .= str_repeat (' ' , $ ident ) . "</fieldsynopsis> " . PHP_EOL ;
597
600
}
598
601
599
602
if ($ markup ) {
600
- $ markup = "<classsynopsisinfo role= \"comment \">&Properties;</classsynopsisinfo> " . PHP_EOL . $ markup ;
603
+ $ markup = PHP_EOL . str_repeat ( ' ' , $ ident ) . "<classsynopsisinfo role= \"comment \">&Properties;</classsynopsisinfo> " . PHP_EOL . $ markup ;
601
604
}
602
605
603
606
if ($ inherited ) {
@@ -606,7 +609,7 @@ function gen_class_markup(ReflectionClass $class, $content) { /* {{{ */
606
609
}
607
610
$ markup .= '<classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo> ' . PHP_EOL ;
608
611
foreach ($ inherited as $ declaring_class ) {
609
- $ markup .= str_repeat (' ' , $ ident ) ."<xi:include xpointer= \"xmlns(db=http://docbook.org/ns/docbook) xpointer(id(' " . strtolower ($ declaring_class ) . ".synopsis')/descendant::db:fieldsynopsis) \"><xi:fallback/></xi:include> " . PHP_EOL ;
612
+ $ markup .= str_repeat (' ' , $ ident ) ."<xi:include xpointer= \"xmlns(db=http://docbook.org/ns/docbook) xpointer(id(' " . strtolower ($ declaring_class ) . ".synopsis')/descendant::db:fieldsynopsis) \"> " . PHP_EOL . str_repeat ( ' ' , $ ident + 1 ) . " <xi:fallback/> " . PHP_EOL . str_repeat ( ' ' , $ ident ) . " </xi:include> " . PHP_EOL ;
610
613
}
611
614
}
612
615
@@ -651,15 +654,15 @@ function gen_class_markup(ReflectionClass $class, $content) { /* {{{ */
651
654
$ ident = get_ident_size ('METHOD_XINCLUDE ' , $ content );
652
655
$ content = preg_replace ('/\{METHOD_XINCLUDE\}/ ' ,
653
656
PHP_EOL . str_repeat (' ' , $ ident ) . "<classsynopsisinfo role= \"comment \">&Methods;</classsynopsisinfo> " . PHP_EOL .
654
- str_repeat (' ' , $ ident ) ."<xi:include xpointer= \"xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class. " . $ id ."')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not( @role='procedural') ]) \"><xi:fallback/></xi:include> " ,
657
+ str_repeat (' ' , $ ident ) ."<xi:include xpointer= \"xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class. " . $ id ."')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role=' " . $ escapedName . " ' ]) \"> " . PHP_EOL . str_repeat ( ' ' , $ ident + 1 ) . " <xi:fallback/> " . PHP_EOL . str_repeat ( ' ' , $ ident ) . " </xi:include> " ,
655
658
$ content , 1 );
656
659
657
660
/* {INHERITED_XINCLUDE} */
658
661
if ($ parent ) {
659
662
$ ident = get_ident_size ('INHERITED_XINCLUDE ' , $ content );
660
663
$ content = preg_replace ('/\{INHERITED_XINCLUDE\}/ ' ,
661
664
PHP_EOL . str_repeat (' ' , $ ident ) ."<classsynopsisinfo role= \"comment \">&InheritedMethods;</classsynopsisinfo> " . PHP_EOL .
662
- str_repeat (' ' , $ ident ) ."<xi:include xpointer= \"xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class. " . format_id ($ parent ->getName ()) ."')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[not( @role='procedural') ]) \"><xi:fallback/></xi:include> " . PHP_EOL ,
665
+ str_repeat (' ' , $ ident ) ."<xi:include xpointer= \"xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class. " . format_id ($ parent ->getName ()) ."')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role=' " . $ escapedName . " ' ]) \"> " . PHP_EOL . str_repeat ( ' ' , $ ident + 1 ) . " <xi:fallback/> " . PHP_EOL . str_repeat ( ' ' , $ ident ) . " </xi:include> " . PHP_EOL ,
663
666
$ content , 1 );
664
667
} else {
665
668
$ content = preg_replace ('/^\s*\{INHERITED_XINCLUDE\}.*?\n/m ' , '' , $ content , 1 );
0 commit comments