3v4l.org

run code in 300+ PHP versions simultaneously
<?php use ArrayObject as PhpArrayObject; class Parameters extends PhpArrayObject { /** * Constructor * * Enforces that we have an array, and enforces parameter access to array * elements. * * @param array $values */ public function __construct(array $values = null) { if (null === $values) { $values = []; } parent::__construct($values, ArrayObject::ARRAY_AS_PROPS); } /** * Populate from native PHP array * * @param array $values * @return void */ public function fromArray(array $values) { $this->exchangeArray($values); } /** * Populate from query string * * @param string $string * @return void */ public function fromString($string) { $array = []; parse_str($string, $array); $this->fromArray($array); } /** * Serialize to native PHP array * * @return array */ public function toArray() { return $this->getArrayCopy(); } /** * Serialize to query string * * @return string */ public function toString() { return http_build_query($this->toArray()); } /** * Retrieve by key * * Returns null if the key does not exist. * * @param string $name * @return mixed */ public function offsetGet($name) { if ($this->offsetExists($name)) { return parent::offsetGet($name); } return; } /** * @param string $name * @param mixed $default optional default value * @return mixed */ public function get($name, $default = null) { if ($this->offsetExists($name)) { return parent::offsetGet($name); } return $default; } /** * @param string $name * @param mixed $value * @return Parameters */ public function set($name, $value) { $this[$name] = $value; return $this; } } $data = new Parameters(); $data->param['toto'] = 'tutu'; $data->param['type'] = 1; var_dump($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l56rd
function name:  (null)
number of ops:  13
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   99     0  E >   NEW                                              $1      'Parameters'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
  101     3        FETCH_OBJ_W                                      $4      !0, 'param'
          4        ASSIGN_DIM                                               $4, 'toto'
          5        OP_DATA                                                  'tutu'
  102     6        FETCH_OBJ_W                                      $6      !0, 'param'
          7        ASSIGN_DIM                                               $6, 'type'
          8        OP_DATA                                                  1
  104     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Class Parameters:
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/l56rd
function name:  __construct
number of ops:  9
compiled vars:  !0 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV_INIT                                        !0      null
   15     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~1, ->4
   16     3    >   ASSIGN                                                   !0, <array>
   18     4    >   INIT_STATIC_METHOD_CALL                                  
          5        SEND_VAR_EX                                              !0
          6        SEND_VAL_EX                                              2
          7        DO_FCALL                                      0          
   19     8      > RETURN                                                   null

End of function __construct

Function fromarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l56rd
function name:  fromArray
number of ops:  5
compiled vars:  !0 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   RECV                                             !0      
   28     1        INIT_METHOD_CALL                                         'exchangeArray'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   29     4      > RETURN                                                   null

End of function fromarray

Function fromstring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l56rd
function name:  fromString
number of ops:  10
compiled vars:  !0 = $string, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
   38     1        ASSIGN                                                   !1, <array>
   39     2        INIT_FCALL                                               'parse_str'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
   40     6        INIT_METHOD_CALL                                         'fromArray'
          7        SEND_VAR_EX                                              !1
          8        DO_FCALL                                      0          
   41     9      > RETURN                                                   null

End of function fromstring

Function toarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l56rd
function name:  toArray
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   INIT_METHOD_CALL                                         'getArrayCopy'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   50     3*     > RETURN                                                   null

End of function toarray

Function tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l56rd
function name:  toString
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   58     0  E >   INIT_FCALL                                               'http_build_query'
          1        INIT_METHOD_CALL                                         'toArray'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
   59     6*     > RETURN                                                   null

End of function tostring

Function offsetget:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 9
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l56rd
function name:  offsetGet
number of ops:  11
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   RECV                                             !0      
   70     1        INIT_METHOD_CALL                                         'offsetExists'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > JMPZ                                                     $1, ->9
   71     5    >   INIT_STATIC_METHOD_CALL                                  'offsetGet'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0  $2      
          8      > RETURN                                                   $2
   73     9    > > RETURN                                                   null
   74    10*     > RETURN                                                   null

End of function offsetget

Function get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 10
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l56rd
function name:  get
number of ops:  12
compiled vars:  !0 = $name, !1 = $default
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   80     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   82     2        INIT_METHOD_CALL                                         'offsetExists'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5      > JMPZ                                                     $2, ->10
   83     6    >   INIT_STATIC_METHOD_CALL                                  'offsetGet'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0  $3      
          9      > RETURN                                                   $3
   85    10    > > RETURN                                                   !1
   86    11*     > RETURN                                                   null

End of function get

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/l56rd
function name:  set
number of ops:  8
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   92     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   94     2        FETCH_THIS                                       $2      
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
   95     5        FETCH_THIS                                       ~4      
          6      > RETURN                                                   ~4
   96     7*     > RETURN                                                   null

End of function set

End of class Parameters.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.06 ms | 1404 KiB | 19 Q