3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @property string $pathSeparator * @property-read AddressableTree|null $rootNode */ class AddressableTree implements ArrayAccess, RecursiveIterator { /** * @var string */ private $pathSeparator; /** * @var AddressableTree */ private $rootNode; /** * @var array */ private $data = []; /** * @var self[] */ private $branches = []; /** * @param array $data * @param string $pathSeparator */ public function __construct(array $data = [], $pathSeparator = '/') { $this->setRootNode(null); $this->setPathSeparator($pathSeparator); foreach ($data as $key => $value) { if (is_array($value)) { $this->data[$key] = $this->createBranch($value); } else { $this->data[$key] = $value; } } } /** * @param string $name * @return mixed */ public function __get($name) { if (!in_array($name, ['pathSeparator', 'rootNode'])) { throw new \LogicException('Read of undefined property: ' . $name); } return $this->$name; } /** * @param string $name * @param mixed $value */ public function __set($name, $value) { if (!in_array($name, ['pathSeparator', 'rootNode'])) { throw new \LogicException('Write of undefined property: ' . $name); } call_user_func([$this, 'set' . $name], $value); } /** * @param string $value */ private function setPathSeparator($value) { $value = (string)$value; if ($this->rootNode && $value !== $this->rootNode->pathSeparator) { throw new \LogicException('Path separator can only be set on the root node'); } $this->pathSeparator = $value; foreach ($this->branches as $branch) { $branch->pathSeparator = $value; } } /** * @param AddressableTree|null $value */ private function setRootNode(AddressableTree $value = null) { $this->rootNode = $value; $branchRoot = $value ?: $this; foreach ($this->branches as $branch) { $branch->rootNode = $branchRoot; } } /** * @param array $value * @return AddressableTree */ private function createBranch(array $value) { $branch = new self($value, $this->pathSeparator); $branch->rootNode = $this->rootNode ?: $this; return $branch; } /** * @param $address * @return array|bool */ private function parseAddressParts($address) { if (false === $pos = strpos($address, $this->pathSeparator)) { return false; } else if (!$pos && !$pos = strpos($address, $this->pathSeparator, strlen($this->pathSeparator))) { return false; } return [substr($address, 0, $pos), substr($address, $pos + strlen($this->pathSeparator))]; } /** * @param string $key * @param mixed $value */ private function setElementAtKey($key, $value) { if ($value instanceof self) { if ($value->rootNode) { throw new \LogicException('Cannot add branch to tree: already attached to a tree'); } $value->rootNode = $this->rootNode; $value->pathSeparator = $this->pathSeparator; if (isset($this->data[$key])) { $this->removeElementAtKey($key); } $this->data[$key] = $value; $this->branches[$key] = $value; } else { $this->data[$key] = $value; } } /** * @param string $key */ private function removeElementAtKey($key) { if (!array_key_exists($key, $this->data)) { throw new \LogicException("Cannot remove element at '$key': does not exist"); } if ($this->data[$key] instanceof self) { $this->data[$key]->rootNode = null; unset($this->branches[$key]); } unset($this->data[$key]); } /** * @param string $address * @param mixed $value */ public function setElementAtAddress($address, $value) { if (!$parts = $this->parseAddressParts($address)) { $this->setElementAtKey($address, $value); return; } list($key, $subAddress) = $parts; if (!array_key_exists($key, $this->data)) { $this->data[$key] = $this->branches[$key] = new self([], $this->pathSeparator); $this->branches[$key]->rootNode = $this->rootNode; } else if (!($this->data[$key] instanceof self)) { throw new \InvalidArgumentException("Target element address invalid: treats leaf '{$key}' as a branch"); } $this->branches[$key]->setElementAtAddress($subAddress, $value); } /** * @param string $address * @return mixed */ public function getElementAtAddress($address) { if (!$parts = $this->parseAddressParts($address)) { if (!array_key_exists($address, $this->data)) { throw new \InvalidArgumentException("Target leaf address invalid: element '{$address}' does not exist"); } return $this->data[$address]; } list($key, $subAddress) = $parts; if (!array_key_exists($key, $this->data)) { throw new \InvalidArgumentException("Target element address invalid: branch '{$key}' does not exist"); } else if (!($this->data[$key] instanceof self)) { throw new \InvalidArgumentException("Target element address invalid: treats leaf '{$key}' as a branch"); } return $this->branches[$key]->getElementAtAddress($subAddress); } /** * @param string $address */ public function removeElementAtAddress($address) { if (!$parts = $this->parseAddressParts($address)) { $this->removeElementAtKey($address); return; } list($key, $subAddress) = $parts; if (!array_key_exists($key, $this->data)) { throw new \InvalidArgumentException("Target element address invalid: branch '{$key}' does not exist"); } else if (!($this->data[$key] instanceof self)) { throw new \InvalidArgumentException("Target element address invalid: treats leaf '{$key}' as a branch"); } $this->branches[$key]->removeElementAtAddress($subAddress); } /** * @param string $address * @return bool */ public function addressExists($address) { if (!$parts = $this->parseAddressParts($address)) { return array_key_exists($address, $this->data); } list($key, $subAddress) = $parts; if (!array_key_exists($key, $this->data) || !($this->data[$key] instanceof self)) { return false; } return $this->branches[$key]->addressExists($subAddress); } /** * @return mixed */ public function current() { return current($this->data); } public function next() { next($this->data); } /** * @return string */ public function key() { return key($this->data); } /** * @return bool */ public function valid() { return key($this->data) !== null; } public function rewind() { reset($this->data); } /** * @return bool */ public function hasChildren() { return current($this->data) instanceof self; } /** * @return RecursiveIterator|null */ public function getChildren() { return current($this->data) instanceof self ? current($this->data) : null; } /** * @param string $address * @return bool */ public function offsetExists($address) { return $this->addressExists($address); } /** * @param string $address * @return mixed */ public function offsetGet($address) { return $this->getElementAtAddress($address); } /** * @param string $address * @param mixed $value */ public function offsetSet($address, $value) { $this->setElementAtAddress($address, $value); } /** * @param string $key */ public function offsetUnset($key) { $this->removeElementAtAddress($key); } } $tree = new AddressableTree([ 'foo' => [ 'bar' => 1, 'baz' => 2, ], 'qux' => [ 'yo' => ['mama' => ['so' => 'fat']] ], ]); var_dump($tree['foo/bar'], $tree['/foo/bar'], $tree['foo']['bar']); $tree['/yo/mama/so'] = 'ugly'; var_dump($tree);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6CGnk
function name:  (null)
number of ops:  20
compiled vars:  !0 = $tree
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'addressabletree'
  345     1        NEW                                              $1      'AddressableTree'
  347     2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
  345     4        ASSIGN                                                   !0, $1
  355     5        INIT_FCALL                                               'var_dump'
          6        FETCH_DIM_R                                      ~4      !0, 'foo%2Fbar'
          7        SEND_VAL                                                 ~4
          8        FETCH_DIM_R                                      ~5      !0, '%2Ffoo%2Fbar'
          9        SEND_VAL                                                 ~5
         10        FETCH_DIM_R                                      ~6      !0, 'foo'
         11        FETCH_DIM_R                                      ~7      ~6, 'bar'
         12        SEND_VAL                                                 ~7
         13        DO_ICALL                                                 
  356    14        ASSIGN_DIM                                               !0, '%2Fyo%2Fmama%2Fso'
         15        OP_DATA                                                  'ugly'
  358    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Class AddressableTree:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/6CGnk
