@@ -42,9 +42,6 @@ public function parse(?object $object, array &$dependencies): StructureElement
4242
4343 $ this ->element = $ object ->element ;
4444 $ this ->parse_common ($ object , $ dependencies );
45- if (!isset ($ object ->content ) && isset ($ object ->meta )) {
46- return $ this ;
47- }
4845
4946 if (isset ($ object ->content ) && is_array ($ object ->content )) {
5047 $ this ->parse_array_content ($ object , $ dependencies );
@@ -74,25 +71,30 @@ public function parse(?object $object, array &$dependencies): StructureElement
7471 /**
7572 * Parse $this->value as a structure based on given content.
7673 *
77- * @param mixed $value APIB content
78- * @param array $dependencies Object dependencies
74+ * @param object $object APIB content
75+ * @param array $dependencies Object dependencies
7976 *
8077 * @return void
8178 */
82- protected function parse_value_structure ($ value , array &$ dependencies )
79+ protected function parse_value_structure (object $ object , array &$ dependencies )
8380 {
84- switch ($ this ->type ) {
81+ $ type = $ this ->element === 'member ' ? $ this ->type : $ this ->element ;
82+ if (!isset ($ object ->content ->value ) && !isset ($ object ->attributes ->enumerations )) {
83+ return ;
84+ }
85+
86+ $ value = $ object ->content ->value ?? $ object ;
87+ switch ($ type ) {
88+ default :
89+ case 'object ' :
90+ $ struct = $ this ->new_instance ();
91+ break ;
8592 case 'array ' :
8693 $ struct = new ArrayStructureElement ();
8794 break ;
8895 case 'enum ' :
8996 $ struct = new EnumStructureElement ();
9097 break ;
91- default :
92- case 'object ' :
93- $ value = $ value ->content ->value ?? null ;
94- $ struct = $ this ->new_instance ();
95- break ;
9698 }
9799 $ this ->value = $ struct ->parse ($ value , $ dependencies );
98100
@@ -113,25 +115,26 @@ protected function new_instance(): StructureElement
113115 /**
114116 * Parse content formed as an array.
115117 *
116- * @param mixed $object APIB content
117- * @param array $dependencies Object dependencies
118+ * @param object|null $object APIB content
119+ * @param array $dependencies Object dependencies
118120 *
119121 * @return void
120122 */
121- protected function parse_array_content ($ object , array &$ dependencies ): void
123+ protected function parse_array_content (? object $ object , array &$ dependencies ): void
122124 {
123125 foreach ($ object ->content as $ value ) {
124- switch ($ this ->type ){
126+ $ type = $ this ->element === 'member ' ? $ this ->type : $ this ->element ;
127+ switch ($ type ){
128+ default :
129+ case 'object ' :
130+ $ struct = $ this ->new_instance ();
131+ break ;
125132 case 'enum ' :
126133 $ struct = new EnumStructureElement ();
127134 break ;
128135 case 'array ' :
129136 $ struct = new ArrayStructureElement ();
130137 break ;
131- default :
132- case 'object ' :
133- $ struct = $ this ->new_instance ();
134- break ;
135138 }
136139
137140 $ this ->value [] = $ struct ->parse ($ value , $ dependencies );
@@ -154,24 +157,22 @@ public function __toString(): string
154157 }
155158
156159 if (is_array ($ this ->value )) {
157- $ return = '<table class="table table-striped mdl-data-table mdl-js-data-table "> ' ;
160+ $ return = '' ;
158161 foreach ($ this ->value as $ object ) {
159- if (is_string ($ object ) || is_subclass_of (get_class ($ object ), BasicStructureElement ::class)) {
162+ if (is_string ($ object ) || is_subclass_of (get_class ($ object ), StructureElement ::class)) {
160163 $ return .= $ object ;
161164 }
162165 }
163166
164- $ return .= '</table> ' ;
165-
166- return $ this ->description . $ return ;
167+ return "<table class= \"table table-striped mdl-data-table mdl-js-data-table \"> $ return</table> " ;
167168 }
168169
169170 if ($ this ->ref !== null ) {
170- return '<p>Inherits from <a href="#object- ' . strtolower ($ this ->ref ) . '"> ' . $ this ->ref . '</a></p> ' . $ this -> description ;
171+ return '<p>Inherits from <a href="#object- ' . strtolower ($ this ->ref ) . '"> ' . $ this ->ref . '</a></p> ' ;
171172 }
172173
173174 if ($ this ->value === null && $ this ->key === null && $ this ->description !== null ) {
174- return " <div class='description clearfix'> $ this -> description </div> " ;
175+ return '' ;
175176 }
176177
177178 if ($ this ->value === null && $ this ->key === null && $ this ->description === null ) {
@@ -218,15 +219,8 @@ protected function construct_string_return(string $value): string
218219 if ($ this ->type === NULL ) {
219220 return $ value ;
220221 }
221- if (!in_array ($ this ->type , self ::DEFAULTS )) {
222- $ type = '<a class="code" href="#object- ' . str_replace (
223- ' ' ,
224- '- ' ,
225- strtolower ($ this ->type )
226- ) . '"> ' . $ this ->type . '</a> ' ;
227- } else {
228- $ type = '<code> ' . $ this ->type . '</code> ' ;
229- }
222+
223+ $ type = $ this ->get_element_as_html ($ this ->type );
230224 $ variable = '' ;
231225 if ($ this ->is_variable ) {
232226 $ variable = '<span class="fas fa-info variable-info" data-toggle="tooltip" data-placement="top" title="This is a variable key"></span> ' ;
0 commit comments