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, $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/ZQXMp
function name:  (null)
number of ops:  30
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%2FZQXMp%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        SEND_VAR                                                 !1
   19     8        SEND_VAL                                                 'Foo'
          9        DO_FCALL                                      0  $9      
   16    10        ASSIGN                                                   !2, $9
   22    11        INIT_FCALL                                               'var_dump'
         12        INIT_DYNAMIC_CALL                                        !2
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0  $11     
         15        SEND_VAR                                                 $11
         16        DO_ICALL                                                 
   24    17        NEW                                              $13     'Foo'
         18        DO_FCALL                                      0          
         19        ASSIGN                                                   !3, $13
   25    20        INIT_METHOD_CALL                                         !3, 'setBar'
         21        SEND_VAL_EX                                              'TAB%21'
         22        DO_FCALL                                      0          
   27    23        INIT_FCALL                                               'var_dump'
         24        INIT_DYNAMIC_CALL                                        !2
         25        SEND_VAR_EX                                              !3
         26        DO_FCALL                                      0  $17     
         27        SEND_VAR                                                 $17
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FZQXMp%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZQXMp
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%2FZQXMp%3A11%240

Class Foo:
Function setbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZQXMp
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:
166.22 ms | 1400 KiB | 17 Q