3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $name; protected $age; public $gender; public static $time; function __construct($name, $age, $gender, DateTime $time) { $this->name = $name; $this->age = $age; $this->gender = $gender; self::$time = $time->getTimestamp(); } } $foo = new Foo('hchen', 10, 'M', new DateTime('now')); $newFoo = Closure::bind( function() { return get_object_vars($this); }, $foo, 'Foo'); print_r(PHP_EOL.'<pre>========== START DEBUG: $newFoo =========='.PHP_EOL); print_r($newFoo()); print_r(PHP_EOL.'========== END OF $newFoo DEBUG ==========</pre>'.PHP_EOL); die(); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/rO551
function name:  (null)
number of ops:  30
compiled vars:  !0 = $foo, !1 = $newFoo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $2      'Foo'
          1        SEND_VAL_EX                                              'hchen'
          2        SEND_VAL_EX                                              10
          3        SEND_VAL_EX                                              'M'
          4        NEW                                              $3      'DateTime'
          5        SEND_VAL_EX                                              'now'
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $3
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !0, $2
   22    10        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
   23    11        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FrO551%3A23%240'
   25    12        SEND_VAL                                                 ~7
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 'Foo'
         15        DO_FCALL                                      0  $8      
   22    16        ASSIGN                                                   !1, $8
   26    17        INIT_FCALL                                               'print_r'
         18        SEND_VAL                                                 '%0A%3Cpre%3E%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D+START+DEBUG%3A+%24newFoo+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%0A'
         19        DO_ICALL                                                 
   27    20        INIT_FCALL                                               'print_r'
         21        INIT_DYNAMIC_CALL                                        !1
         22        DO_FCALL                                      0  $11     
         23        SEND_VAR                                                 $11
         24        DO_ICALL                                                 
   28    25        INIT_FCALL                                               'print_r'
         26        SEND_VAL                                                 '%0A%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D+END+OF+%24newFoo+DEBUG+%3D%3D%3D%3D%3D%3D%3D%3D%3D%3D%3C%2Fpre%3E%0A'
         27        DO_ICALL                                                 
   29    28      > EXIT                                                     
   30    29*     > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FrO551%3A23%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rO551
function name:  {closure}
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'get_object_vars'
          1        FETCH_THIS                                       ~0      
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   25     5*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FrO551%3A23%240

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rO551
function name:  __construct
number of ops:  15
compiled vars:  !0 = $name, !1 = $age, !2 = $gender, !3 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
   13     4        ASSIGN_OBJ                                               'name'
          5        OP_DATA                                                  !0
   14     6        ASSIGN_OBJ                                               'age'
          7        OP_DATA                                                  !1
   15     8        ASSIGN_OBJ                                               'gender'
          9        OP_DATA                                                  !2
   16    10        INIT_METHOD_CALL                                         !3, 'getTimestamp'
         11        DO_FCALL                                      0  $8      
         12        ASSIGN_STATIC_PROP                                       'time'
         13        OP_DATA                                                  $8
   17    14      > RETURN                                                   null

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.91 ms | 1400 KiB | 17 Q