3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo {} class Bar { private $foos; public function __construct(callable ...$foos) { $this->foos = $foos; } public function getFoo($id) : Foo { return $this->foos[$id](); } } class Baz { public function run($id) : Foo { return (new Bar( function(){ return new Foo; }, function(){ return new Foo; }, function(){ return new Foo; }, function(){ return new Foo; } ))->getFoo($id); } } var_dump((new Baz)->run(2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mgLWH
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'Baz'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'run'
          4        SEND_VAL_EX                                              2
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FmgLWH%3A25%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mgLWH
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $0      'Foo'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FmgLWH%3A25%240

Function %00%7Bclosure%7D%2Fin%2FmgLWH%3A26%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mgLWH
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $0      'Foo'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FmgLWH%3A26%241

Function %00%7Bclosure%7D%2Fin%2FmgLWH%3A27%242:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mgLWH
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   NEW                                              $0      'Foo'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FmgLWH%3A27%242

Function %00%7Bclosure%7D%2Fin%2FmgLWH%3A28%243:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mgLWH
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $0      'Foo'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
          3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FmgLWH%3A28%243

Class Foo: [no user functions]
Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mgLWH
function name:  __construct
number of ops:  4
compiled vars:  !0 = $foos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV_VARIADIC                                    !0      
   11     1        ASSIGN_OBJ                                               'foos'
          2        OP_DATA                                                  !0
   12     3      > RETURN                                                   null

End of function __construct

Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mgLWH
function name:  getFoo
number of ops:  9
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        FETCH_OBJ_R                                      ~1      'foos'
          2        FETCH_DIM_R                                      ~2      ~1, !0
          3        INIT_DYNAMIC_CALL                                        ~2
          4        DO_FCALL                                      0  $3      
          5        VERIFY_RETURN_TYPE                                       $3
          6      > RETURN                                                   $3
   17     7*       VERIFY_RETURN_TYPE                                       
          8*     > RETURN                                                   null

End of function getfoo

End of class Bar.

Class Baz:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mgLWH
function name:  run
number of ops:  18
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        NEW                                              $1      'Bar'
   25     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FmgLWH%3A25%240'
          3        SEND_VAL_EX                                              ~2
   26     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FmgLWH%3A26%241'
          5        SEND_VAL_EX                                              ~3
   27     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FmgLWH%3A27%242'
          7        SEND_VAL_EX                                              ~4
   28     8        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FmgLWH%3A28%243'
          9        SEND_VAL_EX                                              ~5
         10        DO_FCALL                                      0          
   29    11        INIT_METHOD_CALL                                         $1, 'getFoo'
         12        SEND_VAR_EX                                              !0
         13        DO_FCALL                                      0  $7      
         14        VERIFY_RETURN_TYPE                                       $7
         15      > RETURN                                                   $7
   30    16*       VERIFY_RETURN_TYPE                                       
         17*     > RETURN                                                   null

End of function run

End of class Baz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.62 ms | 1400 KiB | 15 Q