3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private static $sfoo = 1; public $ifoo = 2; } $cl1 = static function() { return A::$sfoo; }; $cl2 = function() { return $this->ifoo; }; $x = new A(); $x->ifoo=3; $bcl1 = Closure::bind($cl1, null, 'A'); $bcl23 = Closure::bind($cl2, new A, 'A'); $bcl2 = Closure::bind($cl2, $x, 'A'); echo $bcl1(), "\n"; echo $bcl2(), "\n"; echo $bcl23(), "\n"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bUWSv
function name:  (null)
number of ops:  42
compiled vars:  !0 = $cl1, !1 = $cl2, !2 = $x, !3 = $bcl1, !4 = $bcl23, !5 = $bcl2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FbUWSv%3A6%240'
          1        ASSIGN                                                   !0, ~6
    9     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FbUWSv%3A9%241'
          3        ASSIGN                                                   !1, ~8
   12     4        NEW                                              $10     'A'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $10
          7        ASSIGN_OBJ                                               !2, 'ifoo'
          8        OP_DATA                                                  3
   13     9        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 null
         12        SEND_VAL                                                 'A'
         13        DO_FCALL                                      0  $14     
         14        ASSIGN                                                   !3, $14
   14    15        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         16        SEND_VAR                                                 !1
         17        NEW                                              $16     'A'
         18        DO_FCALL                                      0          
         19        SEND_VAR                                                 $16
         20        SEND_VAL                                                 'A'
         21        DO_FCALL                                      0  $18     
         22        ASSIGN                                                   !4, $18
   15    23        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         24        SEND_VAR                                                 !1
         25        SEND_VAR                                                 !2
         26        SEND_VAL                                                 'A'
         27        DO_FCALL                                      0  $20     
         28        ASSIGN                                                   !5, $20
   16    29        INIT_DYNAMIC_CALL                                        !3
         30        DO_FCALL                                      0  $22     
         31        ECHO                                                     $22
         32        ECHO                                                     '%0A'
   17    33        INIT_DYNAMIC_CALL                                        !5
         34        DO_FCALL                                      0  $23     
         35        ECHO                                                     $23
         36        ECHO                                                     '%0A'
   19    37        INIT_DYNAMIC_CALL                                        !4
         38        DO_FCALL                                      0  $24     
         39        ECHO                                                     $24
         40        ECHO                                                     '%0A'
   20    41      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FbUWSv%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bUWSv
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'sfoo'
          1      > RETURN                                                   ~0
    8     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FbUWSv%3A6%240

Function %00%7Bclosure%7D%2Fin%2FbUWSv%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bUWSv
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_THIS                                       $0      
          1        FETCH_OBJ_R                                      ~1      $0, 'ifoo'
          2      > RETURN                                                   ~1
   11     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FbUWSv%3A9%241

Class A: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.49 ms | 1399 KiB | 13 Q