function name:  __construct
number of ops:  26
compiled vars:  !0 = $data, !1 = $pathSeparator, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV_INIT                                        !0      <array>
          1        RECV_INIT                                        !1      '%2F'
   35     2        INIT_METHOD_CALL                                         'setRootNode'
          3        SEND_VAL_EX                                              null
          4        DO_FCALL                                      0          
   36     5        INIT_METHOD_CALL                                         'setPathSeparator'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   38     8      > FE_RESET_R                                       $6      !0, ->24
          9    > > FE_FETCH_R                                       ~7      $6, !2, ->24
         10    >   ASSIGN                                                   !3, ~7
   39    11        TYPE_CHECK                                  128          !2
         12      > JMPZ                                                     ~9, ->20
   40    13    >   INIT_METHOD_CALL                                         'createBranch'
         14        SEND_VAR_EX                                              !2
         15        DO_FCALL                                      0  $12     
         16        FETCH_OBJ_W                                      $10     'data'
         17        ASSIGN_DIM                                               $10, !3
         18        OP_DATA                                                  $12
         19      > JMP                                                      ->23
   42    20    >   FETCH_OBJ_W                                      $13     'data'
         21        ASSIGN_DIM                                               $13, !3
         22        OP_DATA                                                  !2
   38    23    > > JMP                                                      ->9
         24    >   FE_FREE                                                  $6
   45    25      > RETURN                                                   null

