3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Test; $function = function () { return $a + $b . "Hello {$c} World!"; }; // Reflect the closure and fetch relevant properties $reflection = new \ReflectionFunction($function); $fileName = $reflection->getFileName(); $startLine = $reflection->getStartLine(); $endLine = $reflection->getEndLine(); // Slice out the lines $lines = array_slice(file($fileName), $startLine - 1, ($endLine - $startLine) + 1); $code = sprintf('<?php %s ; ?>', implode($lines)); // Tokenize and filter T_WHITESPACE $tokens = array_filter(token_get_all($code), function ($token) { if (is_array($token)) { if ($token[0] == T_WHITESPACE) { return false; } } return true; }); // Dump for shits and giggles foreach ($tokens as $token) { echo PHP_EOL; if (is_array($token)) { echo str_pad(token_name($token[0]), 30, '.') . trim($token[1]); continue; } echo str_pad('SYMBOL', 30, '.') . $token; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 78
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 78
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 70
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 70
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
filename:       /in/LU4S3
function name:  (null)
number of ops:  80
compiled vars:  !0 = $function, !1 = $reflection, !2 = $fileName, !3 = $startLine, !4 = $endLine, !5 = $lines, !6 = $code, !7 = $tokens, !8 = $token
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00test%5C%7Bclosure%7D%2Fin%2FLU4S3%3A5%240'
          1        ASSIGN                                                   !0, ~9
   10     2        NEW                                              $11     'ReflectionFunction'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $11
   11     6        INIT_METHOD_CALL                                         !1, 'getFileName'
          7        DO_FCALL                                      0  $14     
          8        ASSIGN                                                   !2, $14
   12     9        INIT_METHOD_CALL                                         !1, 'getStartLine'
         10        DO_FCALL                                      0  $16     
         11        ASSIGN                                                   !3, $16
   13    12        INIT_METHOD_CALL                                         !1, 'getEndLine'
         13        DO_FCALL                                      0  $18     
         14        ASSIGN                                                   !4, $18
   16    15        INIT_NS_FCALL_BY_NAME                                    'Test%5Carray_slice'
         16        INIT_NS_FCALL_BY_NAME                                    'Test%5Cfile'
         17        SEND_VAR_EX                                              !2
         18        DO_FCALL                                      0  $20     
         19        SEND_VAR_NO_REF_EX                                       $20
         20        SUB                                              ~21     !3, 1
         21        SEND_VAL_EX                                              ~21
         22        SUB                                              ~22     !4, !3
         23        ADD                                              ~23     ~22, 1
         24        SEND_VAL_EX                                              ~23
         25        DO_FCALL                                      0  $24     
         26        ASSIGN                                                   !5, $24
   17    27        INIT_NS_FCALL_BY_NAME                                    'Test%5Csprintf'
         28        SEND_VAL_EX                                              '%3C%3Fphp+%25s+%3B+%3F%3E'
         29        INIT_NS_FCALL_BY_NAME                                    'Test%5Cimplode'
         30        SEND_VAR_EX                                              !5
         31        DO_FCALL                                      0  $26     
         32        SEND_VAR_NO_REF_EX                                       $26
         33        DO_FCALL                                      0  $27     
         34        ASSIGN                                                   !6, $27
   20    35        INIT_NS_FCALL_BY_NAME                                    'Test%5Carray_filter'
         36        INIT_NS_FCALL_BY_NAME                                    'Test%5Ctoken_get_all'
         37        SEND_VAR_EX                                              !6
         38        DO_FCALL                                      0  $29     
         39        SEND_VAR_NO_REF_EX                                       $29
         40        DECLARE_LAMBDA_FUNCTION                                  '%00test%5C%7Bclosure%7D%2Fin%2FLU4S3%3A20%241'
   29    41        SEND_VAL_EX                                              ~30
         42        DO_FCALL                                      0  $31     
   20    43        ASSIGN                                                   !7, $31
   32    44      > FE_RESET_R                                       $33     !7, ->78
         45    > > FE_FETCH_R                                               $33, !8, ->78
   34    46    >   FETCH_CONSTANT                                   ~34     'Test%5CPHP_EOL'
         47        ECHO                                                     ~34
   35    48        INIT_NS_FCALL_BY_NAME                                    'Test%5Cis_array'
         49        SEND_VAR_EX                                              !8
         50        DO_FCALL                                      0  $35     
         51      > JMPZ                                                     $35, ->70
   37    52    >   INIT_NS_FCALL_BY_NAME                                    'Test%5Cstr_pad'
         53        INIT_NS_FCALL_BY_NAME                                    'Test%5Ctoken_name'
         54        CHECK_FUNC_ARG                                           
         55        FETCH_DIM_FUNC_ARG                               $36     !8, 0
         56        SEND_FUNC_ARG                                            $36
         57        DO_FCALL                                      0  $37     
         58        SEND_VAR_NO_REF_EX                                       $37
         59        SEND_VAL_EX                                              30
         60        SEND_VAL_EX                                              '.'
         61        DO_FCALL                                      0  $38     
         62        INIT_NS_FCALL_BY_NAME                                    'Test%5Ctrim'
         63        CHECK_FUNC_ARG                                           
         64        FETCH_DIM_FUNC_ARG                               $39     !8, 1
         65        SEND_FUNC_ARG                                            $39
         66        DO_FCALL                                      0  $40     
         67        CONCAT                                           ~41     $38, $40
         68        ECHO                                                     ~41
   38    69      > JMP                                                      ->45
   40    70    >   INIT_NS_FCALL_BY_NAME                                    'Test%5Cstr_pad'
         71        SEND_VAL_EX                                              'SYMBOL'
         72        SEND_VAL_EX                                              30
         73        SEND_VAL_EX                                              '.'
         74        DO_FCALL                                      0  $42     
         75        CONCAT                                           ~43     $42, !8
         76        ECHO                                                     ~43
   32    77      > JMP                                                      ->45
         78    >   FE_FREE                                                  $33
   41    79      > RETURN                                                   1

Function %00test%5C%7Bclosure%7D%2Fin%2FLU4S3%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LU4S3
function name:  Test\{closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ADD                                              ~3      !0, !1
          1        ROPE_INIT                                     3  ~5      'Hello+'
          2        ROPE_ADD                                      1  ~5      ~5, !2
          3        ROPE_END                                      2  ~4      ~5, '+World%21'
          4        CONCAT                                           ~7      ~3, ~4
          5      > RETURN                                                   ~7
    7     6*     > RETURN                                                   null

End of function %00test%5C%7Bclosure%7D%2Fin%2FLU4S3%3A5%240

Function %00test%5C%7Bclosure%7D%2Fin%2FLU4S3%3A20%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/LU4S3
function name:  Test\{closure}
number of ops:  12
compiled vars:  !0 = $token
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        INIT_NS_FCALL_BY_NAME                                    'Test%5Cis_array'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > JMPZ                                                     $1, ->10
   23     5    >   FETCH_DIM_R                                      ~2      !0, 0
          6        FETCH_CONSTANT                                   ~3      'Test%5CT_WHITESPACE'
          7        IS_EQUAL                                                 ~2, ~3
          8      > JMPZ                                                     ~4, ->10
   25     9    > > RETURN                                                   <false>
   28    10    > > RETURN                                                   <true>
   29    11*     > RETURN                                                   null

End of function %00test%5C%7Bclosure%7D%2Fin%2FLU4S3%3A20%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.99 ms | 1404 KiB | 33 Q