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, null, '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/RCQme
function name:  (null)
number of ops:  40
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%2FRCQme%3A6%240'
          1        ASSIGN                                                   !0, ~6
    9     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FRCQme%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        SEND_VAL                                                 null
         18        SEND_VAL                                                 'A'
         19        DO_FCALL                                      0  $16     
         20        ASSIGN                                                   !4, $16
   15    21        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         22        SEND_VAR                                                 !1
         23        SEND_VAR                                                 !2
         24        SEND_VAL                                                 'A'
         25        DO_FCALL                                      0  $18     
         26        ASSIGN                                                   !5, $18
   16    27        INIT_DYNAMIC_CALL                                        !3
         28        DO_FCALL                                      0  $20     
         29        ECHO                                                     $20
         30        ECHO                                                     '%0A'
   17    31        INIT_DYNAMIC_CALL                                        !5
         32        DO_FCALL                                      0  $21     
         33        ECHO                                                     $21
         34        ECHO                                                     '%0A'
   19    35        INIT_DYNAMIC_CALL                                        !4
         36        DO_FCALL                                      0  $22     
         37        ECHO                                                     $22
         38        ECHO                                                     '%0A'
   20    39      > RETURN                                                   1

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

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

Class A: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.88 ms | 1399 KiB | 13 Q