End of function __construct

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6CGnk
function name:  __get
number of ops:  12
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
   53     1        IN_ARRAY                                         ~1      !0, <array>
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->9
   54     4    >   NEW                                              $3      'LogicException'
          5        CONCAT                                           ~4      'Read+of+undefined+property%3A+', !0
          6        SEND_VAL_EX                                              ~4
          7        DO_FCALL                                      0          
          8      > THROW                                         0          $3
   57     9    >   FETCH_OBJ_R                                      ~6      !0
         10      > RETURN                                                   ~6
   58    11*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6CGnk
function name:  __set
number of ops:  18
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   66     2        IN_ARRAY                                         ~2      !0, <array>
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->10
   67     5    >   NEW                                              $4      'LogicException'
          6        CONCAT                                           ~5      'Write+of+undefined+property%3A+', !0
          7        SEND_VAL_EX                                              ~5
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $4
   70    10    >   FETCH_THIS                                       ~7      
         11        INIT_ARRAY                                       ~8      ~7
         12        CONCAT                                           ~9      'set', !0
         13        ADD_ARRAY_ELEMENT                                ~8      ~9
         14        INIT_USER_CALL                                1          'call_user_func', ~8
         15        SEND_USER                                                !1
         16        DO_FCALL                                      0          
   71    17      > RETURN                                                   null

End of function __set

Function setpathseparator:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 14
Branch analysis from position: 10
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 9
filename:       /in/6CGnk
function name:  setPathSeparator
number of ops:  24
compiled vars:  !0 = $value, !1 = $branch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   RECV                                             !0      
   78     1        CAST                                          6  ~2      !0
          2        ASSIGN                                                   !0, ~2
   79     3        FETCH_OBJ_R                                      ~4      'rootNode'
          4      > JMPZ_EX                                          ~4      ~4, ->9
          5    >   FETCH_OBJ_R                                      ~5      'rootNode'
          6        FETCH_OBJ_R                                      ~6      ~5, 'pathSeparator'
          7        IS_NOT_IDENTICAL                                 ~7      !0, ~6
          8        BOOL                                             ~4      ~7
          9    > > JMPZ                                                     ~4, ->14
   80    10    >   NEW                                              $8      'LogicException'
         11        SEND_VAL_EX                                              'Path+separator+can+only+be+set+on+the+root+node'
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $8
   83    14    >   ASSIGN_OBJ                                               'pathSeparator'
         15        OP_DATA                                                  !0
   84    16        FETCH_OBJ_R                                      ~11     'branches'
         17      > FE_RESET_R                                       $12     ~11, ->22
         18    > > FE_FETCH_R                                               $12, !1, ->22
   85    19    >   ASSIGN_OBJ                                               !1, 'pathSeparator'
         20        OP_DATA                                                  !0
   84    21      > JMP                                                      ->18
         22    >   FE_FREE                                                  $12
   87    23      > RETURN                                                   null

End of function setpathseparator

Function setrootnode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 13
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/6CGnk
function name:  setRootNode
number of ops:  15
compiled vars:  !0 = $value, !1 = $branchRoot, !2 = $branch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   92     0  E >   RECV_INIT                                        !0      null
   94     1        ASSIGN_OBJ                                               'rootNode'
          2        OP_DATA                                                  !0
   96     3        JMP_SET                                          ~4      !0, ->6
          4        FETCH_THIS                                       ~5      
          5        QM_ASSIGN                                        ~4      ~5
          6        ASSIGN                                                   !1, ~4
   97     7        FETCH_OBJ_R                                      ~7      'branches'
          8      > FE_RESET_R                                       $8      ~7, ->13
          9    > > FE_FETCH_R                                               $8, !2, ->13
   98    10    >   ASSIGN_OBJ                                               !2, 'rootNode'
         11        OP_DATA                                                  !1
   97    12      > JMP                                                      ->9
         13    >   FE_FREE                                                  $8
  100    14      > RETURN                                                   null

End of function setrootnode

Function createbranch:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6CGnk
function name:  createBranch
number of ops:  16
compiled vars:  !0 = $value, !1 = $branch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  106     0  E >   RECV                                             !0      
  108     1        NEW                          self                $2      
          2        SEND_VAR_EX                                              !0
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $3      'pathSeparator'
          5        SEND_FUNC_ARG                                            $3
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $2
  109     8        FETCH_OBJ_R                                      ~7      'rootNode'
          9        JMP_SET                                          ~8      ~7, ->12
         10        FETCH_THIS                                       ~9      
         11        QM_ASSIGN                                        ~8      ~9
         12        ASSIGN_OBJ                                               !1, 'rootNode'
         13        OP_DATA                                                  ~8
  111    14      > RETURN                                                   !1
  112    15*     > RETURN                                                   null

