3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Capstone\Container; class Registry { protected $map; /** * @param \arrayAccess|array|null $map */ function __construct( &$map = null ) { if( $map === null ) { $map = array(); } $this->map =& $map; } function set($key, $value){ $this->map[$key] = $value; } function setMany(array $map){ foreach($map as $key => $value){ $this->set($key, $value); } } function get($key){ if(array_key_exists($key, $this->map)){ return $this->map[$key]; } return null; } function has($key){ return array_key_exists($key, $this->map); } function length(){ return count($this->map); } function getIterator(){ return new \ArrayIterator($this->map); } } $bob = array('x' => 'y'); $bob_reg = new Registry(); $bob_reg->set('ted', 'bob'); print_r($bob); echo $bob_reg->get('ted');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DZOB0
function name:  (null)
number of ops:  16
compiled vars:  !0 = $bob, !1 = $bob_reg
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   ASSIGN                                                   !0, <array>
   53     1        NEW                                              $3      'Capstone%5CContainer%5CRegistry'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $3
   55     4        INIT_METHOD_CALL                                         !1, 'set'
          5        SEND_VAL_EX                                              'ted'
          6        SEND_VAL_EX                                              'bob'
          7        DO_FCALL                                      0          
   57     8        INIT_NS_FCALL_BY_NAME                                    'Capstone%5CContainer%5Cprint_r'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0          
   58    11        INIT_METHOD_CALL                                         !1, 'get'
         12        SEND_VAL_EX                                              'ted'
         13        DO_FCALL                                      0  $8      
         14        ECHO                                                     $8
         15      > RETURN                                                   1

Class Capstone\Container\Registry:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
filename:       /in/DZOB0
function name:  __construct
number of ops:  7
compiled vars:  !0 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV_INIT                                        !0      null
   13     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~1, ->4
   14     3    >   ASSIGN                                                   !0, <array>
   17     4    >   ASSIGN_OBJ_REF                                           'map'
          5        OP_DATA                                                  !0
   18     6      > RETURN                                                   null

End of function __construct

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DZOB0
function name:  set
number of ops:  6
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        FETCH_OBJ_W                                      $2      'map'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   22     5      > RETURN                                                   null

End of function set

Function setmany:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 9
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/DZOB0
function name:  setMany
number of ops:  11
compiled vars:  !0 = $map, !1 = $value, !2 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1      > FE_RESET_R                                       $3      !0, ->9
          2    > > FE_FETCH_R                                       ~4      $3, !1, ->9
          3    >   ASSIGN                                                   !2, ~4
   26     4        INIT_METHOD_CALL                                         'set'
          5        SEND_VAR_EX                                              !2
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   25     8      > JMP                                                      ->2
          9    >   FE_FREE                                                  $3
   28    10      > RETURN                                                   null

End of function setmany

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DZOB0
function name:  get
number of ops:  13
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        INIT_NS_FCALL_BY_NAME                                    'Capstone%5CContainer%5Carray_key_exists'
          2        SEND_VAR_EX                                              !0
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $1      'map'
          5        SEND_FUNC_ARG                                            $1
          6        DO_FCALL                                      0  $2      
          7      > JMPZ                                                     $2, ->11
   32     8    >   FETCH_OBJ_R                                      ~3      'map'
          9        FETCH_DIM_R                                      ~4      ~3, !0
         10      > RETURN                                                   ~4
   34    11    > > RETURN                                                   null
   35    12*     > RETURN                                                   null

End of function get

Function has:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DZOB0
function name:  has
number of ops:  9
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
   38     1        INIT_NS_FCALL_BY_NAME                                    'Capstone%5CContainer%5Carray_key_exists'
          2        SEND_VAR_EX                                              !0
          3        CHECK_FUNC_ARG                                           
          4        FETCH_OBJ_FUNC_ARG                               $1      'map'
          5        SEND_FUNC_ARG                                            $1
          6        DO_FCALL                                      0  $2      
          7      > RETURN                                                   $2
   39     8*     > RETURN                                                   null

End of function has

Function length:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DZOB0
function name:  length
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E >   INIT_NS_FCALL_BY_NAME                                    'Capstone%5CContainer%5Ccount'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $0      'map'
          3        SEND_FUNC_ARG                                            $0
          4        DO_FCALL                                      0  $1      
          5      > RETURN                                                   $1
   43     6*     > RETURN                                                   null

End of function length

Function getiterator:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DZOB0
function name:  getIterator
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   NEW                                              $0      'ArrayIterator'
          1        CHECK_FUNC_ARG                                           
          2        FETCH_OBJ_FUNC_ARG                               $1      'map'
          3        SEND_FUNC_ARG                                            $1
          4        DO_FCALL                                      0          
          5      > RETURN                                                   $0
   47     6*     > RETURN                                                   null

End of function getiterator

End of class Capstone\Container\Registry.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.2 ms | 1404 KiB | 19 Q