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) { $this->setElementAtKey($key, is_array($value) ? $this->createBranch($value) : $value, true); } } /** * @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) { $pos = strpos($address, $this->pathSeparator); if ($pos === 0) { $address = substr($address, strlen($this->pathSeparator)); $pos = strpos($address, $this->pathSeparator); } if ($pos === false) { return false; } return [substr($address, 0, $pos), substr($address, $pos + strlen($this->pathSeparator))]; } /** * @param string $key * @param mixed $value * @param bool $forceBranch */ private function setElementAtKey($key, $value, $forceBranch = false) { if ($value instanceof self) { if ($value->rootNode && !$forceBranch) { throw new \LogicException('Cannot add branch to tree: already attached to a tree'); } $value->rootNode = $this->rootNode ?: $this; $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] = $this->createBranch(); } 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, ], 'yo' => ['mama' => ['so' => 'fat']], 'stuff' => 'ting', ]); 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/pb6ZQ
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'
  346     1        NEW                                              $1      'AddressableTree'
  348     2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
  346     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 = 25
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 20
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
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: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/pb6ZQ
function name:  __construct
number of ops:  27
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, ->25
          9    > > FE_FETCH_R                                       ~7      $6, !2, ->25
         10    >   ASSIGN                                                   !3, ~7
   39    11        INIT_METHOD_CALL                                         'setElementAtKey'
         12        SEND_VAR_EX                                              !3
         13        TYPE_CHECK                                  128          !2
         14      > JMPZ                                                     ~9, ->20
         15    >   INIT_METHOD_CALL                                         'createBranch'
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0  $10     
         18        QM_ASSIGN                                        ~11     $10
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~11     !2
         21    >   SEND_VAL_EX                                              ~11
         22        SEND_VAL_EX                                              <true>
         23        DO_FCALL                                      0          
   38    24      > JMP                                                      ->9
         25    >   FE_FREE                                                  $6
   41    26      > 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/pb6ZQ
function name:  __get
number of ops:  12
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
   49     1        IN_ARRAY                                         ~1      !0, <array>
          2        BOOL_NOT                                         ~2      ~1
          3      > JMPZ                                                     ~2, ->9
   50     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
   53     9    >   FETCH_OBJ_R                                      ~6      !0
         10      > RETURN                                                   ~6
   54    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/pb6ZQ
function name:  __set
number of ops:  18
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   62     2        IN_ARRAY                                         ~2      !0, <array>
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->10
   63     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
   66    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          
   67    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/pb6ZQ
function name:  setPathSeparator
number of ops:  24
compiled vars:  !0 = $value, !1 = $branch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   72     0  E >   RECV                                             !0      
   74     1        CAST                                          6  ~2      !0
          2        ASSIGN                                                   !0, ~2
   75     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
   76    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
   79    14    >   ASSIGN_OBJ                                               'pathSeparator'
         15        OP_DATA                                                  !0
   80    16        FETCH_OBJ_R                                      ~11     'branches'
         17      > FE_RESET_R                                       $12     ~11, ->22
         18    > > FE_FETCH_R                                               $12, !1, ->22
   81    19    >   ASSIGN_OBJ                                               !1, 'pathSeparator'
         20        OP_DATA                                                  !0
   80    21      > JMP                                                      ->18
         22    >   FE_FREE                                                  $12
   83    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/pb6ZQ
function name:  setRootNode
number of ops:  15
compiled vars:  !0 = $value, !1 = $branchRoot, !2 = $branch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   88     0  E >   RECV_INIT                                        !0      null
   90     1        ASSIGN_OBJ                                               'rootNode'
          2        OP_DATA                                                  !0
   92     3        JMP_SET                                          ~4      !0, ->6
          4        FETCH_THIS                                       ~5      
          5        QM_ASSIGN                                        ~4      ~5
          6        ASSIGN                                                   !1, ~4
   93     7        FETCH_OBJ_R                                      ~7      'branches'
          8      > FE_RESET_R                                       $8      ~7, ->13
          9    > > FE_FETCH_R                                               $8, !2, ->13
   94    10    >   ASSIGN_OBJ                                               !2, 'rootNode'
         11        OP_DATA                                                  !1
   93    12      > JMP                                                      ->9
         13    >   FE_FREE                                                  $8
   96    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/pb6ZQ
