3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyXML extends SimpleXMLElement { public function firstChild() { $children = $this->children(); foreach ($children as $child) break; return $child; } public function keyHasTwins($key) { if (isset($this->$key)) return (count($this->$key)>1); else return false; } public function hasChildren() { return (bool)count($this->children()); } public function nodeIsCollection() { var_dump(count($this));exit; return (count); } public function getChildrenKeys() { $all = []; $children = $this->children(); foreach ($children as $key => $child) { $all[] = $key; } return $all; } } $s = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>'. '<request>'. ' <body>'. ' <rows>'. ' <row id="1"/>'. ' <row id="2"/>'. ' <row id="3"/>'. ' <row2 ver="2.0">test data</row2>'. ' <row2 ver="2.1">test data 2</row2>'. ' <row3 ver="3.0">'. ' <test inherit="yes">data</test>'. ' </row3>'. ' </rows>'. ' </body>'. '</request>'; $obj = new MyXML($s); $row = $obj->firstChild()->firstChild(); var_dump($row->getChildrenKeys());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PAWlv
function name:  (null)
number of ops:  16
compiled vars:  !0 = $s, !1 = $obj, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   ASSIGN                                                   !0, '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22utf-8%22+standalone%3D%22yes%22+%3F%3E%3Crequest%3E++%3Cbody%3E++++++%3Crows%3E++++++++++%3Crow+id%3D%221%22%2F%3E++++++++++%3Crow+id%3D%222%22%2F%3E++++++++++%3Crow+id%3D%223%22%2F%3E++++++++++%3Crow2+ver%3D%222.0%22%3Etest+data%3C%2Frow2%3E%09%09%09%3Crow2+ver%3D%222.1%22%3Etest+data+2%3C%2Frow2%3E%09%09%09%3Crow3+ver%3D%223.0%22%3E%09%09%09%09%3Ctest+inherit%3D%22yes%22%3Edata%3C%2Ftest%3E%09%09%09%3C%2Frow3%3E++++++%3C%2Frows%3E++%3C%2Fbody%3E%3C%2Frequest%3E'
   61     1        NEW                                              $4      'MyXML'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $4
   63     5        INIT_METHOD_CALL                                         !1, 'firstChild'
          6        DO_FCALL                                      0  $7      
          7        INIT_METHOD_CALL                                         $7, 'firstChild'
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !2, $8
   65    10        INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !2, 'getChildrenKeys'
         12        DO_FCALL                                      0  $10     
         13        SEND_VAR                                                 $10
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Class MyXML:
Function firstchild:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
Branch analysis from position: 7
filename:       /in/PAWlv
function name:  firstChild
number of ops:  10
compiled vars:  !0 = $children, !1 = $child
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_METHOD_CALL                                         'children'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
    7     3      > FE_RESET_R                                       $4      !0, ->7
          4    > > FE_FETCH_R                                               $4, !1, ->7
    8     5    > > JMP                                                      ->7
    7     6*       JMP                                                      ->4
          7    >   FE_FREE                                                  $4
    9     8      > RETURN                                                   !1
   10     9*     > RETURN                                                   null

End of function firstchild

Function keyhastwins:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 8
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PAWlv
function name:  keyHasTwins
number of ops:  10
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        ISSET_ISEMPTY_PROP_OBJ                                   !0
          2      > JMPZ                                                     ~1, ->8
   15     3    >   FETCH_OBJ_R                                      ~2      !0
          4        COUNT                                            ~3      ~2
          5        IS_SMALLER                                       ~4      1, ~3
          6      > RETURN                                                   ~4
          7*       JMP                                                      ->9
   17     8    > > RETURN                                                   <false>
   18     9*     > RETURN                                                   null

End of function keyhastwins

Function haschildren:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PAWlv
function name:  hasChildren
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_METHOD_CALL                                         'children'
          1        DO_FCALL                                      0  $0      
          2        COUNT                                            ~1      $0
          3        BOOL                                             ~2      ~1
          4      > RETURN                                                   ~2
   23     5*     > RETURN                                                   null

End of function haschildren

Function nodeiscollection:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/PAWlv
function name:  nodeIsCollection
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_THIS                                       ~0      
          2        COUNT                                            ~1      ~0
          3        SEND_VAL                                                 ~1
          4        DO_ICALL                                                 
          5      > EXIT                                                     
   28     6*       FETCH_CONSTANT                                   ~3      'count'
          7*       RETURN                                                   ~3
   29     8*     > RETURN                                                   null

End of function nodeiscollection

Function getchildrenkeys:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/PAWlv
function name:  getChildrenKeys
number of ops:  13
compiled vars:  !0 = $all, !1 = $children, !2 = $child, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ASSIGN                                                   !0, <array>
   34     1        INIT_METHOD_CALL                                         'children'
          2        DO_FCALL                                      0  $5      
          3        ASSIGN                                                   !1, $5
   36     4      > FE_RESET_R                                       $7      !1, ->10
          5    > > FE_FETCH_R                                       ~8      $7, !2, ->10
          6    >   ASSIGN                                                   !3, ~8
   37     7        ASSIGN_DIM                                               !0
          8        OP_DATA                                                  !3
   36     9      > JMP                                                      ->5
         10    >   FE_FREE                                                  $7
   40    11      > RETURN                                                   !0
   41    12*     > RETURN                                                   null

End of function getchildrenkeys

End of class MyXML.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.81 ms | 1396 KiB | 15 Q