3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public $x = 42; public function foo() { return function () { return $this->x; }; } public function bar() { return static function () { return $this->x; }; } } $a = new A(); $foo = $a->foo(); var_dump($foo()); $bar = $a->bar(); var_dump($bar());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cHu1c
function name:  (null)
number of ops:  20
compiled vars:  !0 = $a, !1 = $foo, !2 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $3      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   17     3        INIT_METHOD_CALL                                         !0, 'foo'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   18     6        INIT_FCALL                                               'var_dump'
          7        INIT_DYNAMIC_CALL                                        !1
          8        DO_FCALL                                      0  $8      
          9        SEND_VAR                                                 $8
         10        DO_ICALL                                                 
   19    11        INIT_METHOD_CALL                                         !0, 'bar'
         12        DO_FCALL                                      0  $10     
         13        ASSIGN                                                   !2, $10
   20    14        INIT_FCALL                                               'var_dump'
         15        INIT_DYNAMIC_CALL                                        !2
         16        DO_FCALL                                      0  $12     
         17        SEND_VAR                                                 $12
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FcHu1c%3A5%240

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

End of function %00%7Bclosure%7D%2Fin%2FcHu1c%3A10%241

Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cHu1c
function name:  foo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FcHu1c%3A5%240'
    7     1      > RETURN                                                   ~0
    8     2*     > RETURN                                                   null

End of function foo

Function bar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cHu1c
function name:  bar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FcHu1c%3A10%241'
   12     1      > RETURN                                                   ~0
   13     2*     > RETURN                                                   null

End of function bar

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.43 ms | 1400 KiB | 15 Q