function name:  createBranch
number of ops:  16
compiled vars:  !0 = $value, !1 = $branch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  102     0  E >   RECV_INIT                                        !0      <array>
  104     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
  105     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
  107    14      > RETURN                                                   !1
  108    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 = 22
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/pb6ZQ
function name:  parseAddressParts
number of ops:  41
compiled vars:  !0 = $address, !1 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  114     0  E >   RECV                                             !0      
  116     1        INIT_FCALL                                               'strpos'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~2      'pathSeparator'
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !1, $3
  118     7        IS_IDENTICAL                                             !1, 0
          8      > JMPZ                                                     ~5, ->22
  119     9    >   INIT_FCALL                                               'substr'
         10        SEND_VAR                                                 !0
         11        FETCH_OBJ_R                                      ~6      'pathSeparator'
         12        STRLEN                                           ~7      ~6
         13        SEND_VAL                                                 ~7
         14        DO_ICALL                                         $8      
         15        ASSIGN                                                   !0, $8
  120    16        INIT_FCALL                                               'strpos'
         17        SEND_VAR                                                 !0
         18        FETCH_OBJ_R                                      ~10     'pathSeparator'
         19        SEND_VAL                                                 ~10
         20        DO_ICALL                                         $11     
         21        ASSIGN                                                   !1, $11
  123    22    >   TYPE_CHECK                                    4          !1
         23      > JMPZ                                                     ~13, ->25
  124    24    > > RETURN                                                   <false>
  127    25    >   INIT_FCALL                                               'substr'
         26        SEND_VAR                                                 !0
         27        SEND_VAL                                                 0
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $14     
         30        INIT_ARRAY                                       ~15     $14
         31        INIT_FCALL                                               'substr'
         32        SEND_VAR                                                 !0
         33        FETCH_OBJ_R                                      ~16     'pathSeparator'
         34        STRLEN                                           ~17     ~16
         35        ADD                                              ~18     !1, ~17
         36        SEND_VAL                                                 ~18
         37        DO_ICALL                                         $19     
         38        ADD_ARRAY_ELEMENT                                ~15     $19
         39      > RETURN                                                   ~15
  128    40*     > RETURN                                                   null

End of function parseaddressparts

Function setelementatkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 36
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
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 = 43) Position 1 = 26, Position 2 = 29
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
Branch analysis from position: 9
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pb6ZQ
function name:  setElementAtKey
number of ops:  40
compiled vars:  !0 = $key, !1 = $value, !2 = $forceBranch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  135     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <false>
  137     3        INSTANCEOF                                               !1
          4      > JMPZ                                                     ~3, ->36
  138     5    >   FETCH_OBJ_R                                      ~4      !1, 'rootNode'
          6      > JMPZ_EX                                          ~4      ~4, ->9
          7    >   BOOL_NOT                                         ~5      !2
          8        BOOL                                             ~4      ~5
          9    > > JMPZ                                                     ~4, ->14
  139    10    >   NEW                                              $6      'LogicException'
         11        SEND_VAL_EX                                              'Cannot+add+branch+to+tree%3A+already+attached+to+a+tree'
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $6
  142    14    >   FETCH_OBJ_R                                      ~9      'rootNode'
         15        JMP_SET                                          ~10     ~9, ->18
         16        FETCH_THIS                                       ~11     
         17        QM_ASSIGN                                        ~10     ~11
         18        ASSIGN_OBJ                                               !1, 'rootNode'
         19        OP_DATA                                                  ~10
  143    20        FETCH_OBJ_R                                      ~13     'pathSeparator'
         21        ASSIGN_OBJ                                               !1, 'pathSeparator'
         22        OP_DATA                                                  ~13
  145    23        FETCH_OBJ_IS                                     ~14     'data'
         24        ISSET_ISEMPTY_DIM_OBJ                         0          ~14, !0
         25      > JMPZ                                                     ~15, ->29
  146    26    >   INIT_METHOD_CALL                                         'removeElementAtKey'
         27        SEND_VAR_EX                                              !0
         28        DO_FCALL                                      0          
  149    29    >   FETCH_OBJ_W                                      $17     'data'
         30        ASSIGN_DIM                                               $17, !0
         31        OP_DATA                                                  !1
  150    32        FETCH_OBJ_W                                      $19     'branches'
         33        ASSIGN_DIM                                               $19, !0
         34        OP_DATA                                                  !1
         35      > JMP                                                      ->39
  152    36    >   FETCH_OBJ_W                                      $21     'data'
         37        ASSIGN_DIM                                               $21, !0
         38        OP_DATA                                                  !1
  154    39    > > 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/pb6ZQ
