3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { private $baz = 'tab'; } $accessor = function () { return $this->baz; }; $writer = function ($bar) { $this->baz = $bar; }; $bar = new Bar(); $accessor = Closure::bind($accessor, $bar, 'Bar'); $writer = Closure::bind($writer, $bar, 'Bar'); var_dump($accessor()); $writer('taz'); var_dump($bar);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tf7SQ
function name:  (null)
number of ops:  31
compiled vars:  !0 = $accessor, !1 = $writer, !2 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ftf7SQ%3A8%240'
          1        ASSIGN                                                   !0, ~3
    9     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ftf7SQ%3A9%241'
          3        ASSIGN                                                   !1, ~5
   11     4        NEW                                              $7      'Bar'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $7
   13     7        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          8        SEND_VAR                                                 !0
          9        SEND_VAR                                                 !2
         10        SEND_VAL                                                 'Bar'
         11        DO_FCALL                                      0  $10     
         12        ASSIGN                                                   !0, $10
   14    13        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         14        SEND_VAR                                                 !1
         15        SEND_VAR                                                 !2
         16        SEND_VAL                                                 'Bar'
         17        DO_FCALL                                      0  $12     
         18        ASSIGN                                                   !1, $12
   16    19        INIT_FCALL                                               'var_dump'
         20        INIT_DYNAMIC_CALL                                        !0
         21        DO_FCALL                                      0  $14     
         22        SEND_VAR                                                 $14
         23        DO_ICALL                                                 
   18    24        INIT_DYNAMIC_CALL                                        !1
         25        SEND_VAL_EX                                              'taz'
         26        DO_FCALL                                      0          
   20    27        INIT_FCALL                                               'var_dump'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2Ftf7SQ%3A8%240

Function %00%7Bclosure%7D%2Fin%2Ftf7SQ%3A9%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tf7SQ
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        FETCH_THIS                                       $1      
          2        ASSIGN_OBJ                                               $1, 'baz'
          3        OP_DATA                                                  !0
          4      > RETURN                                                   null

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

Class Bar: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.19 ms | 1400 KiB | 15 Q