3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cl =function(){ echo 'Im a closure' . PHP_EOL; }; class test { protected $cloure; public function __construct($closure) { $this->closure = $closure; } public function sayWho() { $closure = $this->closure; $closure(); } } $splstorage = new SplObjectStorage(); $test = new test($closure); $splstorage->attach($test); $after = $splstorage->offsetGet($test); $after->sayWho();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/99Hse
function name:  (null)
number of ops:  19
compiled vars:  !0 = $cl, !1 = $splstorage, !2 = $test, !3 = $closure, !4 = $after
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F99Hse%3A4%240'
          1        ASSIGN                                                   !0, ~5
   29     2        NEW                                              $7      'SplObjectStorage'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $7
   31     5        NEW                                              $10     'test'
          6        SEND_VAR_EX                                              !3
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !2, $10
   33     9        INIT_METHOD_CALL                                         !1, 'attach'
         10        SEND_VAR_EX                                              !2
         11        DO_FCALL                                      0          
   35    12        INIT_METHOD_CALL                                         !1, 'offsetGet'
         13        SEND_VAR_EX                                              !2
         14        DO_FCALL                                      0  $14     
         15        ASSIGN                                                   !4, $14
   36    16        INIT_METHOD_CALL                                         !4, 'sayWho'
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F99Hse%3A4%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/99Hse
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ECHO                                                     'Im+a+closure%0A'
    6     1      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F99Hse%3A4%240

Class test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/99Hse
function name:  __construct
number of ops:  4
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        ASSIGN_OBJ                                               'closure'
          2        OP_DATA                                                  !0
   17     3      > RETURN                                                   null

End of function __construct

Function saywho:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/99Hse
function name:  sayWho
number of ops:  5
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   FETCH_OBJ_R                                      ~1      'closure'
          1        ASSIGN                                                   !0, ~1
   22     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0          
   23     4      > RETURN                                                   null

End of function saywho

End of class test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.87 ms | 1399 KiB | 13 Q