End of function createbranch

Function parseaddressparts:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 46) Position 1 = 13, Position 2 = 24
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/6CGnk
function name:  parseAddressParts
number of ops:  42
compiled vars:  !0 = $address, !1 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  118     0  E >   RECV                                             !0      
  120     1        INIT_FCALL                                               'strpos'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~2      'pathSeparator'
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6        ASSIGN                                           ~4      !1, $3
          7        TYPE_CHECK                                    4          ~4
          8      > JMPZ                                                     ~5, ->11
  121     9    > > RETURN                                                   <false>
         10*       JMP                                                      ->26
  122    11    >   BOOL_NOT                                         ~6      !1
         12      > JMPZ_EX                                          ~6      ~6, ->24
         13    >   INIT_FCALL                                               'strpos'
         14        SEND_VAR                                                 !0
         15        FETCH_OBJ_R                                      ~7      'pathSeparator'
         16        SEND_VAL                                                 ~7
         17        FETCH_OBJ_R                                      ~8      'pathSeparator'
         18        STRLEN                                           ~9      ~8
         19        SEND_VAL                                                 ~9
         20        DO_ICALL                                         $10     
         21        ASSIGN                                           ~11     !1, $10
         22        BOOL_NOT                                         ~12     ~11
         23        BOOL                                             ~6      ~12
         24    > > JMPZ                                                     ~6, ->26
  123    25    > > RETURN                                                   <false>
  126    26    >   INIT_FCALL                                               'substr'
         27        SEND_VAR                                                 !0
         28        SEND_VAL                                                 0
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                         $13     
         31        INIT_ARRAY                                       ~14     $13
         32        INIT_FCALL                                               'substr'
         33        SEND_VAR                                                 !0
         34        FETCH_OBJ_R                                      ~15     'pathSeparator'
         35        STRLEN                                           ~16     ~15
         36        ADD                                              ~17     !1, ~16
         37        SEND_VAL                                                 ~17
         38        DO_ICALL                                         $18     
         39        ADD_ARRAY_ELEMENT                                ~14     $18
         40      > RETURN                                                   ~14
  127    41*     > RETURN                                                   null

End of function parseaddressparts

Function setelementatkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6CGnk
function name:  setElementAtKey
number of ops:  33
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  133     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  135     2        INSTANCEOF                                               !1
          3      > JMPZ                                                     ~2, ->29
  136     4    >   FETCH_OBJ_R                                      ~3      !1, 'rootNode'
          5      > JMPZ                                                     ~3, ->10
  137     6    >   NEW                                              $4      'LogicException'
          7        SEND_VAL_EX                                              'Cannot+add+branch+to+tree%3A+already+attached+to+a+tree'
          8        DO_FCALL                                      0          
          9      > THROW                                         0          $4
  140    10    >   FETCH_OBJ_R                                      ~7      'rootNode'
         11        ASSIGN_OBJ                                               !1, 'rootNode'
         12        OP_DATA                                                  ~7
  141    13        FETCH_OBJ_R                                      ~9      'pathSeparator'
         14        ASSIGN_OBJ                                               !1, 'pathSeparator'
         15        OP_DATA                                                  ~9
  143    16        FETCH_OBJ_IS                                     ~10     'data'
         17        ISSET_ISEMPTY_DIM_OBJ                         0          ~10, !0
         18      > JMPZ                                                     ~11, ->22
  144    19    >   INIT_METHOD_CALL                                         'removeElementAtKey'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0          
  147    22    >   FETCH_OBJ_W                                      $13     'data'
         23        ASSIGN_DIM                                               $13, !0
         24        OP_DATA                                                  !1
  148    25        FETCH_OBJ_W                                      $15     'branches'
         26        ASSIGN_DIM                                               $15, !0
         27        OP_DATA                                                  !1
         28      > JMP                                                      ->32
  150    29    >   FETCH_OBJ_W                                      $17     'data'
         30        ASSIGN_DIM                                               $17, !0
         31        OP_DATA                                                  !1
  152    32    > > RETURN                                                   null

End of function setelementatkey

