3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo{ private $bar = 'baz'; public function setBar($bar) { $this->bar = $bar; } } $h = function ($obj) { get_object_vars($obj); }; $foo = new Foo(); $hydrator = Closure::bind( $h, new Foo(), // required blueprint! 'Foo' // setting correct class scope (in case of inheritances) ); var_dump($hydrator($foo)); $foo2 = new Foo(); $foo2->setBar('TAB!'); var_dump($hydrator($foo2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p791g
function name:  (null)
number of ops:  32
compiled vars:  !0 = $h, !1 = $foo, !2 = $hydrator, !3 = $foo2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fp791g%3A11%240'
          1        ASSIGN                                                   !0, ~4
   14     2        NEW                                              $6      'Foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $6
   16     5        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
   17     6        SEND_VAR                                                 !0
   18     7        NEW                                              $9      'Foo'
          8        DO_FCALL                                      0          
          9        SEND_VAR                                                 $9
   19    10        SEND_VAL                                                 'Foo'
         11        DO_FCALL                                      0  $11     
   16    12        ASSIGN                                                   !2, $11
   22    13        INIT_FCALL                                               'var_dump'
         14        INIT_DYNAMIC_CALL                                        !2
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0  $13     
         17        SEND_VAR                                                 $13
         18        DO_ICALL                                                 
   24    19        NEW                                              $15     'Foo'
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !3, $15
   25    22        INIT_METHOD_CALL                                         !3, 'setBar'
         23        SEND_VAL_EX                                              'TAB%21'
         24        DO_FCALL                                      0          
   27    25        INIT_FCALL                                               'var_dump'
         26        INIT_DYNAMIC_CALL                                        !2
         27        SEND_VAR_EX                                              !3
         28        DO_FCALL                                      0  $19     
         29        SEND_VAR                                                 $19
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Fp791g%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p791g
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'get_object_vars'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   13     4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Fp791g%3A11%240

Class Foo:
Function setbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p791g
function name:  setBar
number of ops:  4
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function setbar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.56 ms | 1400 KiB | 17 Q