3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo{ private $bar = 'baz'; public function setBar($bar) { $this->bar = $bar; } } $hydrator = Closure::bind( function ($obj) { return get_object_vars($obj); }, null, // required blueprint! 'Foo' // setting correct class scope (in case of inheritances) ); var_dump($hydrator(new 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/9XsrD
function name:  (null)
number of ops:  28
compiled vars:  !0 = $hydrator, !1 = $foo2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
   13     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9XsrD%3A13%240'
   15     2        SEND_VAL                                                 ~2
   16     3        SEND_VAL                                                 null
   17     4        SEND_VAL                                                 'Foo'
          5        DO_FCALL                                      0  $3      
   12     6        ASSIGN                                                   !0, $3
   20     7        INIT_FCALL                                               'var_dump'
          8        INIT_DYNAMIC_CALL                                        !0
          9        NEW                                              $5      'Foo'
         10        DO_FCALL                                      0          
         11        SEND_VAR_NO_REF_EX                                       $5
         12        DO_FCALL                                      0  $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                                 
   22    15        NEW                                              $9      'Foo'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !1, $9
   23    18        INIT_METHOD_CALL                                         !1, 'setBar'
         19        SEND_VAL_EX                                              'TAB%21'
         20        DO_FCALL                                      0          
   25    21        INIT_FCALL                                               'var_dump'
         22        INIT_DYNAMIC_CALL                                        !0
         23        SEND_VAR_EX                                              !1
         24        DO_FCALL                                      0  $13     
         25        SEND_VAR                                                 $13
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2F9XsrD%3A13%240

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