Function removeelementatkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 12
Branch analysis from position: 5
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/6CGnk
function name:  removeElementAtKey
number of ops:  25
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  157     0  E >   RECV                                             !0      
  159     1        FETCH_OBJ_R                                      ~1      'data'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->12
  160     5    >   NEW                                              $4      'LogicException'
          6        ROPE_INIT                                     3  ~6      'Cannot+remove+element+at+%27'
          7        ROPE_ADD                                      1  ~6      ~6, !0
          8        ROPE_END                                      2  ~5      ~6, '%27%3A+does+not+exist'
          9        SEND_VAL_EX                                              ~5
         10        DO_FCALL                                      0          
         11      > THROW                                         0          $4
  163    12    >   FETCH_OBJ_R                                      ~9      'data'
         13        FETCH_DIM_R                                      ~10     ~9, !0
         14        INSTANCEOF                                               ~10
         15      > JMPZ                                                     ~11, ->22
  164    16    >   FETCH_OBJ_W                                      $12     'data'
         17        FETCH_DIM_W                                      $13     $12, !0
         18        ASSIGN_OBJ                                               $13, 'rootNode'
         19        OP_DATA                                                  null
  165    20        FETCH_OBJ_UNSET                                  $15     'branches'
         21        UNSET_DIM                                                $15, !0
  168    22    >   FETCH_OBJ_UNSET                                  $16     'data'
         23        UNSET_DIM                                                $16, !0
  169    24      > RETURN                                                   null

End of function removeelementatkey

Function setelementataddress:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 41
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 46, Position 2 = 53
Branch analysis from position: 46
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 53
filename:       /in/6CGnk
function name:  setElementAtAddress
number of ops:  60
compiled vars:  !0 = $address, !1 = $value, !2 = $parts, !3 = $key, !4 = $subAddress
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  175     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  177     2        INIT_METHOD_CALL                                         'parseAddressParts'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                           ~6      !2, $5
          6        BOOL_NOT                                         ~7      ~6
          7      > JMPZ                                                     ~7, ->13
  178     8    >   INIT_METHOD_CALL                                         'setElementAtKey'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0          
  179    12      > RETURN                                                   null
  182    13    >   QM_ASSIGN                                        ~9      !2
         14        FETCH_LIST_R                                     $10     ~9, 0
         15        ASSIGN                                                   !3, $10
         16        FETCH_LIST_R                                     $12     ~9, 1
         17        ASSIGN                                                   !4, $12
         18        FREE                                                     ~9
  184    19        FETCH_OBJ_R                                      ~14     'data'
         20        ARRAY_KEY_EXISTS                                 ~15     !3, ~14
         21        BOOL_NOT                                         ~16     ~15
         22      > JMPZ                                                     ~16, ->41
  185    23    >   NEW                          self                $21     
         24        SEND_VAL_EX                                              <array>
         25        CHECK_FUNC_ARG                                           
         26        FETCH_OBJ_FUNC_ARG                               $22     'pathSeparator'
         27        SEND_FUNC_ARG                                            $22
         28        DO_FCALL                                      0          
         29        FETCH_OBJ_W                                      $19     'branches'
         30        ASSIGN_DIM                                       ~20     $19, !3
         31        OP_DATA                                                  $21
         32        FETCH_OBJ_W                                      $17     'data'
         33        ASSIGN_DIM                                               $17, !3
         34        OP_DATA                                                  ~20
  186    35        FETCH_OBJ_R                                      ~27     'rootNode'
         36        FETCH_OBJ_W                                      $24     'branches'
         37        FETCH_DIM_W                                      $25     $24, !3
         38        ASSIGN_OBJ                                               $25, 'rootNode'
         39        OP_DATA                                                  ~27
         40      > JMP                                                      ->53
  187    41    >   FETCH_OBJ_R                                      ~28     'data'
         42        FETCH_DIM_R                                      ~29     ~28, !3
         43        INSTANCEOF                                       ~30     ~29
         44        BOOL_NOT                                         ~31     ~30
         45      > JMPZ                                                     ~31, ->53
  188    46    >   NEW                                              $32     'InvalidArgumentException'
         47        ROPE_INIT                                     3  ~34     'Target+element+address+invalid%3A+treats+leaf+%27'
         48        ROPE_ADD                                      1  ~34     ~34, !3
         49        ROPE_END                                      2  ~33     ~34, '%27+as+a+branch'
         50        SEND_VAL_EX                                              ~33
         51        DO_FCALL                                      0          
         52      > THROW                                         0          $32
  191    53    >   FETCH_OBJ_R                                      ~37     'branches'
         54        FETCH_DIM_R                                      ~38     ~37, !3
         55        INIT_METHOD_CALL                                         ~38, 'setElementAtAddress'
         56        SEND_VAR_EX                                              !4
         57        SEND_VAR_EX                                              !1
         58        DO_FCALL         

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.63 ms | 1428 KiB | 19 Q