@@ -138,17 +138,15 @@ function add_warning($err_msg) { /* {{{ */
138138}
139139/* }}} */
140140
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 = [] ;
144144
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+ }
150148
151- return $ markup ;
149+ return $ result ;
152150}
153151/* }}} */
154152
@@ -395,7 +393,7 @@ function gen_method_markup(ReflectionMethod $method, $content) { /* {{{ */
395393 $ content = preg_replace ('/\{METHOD_NAME\}/ ' , $ method ->name , $ content );
396394
397395 /* {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 );
399397
400398 /* {RETURN_TYPE} */
401399 if (!$ method ->isConstructor ()) {
@@ -476,6 +474,7 @@ function gen_mapping_markup(ReflectionMethod $method, ReflectionFunction $functi
476474
477475function gen_class_markup (ReflectionClass $ class , $ content ) { /* {{{ */
478476 $ id = format_id ($ class ->getName ());
477+ $ escapedName = addslashes ($ class ->getName ());
479478
480479 /* {CLASS_NAME} */
481480 $ content = preg_replace ('/\{CLASS_NAME\}/ ' , $ class ->getName (), $ content );
@@ -573,7 +572,7 @@ function gen_class_markup(ReflectionClass $class, $content) { /* {{{ */
573572
574573
575574 /* {PROPERTIES_LIST} */
576- if ($ properties = $ class ->getProperties (ReflectionProperty:: IS_PUBLIC | ReflectionProperty:: IS_PROTECTED )) {
575+ if ($ properties = $ class ->getProperties ()) {
577576 $ ident = get_ident_size ('PROPERTIES_LIST ' , $ content );
578577 $ inherited = array ();
579578
@@ -587,17 +586,21 @@ function gen_class_markup(ReflectionClass $class, $content) { /* {{{ */
587586 continue ;
588587 }
589588
590- /* Get the modifier */
591- preg_match ('/(\w+) \$/ ' , (string ) $ property , $ match );
592-
593589 $ 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 ;
597600 }
598601
599602 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 ;
601604 }
602605
603606 if ($ inherited ) {
@@ -606,7 +609,7 @@ function gen_class_markup(ReflectionClass $class, $content) { /* {{{ */
606609 }
607610 $ markup .= '<classsynopsisinfo role="comment">&InheritedProperties;</classsynopsisinfo> ' . PHP_EOL ;
608611 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 ;
610613 }
611614 }
612615
@@ -651,15 +654,15 @@ function gen_class_markup(ReflectionClass $class, $content) { /* {{{ */
651654 $ ident = get_ident_size ('METHOD_XINCLUDE ' , $ content );
652655 $ content = preg_replace ('/\{METHOD_XINCLUDE\}/ ' ,
653656 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> " ,
655658 $ content , 1 );
656659
657660 /* {INHERITED_XINCLUDE} */
658661 if ($ parent ) {
659662 $ ident = get_ident_size ('INHERITED_XINCLUDE ' , $ content );
660663 $ content = preg_replace ('/\{INHERITED_XINCLUDE\}/ ' ,
661664 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 ,
663666 $ content , 1 );
664667 } else {
665668 $ content = preg_replace ('/^\s*\{INHERITED_XINCLUDE\}.*?\n/m ' , '' , $ content , 1 );
0 commit comments