function name:  removeElementAtKey
number of ops:  25
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  159     0  E >   RECV                                             !0      
  161     1        FETCH_OBJ_R                                      ~1      'data'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->12
  162     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
  165    12    >   FETCH_OBJ_R                                      ~9      'data'
         13        FETCH_DIM_R                                      ~10     ~9, !0
         14        INSTANCEOF                                               ~10
         15      > JMPZ                                                     ~11, ->22
  166    16    >   FETCH_OBJ_W                                      $12     'data'
         17        FETCH_DIM_W                                      $13     $12, !0
         18        ASSIGN_OBJ                                               $13, 'rootNode'
         19        OP_DATA                                                  null
  167    20        FETCH_OBJ_UNSET                                  $15     'branches'
         21        UNSET_DIM                                                $15, !0
  170    22    >   FETCH_OBJ_UNSET                                  $16     'data'
         23        UNSET_DIM                                                $16, !0
  171    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 = 32
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 44
Branch analysis from position: 37
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 44
filename:       /in/pb6ZQ
function name:  setElementAtAddress
number of ops:  51
compiled vars:  !0 = $address, !1 = $value, !2 = $parts, !3 = $key, !4 = $subAddress
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  177     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  179     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
  180     8    >   INIT_METHOD_CALL                                         'setElementAtKey'
          9        SEND_VAR                                                 !0
         10        SEND_VAR                                                 !1
         11        DO_FCALL                                      0          
  181    12      > RETURN                                                   null
  184    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
  186    19        FETCH_OBJ_R                                      ~14     'data'
         20        ARRAY_KEY_EXISTS                                 ~15     !3, ~14
         21        BOOL_NOT                                         ~16     ~15
         22      > JMPZ                                                     ~16, ->32
  187    23    >   INIT_METHOD_CALL                                         'createBranch'
         24        DO_FCALL                                      0  $21     
         25        FETCH_OBJ_W                                      $19     'branches'
         26        ASSIGN_DIM                                       ~20     $19, !3
         27        OP_DATA                                                  $21
         28        FETCH_OBJ_W                                      $17     'data'
         29        ASSIGN_DIM                                               $17, !3
         30        OP_DATA                                                  ~20
         31      > JMP                                                      ->44
  188    32    >   FETCH_OBJ_R                                      ~22     'data'
         33        FETCH_DIM_R                                      ~23     ~22, !3
         34        INSTANCEOF                                       ~24     ~23
         35        BOOL_NOT                                         ~25     ~24
         36      > JMPZ                                                     ~25, ->44
  189    37    >   NEW                                              $26     'InvalidArgumentException'
         38        ROPE_INIT                                     3  ~28     'Target+element+address+invalid%3A+treats+leaf+%27'
         39        ROPE_ADD                                      1  ~28     ~28, !3
         40        ROPE_END                                      2  ~27     ~28, '%27+as+a+branch'
         41        SEND_VAL_EX                                              ~27
         42        DO_FCALL                                      0          
         43      > THROW                                         0          $26
  192    44    >   FETCH_OBJ_R                                      ~31     'branches'
         45        FETCH_DIM_R                                      ~32     ~31, !3
         46        INIT_METHOD_CALL                                         ~32, 'setElementAtAddress'
         47        SEND_VAR_EX                                              !4
         48        SEND_VAR_EX                                              !1
         49        DO_FCALL                                      0          
  193    50      > RETURN                                                   null

End of function setelementataddress

Function getelementataddress:
Finding en

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.41 ms | 1420 KiB | 19 Q