3v4l.org

run code in 500+ PHP versions simultaneously
<?php function test(Closure $callback): void { $toto = call_user_func($callback); } $fake = new class { public $called = false; public function __invoke() { $this->called = true; } }; var_dump($fake); test(Closure::fromCallable($fake)); var_dump($fake);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yaq5A
function name:  (null)
number of ops:  17
compiled vars:  !0 = $fake
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   DECLARE_ANON_CLASS                                   <unknown> 
          1        NEW                                                  $2      $1
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $2
   18     4        INIT_FCALL                                                   'var_dump'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                                     
   20     7        INIT_FCALL                                                   'test'
          8        INIT_STATIC_METHOD_CALL                                      'Closure', 'fromCallable'
          9        SEND_VAR                                                     !0
         10        DO_FCALL                                          0  $6      
         11        SEND_VAR                                                     $6
         12        DO_FCALL                                          0          
   22    13        INIT_FCALL                                                   'var_dump'
         14        SEND_VAR                                                     !0
         15        DO_ICALL                                                     
         16      > RETURN                                                       1

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yaq5A
function name:  test
number of ops:  5
compiled vars:  !0 = $callback, !1 = $toto
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    5     1        INIT_USER_CALL                                    0          'call_user_func', !0
          2        DO_FCALL                                          0  $2      
          3        ASSIGN                                                       !1, $2
    6     4      > RETURN                                                       null

End of function test

Class class@anonymous:
Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yaq5A
function name:  __invoke
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   ASSIGN_OBJ                                                   'called'
          1        OP_DATA                                                      <true>
   15     2      > RETURN                                                       null

End of function __invoke

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.02 ms | 2127 KiB | 15 Q