3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ClosureTester { private $string = 'default'; public function foo() { return $this->string; } public function someMethod() { $this->string = 'changed'; $self = $this; $closure = function() use ($self) { return 'xxx';//$self->foo(); }; return $closure(); } } $c = new ClosureTester(); echo $c->someMethod();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t0noJ
function name:  (null)
number of ops:  7
compiled vars:  !0 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $1      'ClosureTester'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   22     3        INIT_METHOD_CALL                                         !0, 'someMethod'
          4        DO_FCALL                                      0  $4      
          5        ECHO                                                     $4
          6      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2Ft0noJ%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t0noJ
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $self
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   BIND_STATIC                                              !0
   15     1      > RETURN                                                   'xxx'
   16     2*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Ft0noJ%3A14%240

Class ClosureTester:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t0noJ
function name:  foo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_OBJ_R                                      ~0      'string'
          1      > RETURN                                                   ~0
    9     2*     > RETURN                                                   null

End of function foo

Function somemethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t0noJ
function name:  someMethod
number of ops:  11
compiled vars:  !0 = $self, !1 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ASSIGN_OBJ                                               'string'
          1        OP_DATA                                                  'changed'
   13     2        FETCH_THIS                                       ~3      
          3        ASSIGN                                                   !0, ~3
   14     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ft0noJ%3A14%240'
          5        BIND_LEXICAL                                             ~5, !0
          6        ASSIGN                                                   !1, ~5
   17     7        INIT_DYNAMIC_CALL                                        !1
          8        DO_FCALL                                      0  $7      
          9      > RETURN                                                   $7
   18    10*     > RETURN                                                   null

End of function somemethod

End of class ClosureTester.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.85 ms | 1395 KiB | 13 Q