3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Hoge { private $a = 'foo'; private $b = 'bar'; } function updateProperties($instance, array $properties) { $ref = new ReflectionClass($instance); $props = $ref->getProperties(ReflectionProperty::IS_PRIVATE); foreach ($props as $prop) { if (isset($properties[$prop->name])) { $prop->setAccessible(true); $prop->setValue($properties[$prop->name]); } } } $h = new Hoge; updateProperties($h, array('a' => 'fizz', 'b' => 'buzz')); var_dump($h);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SKp53
function name:  (null)
number of ops:  11
compiled vars:  !0 = $h
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $1      'Hoge'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   20     3        INIT_FCALL                                               'updateproperties'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 <array>
          6        DO_FCALL                                      0          
   21     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function updateproperties:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 24
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/SKp53
function name:  updateProperties
number of ops:  27
compiled vars:  !0 = $instance, !1 = $properties, !2 = $ref, !3 = $props, !4 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        NEW                                              $5      'ReflectionClass'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $5
   10     6        INIT_METHOD_CALL                                         !2, 'getProperties'
          7        SEND_VAL_EX                                              4
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !3, $8
   11    10      > FE_RESET_R                                       $10     !3, ->25
         11    > > FE_FETCH_R                                               $10, !4, ->25
   12    12    >   FETCH_OBJ_R                                      ~11     !4, 'name'
         13        ISSET_ISEMPTY_DIM_OBJ                         0          !1, ~11
         14      > JMPZ                                                     ~12, ->24
   13    15    >   INIT_METHOD_CALL                                         !4, 'setAccessible'
         16        SEND_VAL_EX                                              <true>
         17        DO_FCALL                                      0          
   14    18        INIT_METHOD_CALL                                         !4, 'setValue'
         19        CHECK_FUNC_ARG                                           
         20        FETCH_OBJ_R                                      ~14     !4, 'name'
         21        FETCH_DIM_FUNC_ARG                               $15     !1, ~14
         22        SEND_FUNC_ARG                                            $15
         23        DO_FCALL                                      0          
   11    24    > > JMP                                                      ->11
         25    >   FE_FREE                                                  $10
   17    26      > RETURN                                                   null

End of function updateproperties

Class Hoge: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.29 ms | 1394 KiB | 16 Q