3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { $foo = (yield 'strlen' => ['a']); $foo .= (yield 'strlen' => ['ab']); $foo .= (yield 'strlen' => ['abc']); yield $foo."final"; } function call_generator_function($g) { $args = $g->current(); $callable = $g->key(); while ($g->valid() && is_callable($callable)) { $return = call_user_func_array($callable, $args); $g->send($return); $args = $g->current(); $callable = $g->key(); } return $args; } $result = call_generator_function(foo()); var_dump($result); var_dump(foo());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9sYVF
function name:  (null)
number of ops:  15
compiled vars:  !0 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_FCALL                                               'call_generator_function'
          1        INIT_FCALL                                               'foo'
          2        DO_FCALL                                      0  $1      
          3        SEND_VAR                                                 $1
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   32     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
   33     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'foo'
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 161) Position 1 = -2
filename:       /in/9sYVF
function name:  foo
number of ops:  10
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   GENERATOR_CREATE                                         
    5     1        YIELD                                            $1      <array>, 'strlen'
          2        ASSIGN                                                   !0, $1
    7     3        YIELD                                            $3      <array>, 'strlen'
          4        ASSIGN_OP                                     8          !0, $3
    9     5        YIELD                                            $5      <array>, 'strlen'
          6        ASSIGN_OP                                     8          !0, $5
   11     7        CONCAT                                           ~7      !0, 'final'
          8        YIELD                                                    ~7
   12     9      > GENERATOR_RETURN                                         

End of function foo

Function call_generator_function:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 8
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 29
Branch analysis from position: 25
Branch analysis from position: 29
Branch analysis from position: 29
filename:       /in/9sYVF
function name:  call_generator_function
number of ops:  32
compiled vars:  !0 = $g, !1 = $args, !2 = $callable, !3 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        INIT_METHOD_CALL                                         !0, 'current'
          2        DO_FCALL                                      0  $4      
          3        ASSIGN                                                   !1, $4
   17     4        INIT_METHOD_CALL                                         !0, 'key'
          5        DO_FCALL                                      0  $6      
          6        ASSIGN                                                   !2, $6
   19     7      > JMP                                                      ->22
   20     8    >   INIT_USER_CALL                                0          'call_user_func_array', !2
          9        SEND_ARRAY                                               !1
         10        CHECK_UNDEF_ARGS                                         
         11        DO_FCALL                                      0  $8      
         12        ASSIGN                                                   !3, $8
   21    13        INIT_METHOD_CALL                                         !0, 'send'
         14        SEND_VAR_EX                                              !3
         15        DO_FCALL                                      0          
   23    16        INIT_METHOD_CALL                                         !0, 'current'
         17        DO_FCALL                                      0  $11     
         18        ASSIGN                                                   !1, $11
   24    19        INIT_METHOD_CALL                                         !0, 'key'
         20        DO_FCALL                                      0  $13     
         21        ASSIGN                                                   !2, $13
   19    22    >   INIT_METHOD_CALL                                         !0, 'valid'
         23        DO_FCALL                                      0  $15     
         24      > JMPZ_EX                                          ~16     $15, ->29
         25    >   INIT_FCALL                                               'is_callable'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                         $17     
         28        BOOL                                             ~16     $17
         29    > > JMPNZ                                                    ~16, ->8
   27    30    > > RETURN                                                   !1
   28    31*     > RETURN                                                   null

End of function call_generator_function

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
182.33 ms | 1403 KiB | 20 Q