3v4l.org

run code in 300+ PHP versions simultaneously
<?php function decorate(callable $func): callable { return function (mixed ...$args) use ($func): mixed { echo "Do something before the func call.", PHP_EOL; $result = $func(...$args); echo "Do something after the func call.", PHP_EOL; return $result; }; } // ------------------------------------------------------- $func = function (int $x): void { echo $x, PHP_EOL; }; $func = decorate($func); $func(x: 23);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bbNql
function name:  (null)
number of ops:  11
compiled vars:  !0 = $func
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          1        ASSIGN                                                   !0, ~1
   21     2        INIT_FCALL                                               'decorate'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !0, $3
   22     6        INIT_DYNAMIC_CALL                                        !0
          7        SEND_VAL_EX                                              23, 'x'
          8        CHECK_UNDEF_ARGS                                         
          9        DO_FCALL                                      1          
         10      > 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/bbNql
function name:  {closure}
number of ops:  4
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        ECHO                                                     !0
          2        ECHO                                                     '%0A'
   20     3      > RETURN                                                   null

End of Dynamic Function 0

Function decorate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bbNql
function name:  decorate
number of ops:  7
compiled vars:  !0 = $func
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          2        BIND_LEXICAL                                             ~1, !0
   13     3        VERIFY_RETURN_TYPE                                       ~1
          4      > RETURN                                                   ~1
   14     5*       VERIFY_RETURN_TYPE                                       
          6*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bbNql
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $args, !1 = $func, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV_VARIADIC                                    !0      
          1        BIND_STATIC                                              !1
    6     2        ECHO                                                     'Do+something+before+the+func+call.'
          3        ECHO                                                     '%0A'
    8     4        INIT_DYNAMIC_CALL                                        !1
          5        SEND_UNPACK                                              !0
          6        CHECK_UNDEF_ARGS                                         
          7        DO_FCALL                                      1  $3      
          8        ASSIGN                                                   !2, $3
   10     9        ECHO                                                     'Do+something+after+the+func+call.'
         10        ECHO                                                     '%0A'
   12    11      > RETURN                                                   !2
   13    12*       VERIFY_RETURN_TYPE                                       
         13*     > RETURN                                                   null

End of Dynamic Function 0

End of function decorate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.38 ms | 1451 KiB | 14 Q