3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace x { define('x\_', bin2hex(random_bytes(128))); function partial(callable $f, ...$x) { return static function (...$y) use ($f, $x) { // replace every placeholder with the next passed parameter $x = array_map( function ($a) use (&$y) { return _ === $a ? array_shift($y) : $a; }, $x ); // append any remaining parameters $x = array_merge($x, $y); return $f(...$x); }; } } namespace { use const x\_; use function x\partial; $cube = partial('pow', _, 3); var_dump($cube(2)); $dash = partial('implode', '-'); var_dump($dash([1,2,3])); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TiE6f
function name:  (null)
number of ops:  35
compiled vars:  !0 = $cube, !1 = $dash
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_NS_FCALL_BY_NAME                                    'x%5Cdefine'
          1        SEND_VAL_EX                                              'x%5C_'
          2        INIT_NS_FCALL_BY_NAME                                    'x%5Cbin2hex'
          3        INIT_NS_FCALL_BY_NAME                                    'x%5Crandom_bytes'
          4        SEND_VAL_EX                                              128
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR_NO_REF_EX                                       $2
          7        DO_FCALL                                      0  $3      
          8        SEND_VAR_NO_REF_EX                                       $3
          9        DO_FCALL                                      0          
   27    10        INIT_FCALL                                               'x%5Cpartial'
         11        SEND_VAL                                                 'pow'
         12        FETCH_CONSTANT                                   ~5      'x%5C_'
         13        SEND_VAL                                                 ~5
         14        SEND_VAL                                                 3
         15        DO_FCALL                                      0  $6      
         16        ASSIGN                                                   !0, $6
   29    17        INIT_FCALL                                               'var_dump'
         18        INIT_DYNAMIC_CALL                                        !0
         19        SEND_VAL_EX                                              2
         20        DO_FCALL                                      0  $8      
         21        SEND_VAR                                                 $8
         22        DO_ICALL                                                 
   31    23        INIT_FCALL                                               'x%5Cpartial'
         24        SEND_VAL                                                 'implode'
         25        SEND_VAL                                                 '-'
         26        DO_FCALL                                      0  $10     
         27        ASSIGN                                                   !1, $10
   33    28        INIT_FCALL                                               'var_dump'
         29        INIT_DYNAMIC_CALL                                        !1
         30        SEND_VAL_EX                                              <array>
         31        DO_FCALL                                      0  $12     
         32        SEND_VAR                                                 $12
         33        DO_ICALL                                                 
   34    34      > RETURN                                                   1

Function x%5Cpartial:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TiE6f
function name:  x\partial
number of ops:  7
compiled vars:  !0 = $f, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
    7     2        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
          3        BIND_LEXICAL                                             ~2, !0
          4        BIND_LEXICAL                                             ~2, !1
   19     5      > RETURN                                                   ~2
   20     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/TiE6f
function name:  x\{closure}
number of ops:  21
compiled vars:  !0 = $y, !1 = $f, !2 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_VARIADIC                                    !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
    9     3        INIT_NS_FCALL_BY_NAME                                    'x%5Carray_map'
   10     4        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          5        BIND_LEXICAL                                             ~3, !0
   12     6        SEND_VAL_EX                                              ~3
   10     7        SEND_VAR_EX                                              !2
    9     8        DO_FCALL                                      0  $4      
          9        ASSIGN                                                   !2, $4
   16    10        INIT_NS_FCALL_BY_NAME                                    'x%5Carray_merge'
         11        SEND_VAR_EX                                              !2
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0  $6      
         14        ASSIGN                                                   !2, $6
   18    15        INIT_DYNAMIC_CALL                                        !1
         16        SEND_UNPACK                                              !2
         17        CHECK_UNDEF_ARGS                                         
         18        DO_FCALL                                      1  $8      
         19      > RETURN                                                   $8
   19    20*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TiE6f
function name:  x\{closure}
number of ops:  13
compiled vars:  !0 = $a, !1 = $y
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   11     2        FETCH_CONSTANT                                   ~2      'x%5C_'
          3        IS_IDENTICAL                                             !0, ~2
          4      > JMPZ                                                     ~3, ->10
          5    >   INIT_NS_FCALL_BY_NAME                                    'x%5Carray_shift'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $4      
          8        QM_ASSIGN                                        ~5      $4
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~5      !0
         11    > > RETURN                                                   ~5
   12    12*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

End of function x%5Cpartial

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.08 ms | 1011 KiB | 22 Q