3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected $prot; public $pub; } function hydrate($class,$dry){ static $hydrators = array(); $h = '_Hydrator__'.$class; if (empty($hydrators[$class])) { eval('class '.$h.' extends '.$class.' { static function __hydrate(array $array) { $o = new '.$class.'(); foreach ($array as $prop_name => $prop_value) $o->$prop_name = $prop_value; return $o; } } '); $hydrators[$class] = true; } return $h::__hydrate($dry); } var_dump( hydrate('Foo',array('prot'=>1,'pub'=>2)) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9fuML
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'var_dump'
   27     1        INIT_FCALL                                               'hydrate'
          2        SEND_VAL                                                 'Foo'
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   28     7      > RETURN                                                   1

Function hydrate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/9fuML
function name:  hydrate
number of ops:  22
compiled vars:  !0 = $class, !1 = $dry, !2 = $hydrators, !3 = $h
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        BIND_STATIC                                              !2
   11     3        CONCAT                                           ~4      '_Hydrator__', !0
          4        ASSIGN                                                   !3, ~4
   12     5        ISSET_ISEMPTY_DIM_OBJ                         1          !2, !0
          6      > JMPZ                                                     ~6, ->16
   13     7    >   CONCAT                                           ~7      'class+', !3
          8        CONCAT                                           ~8      ~7, '+extends+'
          9        CONCAT                                           ~9      ~8, !0
         10        CONCAT                                           ~10     ~9, '+%7B%0A++++++++++++++++++static+function+__hydrate%28array+%24array%29+%7B%0A++++++++++++++++++++++%24o+%3D+new+'
   15    11        CONCAT                                           ~11     ~10, !0
         12        CONCAT                                           ~12     ~11, '%28%29%3B%0A++++++++++++++++++++++foreach+%28%24array+as+%24prop_name+%3D%3E+%24prop_value%29+%24o-%3E%24prop_name+%3D+%24prop_value%3B%0A++++++++++++++++++++++return+%24o%3B%0A++++++++++++++++++%7D+++%0A++++++++++++++%7D%0A++++++++'
         13        INCLUDE_OR_EVAL                                          ~12, EVAL
   21    14        ASSIGN_DIM                                               !2, !0
         15        OP_DATA                                                  <true>
   23    16    >   FETCH_CLASS                                   0  $15     !3
         17        INIT_STATIC_METHOD_CALL                                  $15, '__hydrate'
         18        SEND_VAR_EX                                              !1
         19        DO_FCALL                                      0  $16     
         20      > RETURN                                                   $16
   24    21*     > RETURN                                                   null

End of function hydrate

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.43 ms | 1403 KiB | 16 Q