3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /** * @param Foo|callable $x * @return string */ function process(callable $x): string { return $x(); } class Foo { public function __invoke(): string { return 'I know kung fu!'; } } echo process(new Foo()); echo process(function(): int { return 42; });
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Ncgj
function name:  (null)
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'process'
          1        NEW                                              $0      'Foo'
          2        DO_FCALL                                      0          
          3        SEND_VAR                                                 $0
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
   23     6        INIT_FCALL                                               'process'
          7        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
   25     8        SEND_VAL                                                 ~3
   23     9        DO_FCALL                                      0  $4      
   25    10        ECHO                                                     $4
         11      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Ncgj
function name:  {closure}
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E > > RETURN                                                   42
   25     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of Dynamic Function 0

Function process:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Ncgj
function name:  process
number of ops:  7
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        INIT_DYNAMIC_CALL                                        !0
          2        DO_FCALL                                      0  $1      
          3        VERIFY_RETURN_TYPE                                       $1
          4      > RETURN                                                   $1
   12     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null

End of function process

Class Foo:
Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Ncgj
function name:  __invoke
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E > > RETURN                                                   'I+know+kung+fu%21'
   19     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function __invoke

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.61 ms | 1434 KiB | 15 Q