3v4l.org

run code in 300+ PHP versions simultaneously
<?php class XMLParser { private static $xml = null; private static $encoding = 'UTF-8'; /** * Initialize the root XML node [optional] * @param $version * @param $encoding * @param $format_output */ public static function init($version = '1.0', $encoding = 'UTF-8', $format_output = true) { self::$xml = new DomDocument($version, $encoding); self::$xml->formatOutput = $format_output; self::$encoding = $encoding; } /** * Convert an Array to XML * @param string $node_name - name of the root node to be converted * @param array $arr - aray to be converterd * @return DomDocument */ public static function &createXML($node_name, $arr=array()) { $xml = self::getXMLRoot(); $xml->appendChild(self::convert($node_name, $arr)); self::$xml = null; // clear the xml node in the class for 2nd time use. return $xml; } /** * Convert an Array to XML * @param string $node_name - name of the root node to be converted * @param array $arr - aray to be converterd * @return DOMNode */ private static function &convert($node_name, $arr=array()) { //print_arr($node_name); $xml = self::getXMLRoot(); $node = $xml->createElement($node_name); if(is_array($arr)){ // get the attributes first.; if(isset($arr['@attributes'])) { foreach($arr['@attributes'] as $key => $value) { if(!self::isValidTagName($key)) { throw new Exception('[XMLParser] Illegal character in attribute name. attribute: '.$key.' in node: '.$node_name); } $node->setAttribute($key, htmlspecialchars(self::bool2str($value), ENT_QUOTES, self::$encoding)); } unset($arr['@attributes']); //remove the key from the array once done. } // check if it has a value stored in @value, if yes store the value and return // else check if its directly stored as string if(isset($arr['@value'])) { $node->appendChild($xml->createTextNode(htmlspecialchars(self::bool2str($arr['@value']), ENT_QUOTES, self::$encoding))); unset($arr['@value']); //remove the key from the array once done. //return from recursion, as a note with value cannot have child nodes. return $node; } else if(isset($arr['@cdata'])) { $node->appendChild($xml->createCDATASection(self::bool2str($arr['@cdata']))); unset($arr['@cdata']); //remove the key from the array once done. //return from recursion, as a note with cdata cannot have child nodes. return $node; } } //create subnodes using recursion if(is_array($arr)){ // recurse to get the node for that key foreach($arr as $key=>$value){ if(!self::isValidTagName($key)) { throw new Exception('[XMLParser] Illegal character in tag name. tag: '.$key.' in node: '.$node_name); } if(is_array($value) && is_numeric(key($value))) { // MORE THAN ONE NODE OF ITS KIND; // if the new array is numeric index, means it is array of nodes of the same kind // it should follow the parent key name foreach($value as $k=>$v){ $node->appendChild(self::convert($key, $v)); } } else { // ONLY ONE NODE OF ITS KIND $node->appendChild(self::convert($key, $value)); } unset($arr[$key]); //remove the key from the array once done. } } // after we are done with all the keys in the array (if it is one) // we check if it has any text value, if yes, append it. if(!is_array($arr)) { $node->appendChild($xml->createTextNode(htmlspecialchars(self::bool2str($arr), ENT_QUOTES, self::$encoding))); } return $node; } /* * Get the root XML node, if there isn't one, create it. */ private static function getXMLRoot(){ if(empty(self::$xml)) { self::init(); } return self::$xml; } /* * Get string representation of boolean value */ private static function bool2str($v){ //convert boolean to text value. $v = $v === true ? 'true' : $v; $v = $v === false ? 'false' : $v; return $v; } /* * Check if the tag name or attribute name contains illegal characters * Ref: http://www.w3.org/TR/xml/#sec-common-syn */ private static function isValidTagName($tag){ $pattern = '/^[a-z_]+[a-z0-9\:\-\.\_]*[^:]*$/i'; return preg_match($pattern, $tag, $matches) && $matches[0] == $tag; } } /** * XML2Array: A class to convert XML to array in PHP * It returns the array which can be converted back to XML using the Array2XML script * It takes an XML string or a DOMDocument object as an input. * * See Array2XML: http://www.lalit.org/lab/convert-php-array-to-xml-with-attributes * * Author : Lalit Patel * Website: http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array * License: Apache License 2.0 * http://www.apache.org/licenses/LICENSE-2.0 * Version: 0.1 (07 Dec 2011) * Version: 0.2 (04 Mar 2012) * Fixed typo 'DomDocument' to 'DOMDocument' * * Usage: * $array = XML2Array::createArray($xml); */ class XML2Array { private static $xml = null; private static $encoding = 'UTF-8'; /** * Initialize the root XML node [optional] * @param $version * @param $encoding * @param $format_output */ public static function init($version = '1.0', $encoding = 'UTF-8', $format_output = true) { self::$xml = new DOMDocument($version, $encoding); self::$xml->formatOutput = $format_output; self::$encoding = $encoding; } /** * Convert an XML to Array * @param string $node_name - name of the root node to be converted * @param array $arr - aray to be converterd * @return DOMDocument */ public static function &createArray($input_xml) { $xml = self::getXMLRoot(); if(is_string($input_xml)) { $parsed = $xml->loadXML($input_xml); if(!$parsed) { throw new Exception('[XML2Array] Error parsing the XML string.'); } } else { if(get_class($input_xml) != 'DOMDocument') { throw new Exception('[XML2Array] The input XML object should be of type: DOMDocument.'); } $xml = self::$xml = $input_xml; } $array[$xml->documentElement->tagName] = self::convert($xml->documentElement); self::$xml = null; // clear the xml node in the class for 2nd time use. return $array; } /** * Convert an Array to XML * @param mixed $node - XML as a string or as an object of DOMDocument * @return mixed */ private static function &convert($node) { $output = array(); switch ($node->nodeType) { case XML_CDATA_SECTION_NODE: $output['@cdata'] = trim($node->textContent); break; case XML_TEXT_NODE: $output = trim($node->textContent); break; case XML_ELEMENT_NODE: // for each child node, call the covert function recursively for ($i=0, $m=$node->childNodes->length; $i<$m; $i++) { $child = $node->childNodes->item($i); $v = self::convert($child); if(isset($child->tagName)) { $t = $child->tagName; // assume more nodes of same kind are coming if(!isset($output[$t])) { $output[$t] = array(); } $output[$t][] = $v; } else { //check if it is not an empty text node if($v !== '') { $output = $v; } } } if(is_array($output)) { // if only one node of its kind, assign it directly instead if array($value); foreach ($output as $t => $v) { if(is_array($v) && count($v)==1) { $output[$t] = $v[0]; } } if(empty($output)) { //for empty nodes $output = ''; } } // loop through the attributes and collect them if($node->attributes->length) { $a = array(); foreach($node->attributes as $attrName => $attrNode) { $a[$attrName] = (string) $attrNode->value; } // if its an leaf node, store the value in @value instead of directly storing it. if(!is_array($output)) { $output = array('@value' => $output); } $output['@attributes'] = $a; } break; } return $output; } /* * Get the root XML node, if there isn't one, create it. */ private static function getXMLRoot(){ if(empty(self::$xml)) { self::init(); } return self::$xml; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nGtTN
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                            'xmlparser'
  271     1      > RETURN                                                   1

Class XMLParser:
Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nGtTN
function name:  init
number of ops:  15
compiled vars:  !0 = $version, !1 = $encoding, !2 = $format_output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV_INIT                                        !0      '1.0'
          1        RECV_INIT                                        !1      'UTF-8'
          2        RECV_INIT                                        !2      <true>
   14     3        NEW                                              $4      'DomDocument'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
          7        ASSIGN_STATIC_PROP                                       'xml'
          8        OP_DATA                                                  $4
   15     9        FETCH_STATIC_PROP_W          unknown             $6      'xml'
         10        ASSIGN_OBJ                                               $6, 'formatOutput'
         11        OP_DATA                                                  !2
   16    12        ASSIGN_STATIC_PROP                                       'encoding'
         13        OP_DATA                                                  !1
   17    14      > RETURN                                                   null

End of function init

Function createxml:
Finding entry points
Branch analysis from position: 0
Return found
filename:       /in/nGtTN
function name:  createXML
number of ops:  16
compiled vars:  !0 = $node_name, !1 = $arr, !2 = $xml
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   26     2        INIT_STATIC_METHOD_CALL                                  'getXMLRoot'
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !2, $3
   27     5        INIT_METHOD_CALL                                         !2, 'appendChild'
          6        INIT_STATIC_METHOD_CALL                                  'convert'
          7        SEND_VAR_EX                                              !0
          8        SEND_VAR_EX                                              !1
          9        DO_FCALL                                      0  $5      
         10        SEND_VAR_NO_REF_EX                                       $5
         11        DO_FCALL                                      0          
   29    12        ASSIGN_STATIC_PROP                                       'xml'
         13        OP_DATA                                                  null
   30    14      > RETURN_BY_REF                                            !2
   31    15*     > RETURN_BY_REF                                            null

End of function createxml

Function convert:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 82
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 45
Branch analysis from position: 13
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 43
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 43
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 67
Branch analysis from position: 47
Return found
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 69, Position 2 = 82
Branch analysis from position: 69
Return found
Branch analysis from position: 82
2 jumps found. (Code = 43) Position 1 = 84, Position 2 = 132
Branch analysis from position: 84
2 jumps found. (Code = 77) Position 1 = 85, Position 2 = 131
Branch analysis from position: 85
2 jumps found. (Code = 78) Position 1 = 86, Position 2 = 131
Branch analysis from position: 86
2 jumps found. (Code = 43) Position 1 = 92, Position 2 = 99
Branch analysis from position: 92
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 99
2 jumps found. (Code = 46) Position 1 = 101, Position 2 = 108
Branch analysis from position: 101
2 jumps found. (Code = 43) Position 1 = 109, Position 2 = 122
Branch analysis from position: 109
2 jumps found. (Code = 77) Position 1 = 110, Position 2 = 120
Branch analysis from position: 110
2 jumps found. (Code = 78) Position 1 = 111, Position 2 = 120
Branch analysis from position: 111
1 jumps found. (Code = 42) Position 1 = 110
Branch analysis from position: 110
Branch analysis from position: 120
1 jumps found. (Code = 42) Position 1 = 129
Branch analysis from position: 129
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
Branch analysis from position: 120
Branch analysis from position: 122
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
Branch analysis from position: 108
Branch analysis from position: 131
2 jumps found. (Code = 43) Position 1 = 135, Position 2 = 150
Branch analysis from position: 135
Return found
Branch analysis from position: 150
Branch analysis from position: 131
Branch analysis from position: 132
Branch analysis from position: 43
Branch analysis from position: 45
Branch analysis from position: 82
filename:       /in/nGtTN
function name:  convert
number of ops:  152
compiled vars:  !0 = $node_name, !1 = $arr, !2 = $xml, !3 = $node, !4 = $value, !5 = $key, !6 = $v, !7 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   42     2        INIT_STATIC_METHOD_CALL                                  'getXMLRoot'
          3        DO_FCALL                                      0  $8      
          4        ASSIGN                                                   !2, $8
   43     5        INIT_METHOD_CALL                                         !2, 'createElement'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $10     
          8        ASSIGN                                                   !3, $10
   45     9        TYPE_CHECK                                  128          !1
         10      > JMPZ                                                     ~12, ->82
   47    11    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, '%40attributes'
         12      > JMPZ                                                     ~13, ->45
   48    13    >   FETCH_DIM_R                                      ~14     !1, '%40attributes'
         14      > FE_RESET_R                                       $15     ~14, ->43
         15    > > FE_FETCH_R                                       ~16     $15, !4, ->43
         16    >   ASSIGN                                                   !5, ~16
   49    17        INIT_STATIC_METHOD_CALL                                  'isValidTagName'
         18        SEND_VAR_EX                                              !5
         19        DO_FCALL                                      0  $18     
         20        BOOL_NOT                                         ~19     $18
         21      > JMPZ                                                     ~19, ->29
   50    22    >   NEW                                              $20     'Exception'
         23        CONCAT                                           ~21     '%5BXMLParser%5D+Illegal+character+in+attribute+name.+attribute%3A+', !5
         24        CONCAT                                           ~22     ~21, '+in+node%3A+'
         25        CONCAT                                           ~23     ~22, !0
         26        SEND_VAL_EX                                              ~23
         27        DO_FCALL                                      0          
         28      > THROW                                         0          $20
   52    29    >   INIT_METHOD_CALL                                         !3, 'setAttribute'
         30        SEND_VAR_EX                                              !5
         31        INIT_FCALL                                               'htmlspecialchars'
         32        INIT_STATIC_METHOD_CALL                                  'bool2str'
         33        SEND_VAR_EX                                              !4
         34        DO_FCALL                                      0  $25     
         35        SEND_VAR                                                 $25
         36        SEND_VAL                                                 3
         37        FETCH_STATIC_PROP_R          unknown             ~26     'encoding'
         38        SEND_VAL                                                 ~26
         39        DO_ICALL                                         $27     
         40        SEND_VAR_NO_REF_EX                                       $27
         41        DO_FCALL                                      0          
   48    42      > JMP                                                      ->15
         43    >   FE_FREE                                                  $15
   54    44        UNSET_DIM                                                !1, '%40attributes'
   59    45    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, '%40value'
         46      > JMPZ                                                     ~29, ->67
   60    47    >   INIT_METHOD_CALL                                         !3, 'appendChild'
         48        INIT_METHOD_CALL                                         !2, 'createTextNode'
         49        INIT_FCALL                                               'htmlspecialchars'
         50        INIT_STATIC_METHOD_CALL                                  'bool2str'
         51        CHECK_FUNC_ARG                                           
         52        FETCH_DIM_FUNC_ARG                               $30     !1, '%40value'
         53        SEND_FUNC_ARG                                            $30
         54        DO_FCALL                                      0  $31     
         55        SEND_VAR                                                 $31
         56        SEND_VAL                                                 3
         57        FETCH_STATIC_PROP_R          unknown             ~32     'encoding'
         58        SEND_VAL                                                 ~32
         59        DO_ICALL                                         $33     
         60        SEND_VAR_NO_REF_EX                                       $33
         61        DO_FCALL                                      0  $34     
         62        SEND_VAR_NO_REF_EX                                       $34
         63        DO_FCALL                                      0          
   61    64        UNSET_DIM                                                !1, '%40value'
   63    65      > RETURN_BY_REF                                            !3
         66*       JMP                                                      ->82
   64    67    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, '%40cdata'
         68      > JMPZ                                                     ~36, ->82
   65    69    >   INIT_METHOD_CALL                                         !3, 'appendChild'
         70        INIT_METHOD_CALL                                         !2, 'createCDATASection'
         71        INIT_STATIC_METHOD_CALL                                  'bool2str'
         72        CHECK_FUNC_ARG                                           
         73        FETCH_DIM_FUNC_ARG                               $37     !1, '%40cdata'
         74        SEND_FUNC_ARG                                            $37
         75        DO_FCALL                                      0  $38     
         76        SEND_VAR_NO_REF_EX                                       $38
         77        DO_FCALL                                      0  $39     
         78        SEND_VAR_NO_REF_EX                                       $39
         79        DO_FCALL                                      0          
   66    80        UNSET_DIM                                                !1, '%40cdata'
   68    81      > RETURN_BY_REF                                            !3
   73    82    >   TYPE_CHECK                                  128          !1
         83      > JMPZ                                                     ~41, ->132
   75    84    > > FE_RESET_R                                       $42     !1, ->131
         85    > > FE_FETCH_R                                       ~43     $42, !4, ->131
         86    >   ASSIGN                                                   !5, ~43
   76    87        INIT_STATIC_METHOD_CALL                                  'isValidTagName'
         88        SEND_VAR_EX                                              !5
         89        DO_FCALL                                      0  $45     
         90        BOOL_NOT                                         ~46     $45
         91      > JMPZ                                                     ~46, ->99
   77    92    >   NEW                                              $47     'Exception'
         93        CONCAT                                           ~48     '%5BXMLParser%5D+Illegal+character+in+tag+name.+tag%3A+', !5
         94        CONCAT                                           ~49     ~48, '+in+node%3A+'
         95        CONCAT                                           ~50     ~49, !0
         96        SEND_VAL_EX                                              ~50
         97        DO_FCALL                                      0          
         98      > THROW                                         0          $47
   79    99    >   TYPE_CHECK                                  128  ~52     !4
        100      > JMPZ_EX                                          ~52     ~52, ->108
        101    >   INIT_FCALL                                               'is_numeric'
        102        INIT_FCALL                                               'key'
        103        SEND_VAR                                                 !4
        104        DO_ICALL                                         $53     
        105        SEND_VAR                                                 $53
        106        DO_ICALL                                         $54     
        107        BOOL                                             ~52     $54
        108    > > JMPZ                                                     ~52, ->122
   83   109    > > FE_RESET_R                                       $55     !4, ->120
        110    > > FE_FETCH_R                                       ~56     $55, !6, ->120
        111    >   ASSIGN                                                   !7, ~56
   84   112        INIT_METHOD_CALL                                         !3, 'appendChild'
        113        INIT_STATIC_METHOD_CALL                                  'convert'
        114        SEND_VAR                                                 !5
        115        SEND_VAR                                                 !6
        116        DO_FCALL                                      0  $58     
        117        SEND_VAR_NO_REF_EX                                       $58
        118        DO_FCALL                                      0          
   83   119      > JMP                                                      ->110
        120    >   FE_FREE                                                  $55
        121      > JMP                                                      ->129
   88   122    >   INIT_METHOD_CALL                                         !3, 'appendChild'
        123        INIT_STATIC_METHOD_CALL                                  'convert'
        124        SEND_VAR                                                 !5
        125        SEND_VAR                                                 !4
        126        DO_FCALL                                      0  $60     
        127        SEND_VAR_NO_REF_EX                                       $60
        128        DO_FCALL                                      0          
   90   129    >   UNSET_DIM                                                !1, !5
   75   130      > JMP                                                      ->85
        131    >   FE_FREE                                                  $42
   96   132    >   TYPE_CHECK                                  128  ~62     !1
        133        BOOL_NOT                                         ~63     ~62
        134      > JMPZ                                                     ~63, ->150
   97   135    >   INIT_METHOD_CALL                                         !3, 'appendChild'
        136        INIT_METHOD_CALL                                         !2, 'createTextNode'
        137        INIT_FCALL                                               'htmlspecialchars'
        138        INIT_STATIC_METHOD_CALL                                  'bool2str'
        139        SEND_VAR_EX                                              !1
        140        DO_FCALL                                      0  $64     
        141        SEND_VAR                                                 $64
        142        SEND_VAL                                                 3
        143        FETCH_STATIC_PROP_R          unknown             ~65     'encoding'
        144        SEND_VAL                                                 ~65
        145        DO_ICALL                                         $66     
        146        SEND_VAR_NO_REF_EX                                       $66
        147        DO_FCALL                                      0  $67     
        148        SEND_VAR_NO_REF_EX                                       $67
        149        DO_FCALL                                      0          
  100   150    > > RETURN_BY_REF                                            !3
  101   151*     > RETURN_BY_REF                                            null

End of function convert

Function getxmlroot:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
filename:       /in/nGtTN
function name:  getXMLRoot
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  107     0  E >   ISSET_ISEMPTY_STATIC_PROP                                'xml'
          1      > JMPZ                                                     ~0, ->4
  108     2    >   INIT_STATIC_METHOD_CALL                                  'init'
          3        DO_FCALL                                      0          
  110     4    >   FETCH_STATIC_PROP_R          unknown             ~2      'xml'
          5      > RETURN                                                   ~2
  111     6*     > RETURN                                                   null

End of function getxmlroot

Function bool2str:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 5
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
Branch analysis from position: 11
filename:       /in/nGtTN
function name:  bool2str
number of ops:  15
compiled vars:  !0 = $v
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  116     0  E >   RECV                                             !0      
  118     1        TYPE_CHECK                                    8          !0
          2      > JMPZ                                                     ~1, ->5
          3    >   QM_ASSIGN                                        ~2      'true'
          4      > JMP                                                      ->6
          5    >   QM_ASSIGN                                        ~2      !0
          6    >   ASSIGN                                                   !0, ~2
  119     7        TYPE_CHECK                                    4          !0
          8      > JMPZ                                                     ~4, ->11
          9    >   QM_ASSIGN                                        ~5      'false'
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~5      !0
         12    >   ASSIGN                                                   !0, ~5
  120    13      > RETURN                                                   !0
  121    14*     > RETURN                                                   null

End of function bool2str

Function isvalidtagname:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/nGtTN
function name:  isValidTagName
number of ops:  13
compiled vars:  !0 = $tag, !1 = $pattern, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  127     0  E >   RECV                                             !0      
  128     1        ASSIGN                                                   !1, '%2F%5E%5Ba-z_%5D%2B%5Ba-z0-9%5C%3A%5C-%5C.%5C_%5D%2A%5B%5E%3A%5D%2A%24%2Fi'
  129     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $4      
          7      > JMPZ_EX                                          ~5      $4, ->11
          8    >   FETCH_DIM_R                                      ~6      !2, 0
          9        IS_EQUAL                                         ~7      !0, ~6
         10        BOOL                                             ~5      ~7
         11    > > RETURN                                                   ~5
  130    12*     > RETURN                                                   null

End of function isvalidtagname

End of class XMLParser.

Class XML2Array:
Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nGtTN
function name:  init
number of ops:  15
compiled vars:  !0 = $version, !1 = $encoding, !2 = $format_output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  163     0  E >   RECV_INIT                                        !0      '1.0'
          1        RECV_INIT                                        !1      'UTF-8'
          2        RECV_INIT                                        !2      <true>
  164     3        NEW                                              $4      'DOMDocument'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
          7        ASSIGN_STATIC_PROP                                       'xml'
          8        OP_DATA                                                  $4
  165     9        FETCH_STATIC_PROP_W          unknown             $6      'xml'
         10        ASSIGN_OBJ                                               $6, 'formatOutput'
         11        OP_DATA                                                  !2
  166    12        ASSIGN_STATIC_PROP                                       'encoding'
         13        OP_DATA                                                  !1
  167    14      > RETURN                                                   null

End of function init

Function createarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Return found
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 24
Return found
filename:       /in/nGtTN
function name:  createArray
number of ops:  40
compiled vars:  !0 = $input_xml, !1 = $xml, !2 = $parsed, !3 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  175     0  E >   RECV                                             !0      
  176     1        INIT_STATIC_METHOD_CALL                                  'getXMLRoot'
          2        DO_FCALL                                      0  $4      
          3        ASSIGN                                                   !1, $4
  177     4        TYPE_CHECK                                   64          !0
          5      > JMPZ                                                     ~6, ->17
  178     6    >   INIT_METHOD_CALL                                         !1, 'loadXML'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $7      
          9        ASSIGN                                                   !2, $7
  179    10        BOOL_NOT                                         ~9      !2
         11      > JMPZ                                                     ~9, ->16
  180    12    >   NEW                                              $10     'Exception'
         13        SEND_VAL_EX                                              '%5BXML2Array%5D+Error+parsing+the+XML+string.'
         14        DO_FCALL                                      0          
         15      > THROW                                         0          $10
         16    > > JMP                                                      ->27
  183    17    >   GET_CLASS                                        ~12     !0
         18        IS_NOT_EQUAL                                             ~12, 'DOMDocument'
         19      > JMPZ                                                     ~13, ->24
  184    20    >   NEW                                              $14     'Exception'
         21        SEND_VAL_EX                                              '%5BXML2Array%5D+The+input+XML+object+should+be+of+type%3A+DOMDocument.'
         22        DO_FCALL                                      0          
         23      > THROW                                         0          $14
  186    24    >   ASSIGN_STATIC_PROP                               ~16     'xml'
         25        OP_DATA                                                  !0
         26        ASSIGN                                                   !1, ~16
  188    27    >   FETCH_OBJ_R                                      ~18     !1, 'documentElement'
         28        FETCH_OBJ_R                                      ~19     ~18, 'tagName'
         29        INIT_STATIC_METHOD_CALL                                  'convert'
         30        CHECK_FUNC_ARG                                           
         31        FETCH_OBJ_FUNC_ARG                               $21     !1, 'documentElement'
         32        SEND_FUNC_ARG                                            $21
         33        DO_FCALL                                      0  $22     
         34        ASSIGN_DIM                                               !3, ~19
         35        OP_DATA                                                  $22
  189    36        ASSIGN_STATIC_PROP                                       'xml'
         37        OP_DATA                                                  null
  190    38      > RETURN_BY_REF                                            !3
  191    39*     > RETURN_BY_REF                                            null

End of function createarray

Function convert:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 23
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 97
Branch analysis from position: 97
Return found
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 56, Position 2 = 28
Branch analysis from position: 56
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 75
Branch analysis from position: 58
2 jumps found. (Code = 77) Position 1 = 59, Position 2 = 71
Branch analysis from position: 59
2 jumps found. (Code = 78) Position 1 = 60, Position 2 = 71
Branch analysis from position: 60
2 jumps found. (Code = 46) Position 1 = 63, Position 2 = 66
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 70
Branch analysis from position: 67
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
Branch analysis from position: 70
Branch analysis from position: 66
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 75
Branch analysis from position: 74
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 96
Branch analysis from position: 78
2 jumps found. (Code = 77) Position 1 = 81, Position 2 = 88
Branch analysis from position: 81
2 jumps found. (Code = 78) Position 1 = 82, Position 2 = 88
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 81
Branch analysis from position: 81
Branch analysis from position: 88
2 jumps found. (Code = 43) Position 1 = 92, Position 2 = 94
Branch analysis from position: 92
1 jumps found. (

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
265.95 ms | 969 KiB | 23 Q