Subversion Repositories oidplus

Rev

Rev 514 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 514 Rev 585
Line 45... Line 45...
45
        function simplexml_load_file($file): SimpleXMLElement {
45
        function simplexml_load_file($file): SimpleXMLElement {
46
                return simplexml_load_string(file_get_contents($file));
46
                return simplexml_load_string(file_get_contents($file));
47
        }
47
        }
48
 
48
 
49
        function simplexml_load_string($testxml): SimpleXMLElement {
49
        function simplexml_load_string($testxml): SimpleXMLElement {
50
                $out = new SimpleXMLElement();
50
                $out = new SimpleXMLElement(); /** @phpstan-ignore-line */
51
 
51
 
52
                $testxml = preg_replace('@<!\\-\\-.+\\-\\->@','',$testxml); // remove comments
52
                $testxml = preg_replace('@<!\\-\\-.+\\-\\->@','',$testxml); // remove comments
53
                $testxml = preg_replace('@<(\\S+)[^>]*/>@smU','<\\1></\\1>',$testxml); // <x/> => <x></x>
53
                $testxml = preg_replace('@<(\\S+)[^>]*/>@smU','<\\1></\\1>',$testxml); // <x/> => <x></x>
54
 
54
 
55
                if ((stripos($testxml, '<?xml') !== false) || (stripos($testxml, '<!doctype') !== false)) {
55
                if ((stripos($testxml, '<?xml') !== false) || (stripos($testxml, '<!doctype') !== false)) {
Line 173... Line 173...
173
                        unset($this->$offset);
173
                        unset($this->$offset);
174
                }
174
                }
175
 
175
 
176
                public function __get($name) {
176
                public function __get($name) {
177
                        // Output nothing
177
                        // Output nothing
178
                        return new SimpleXMLElement();
178
                        return new SimpleXMLElement(); /** @phpstan-ignore-line */
179
                }
179
                }
180
 
180
 
181
                public function addChild($name, $val=null) {
181
                public function addChild($name, $val=null) {
182
                        if ($val == null) $val = new SimpleXMLElement();
182
                        if ($val == null) $val = new SimpleXMLElement(); /** @phpstan-ignore-line */
183
 
183
 
184
                        if ((substr(trim($val),0,1) === '<') || (trim($val) == '')) {
184
                        if ((substr(trim($val),0,1) === '<') || (trim($val) == '')) {
185
                                $val = simplexml_load_string($val);
185
                                $val = simplexml_load_string($val);
186
                        }
186
                        }
187
 
187
 
Line 201... Line 201...
201
                                }
201
                                }
202
 
202
 
203
                                if ($data[$name]->isArray()) {
203
                                if ($data[$name]->isArray()) {
204
                                        $data[$name]->addToArray($val);
204
                                        $data[$name]->addToArray($val);
205
                                } else {
205
                                } else {
206
                                        $tmp = new SimpleXMLElement();
206
                                        $tmp = new SimpleXMLElement(); /** @phpstan-ignore-line */
207
                                        $tmp->addToArray($data[$name]);
207
                                        $tmp->addToArray($data[$name]);
208
                                        $tmp->addToArray($val);
208
                                        $tmp->addToArray($val);
209
                                        $this->$name = $tmp;
209
                                        $this->$name = $tmp;
210
                                        $this->_attrs = array();
210
                                        $this->_attrs = array();
211
                                }
211
                                }