3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Bar { private $baz = 'tab'; } class Foo extends Bar { private $baz = 'baz'; public function __construct() { $this->accessor = function () { return $this->baz; }; } } $foo = new Foo(); $bar = new Bar(); $accessor = $foo->accessor; var_dump($accessor()); $accessor = $foo->accessor->bindTo($bar); var_dump($accessor());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gDRjN
function name:  (null)
number of ops:  24
compiled vars:  !0 = $foo, !1 = $bar, !2 = $accessor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $3      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   19     3        NEW                                              $6      'Bar'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $6
   21     6        FETCH_OBJ_R                                      ~9      !0, 'accessor'
          7        ASSIGN                                                   !2, ~9
   23     8        INIT_FCALL                                               'var_dump'
          9        INIT_DYNAMIC_CALL                                        !2
         10        DO_FCALL                                      0  $11     
         11        SEND_VAR                                                 $11
         12        DO_ICALL                                                 
   25    13        FETCH_OBJ_R                                      ~13     !0, 'accessor'
         14        INIT_METHOD_CALL                                         ~13, 'bindTo'
         15        SEND_VAR_EX                                              !1
         16        DO_FCALL                                      0  $14     
         17        ASSIGN                                                   !2, $14
   27    18        INIT_FCALL                                               'var_dump'
         19        INIT_DYNAMIC_CALL                                        !2
         20        DO_FCALL                                      0  $16     
         21        SEND_VAR                                                 $16
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FgDRjN%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gDRjN
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     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%2FgDRjN%3A14%240

Class Bar: [no user functions]
Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gDRjN
function name:  __construct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
          0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FgDRjN%3A14%240'
          1        ASSIGN_OBJ                                               'accessor'
          2        OP_DATA                                                  ~1
   15     3      > RETURN                                                   null

End of function __construct

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.63 ms | 1388 KiB | 15 Q