@@ -42,9 +42,6 @@ public function parse(?object $object, array &$dependencies): StructureElement
42
42
43
43
$ this ->element = $ object ->element ;
44
44
$ this ->parse_common ($ object , $ dependencies );
45
- if (!isset ($ object ->content ) && isset ($ object ->meta )) {
46
- return $ this ;
47
- }
48
45
49
46
if (isset ($ object ->content ) && is_array ($ object ->content )) {
50
47
$ this ->parse_array_content ($ object , $ dependencies );
@@ -74,25 +71,30 @@ public function parse(?object $object, array &$dependencies): StructureElement
74
71
/**
75
72
* Parse $this->value as a structure based on given content.
76
73
*
77
- * @param mixed $value APIB content
78
- * @param array $dependencies Object dependencies
74
+ * @param object $object APIB content
75
+ * @param array $dependencies Object dependencies
79
76
*
80
77
* @return void
81
78
*/
82
- protected function parse_value_structure ($ value , array &$ dependencies )
79
+ protected function parse_value_structure (object $ object , array &$ dependencies )
83
80
{
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 ;
85
92
case 'array ' :
86
93
$ struct = new ArrayStructureElement ();
87
94
break ;
88
95
case 'enum ' :
89
96
$ struct = new EnumStructureElement ();
90
97
break ;
91
- default :
92
- case 'object ' :
93
- $ value = $ value ->content ->value ?? null ;
94
- $ struct = $ this ->new_instance ();
95
- break ;
96
98
}
97
99
$ this ->value = $ struct ->parse ($ value , $ dependencies );
98
100
@@ -113,25 +115,26 @@ protected function new_instance(): StructureElement
113
115
/**
114
116
* Parse content formed as an array.
115
117
*
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
118
120
*
119
121
* @return void
120
122
*/
121
- protected function parse_array_content ($ object , array &$ dependencies ): void
123
+ protected function parse_array_content (? object $ object , array &$ dependencies ): void
122
124
{
123
125
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 ;
125
132
case 'enum ' :
126
133
$ struct = new EnumStructureElement ();
127
134
break ;
128
135
case 'array ' :
129
136
$ struct = new ArrayStructureElement ();
130
137
break ;
131
- default :
132
- case 'object ' :
133
- $ struct = $ this ->new_instance ();
134
- break ;
135
138
}
136
139
137
140
$ this ->value [] = $ struct ->parse ($ value , $ dependencies );
@@ -154,24 +157,22 @@ public function __toString(): string
154
157
}
155
158
156
159
if (is_array ($ this ->value )) {
157
- $ return = '<table class="table table-striped mdl-data-table mdl-js-data-table "> ' ;
160
+ $ return = '' ;
158
161
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)) {
160
163
$ return .= $ object ;
161
164
}
162
165
}
163
166
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> " ;
167
168
}
168
169
169
170
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> ' ;
171
172
}
172
173
173
174
if ($ this ->value === null && $ this ->key === null && $ this ->description !== null ) {
174
- return " <div class='description clearfix'> $ this -> description </div> " ;
175
+ return '' ;
175
176
}
176
177
177
178
if ($ this ->value === null && $ this ->key === null && $ this ->description === null ) {
@@ -218,15 +219,8 @@ protected function construct_string_return(string $value): string
218
219
if ($ this ->type === NULL ) {
219
220
return $ value ;
220
221
}
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 );
230
224
$ variable = '' ;
231
225
if ($ this ->is_variable ) {
232
226
$ variable = '<span class="fas fa-info variable-info" data-toggle="tooltip" data-placement="top" title="This is a variable key"></span> ' ;
0 commit comments