3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Summable { public function getNumericValue(): int; } class One implements Summable { public function getNumericValue(): int { return 1; } } class Two implements Summable { public function getNumericValue(): int { return 2; } } function sumNumbers(Summable ...$numbers): int { return array_reduce($numbers, fn($sum, Summable $number) => $sum += $number->getNumericValue()); } $numbers = [new One, new Two, new Two]; echo sumNumbers(...$numbers);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8mMt3
function name:  (null)
number of ops:  18
compiled vars:  !0 = $numbers
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'one'
   13     1        DECLARE_CLASS                                            'two'
   23     2        NEW                                              $1      'One'
          3        DO_FCALL                                      0          
          4        INIT_ARRAY                                       ~3      $1
          5        NEW                                              $4      'Two'
          6        DO_FCALL                                      0          
          7        ADD_ARRAY_ELEMENT                                ~3      $4
          8        NEW                                              $6      'Two'
          9        DO_FCALL                                      0          
         10        ADD_ARRAY_ELEMENT                                ~3      $6
         11        ASSIGN                                                   !0, ~3
   25    12        INIT_FCALL                                               'sumnumbers'
         13        SEND_UNPACK                                              !0
         14        CHECK_UNDEF_ARGS                                         
         15        DO_FCALL                                      1  $9      
         16        ECHO                                                     $9
         17      > RETURN                                                   1

Function sumnumbers:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8mMt3
function name:  sumNumbers
number of ops:  10
compiled vars:  !0 = $numbers
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV_VARIADIC                                    !0      
   20     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~1      [0]
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                         $2      
          6        VERIFY_RETURN_TYPE                                       $2
          7      > RETURN                                                   $2
   21     8*       VERIFY_RETURN_TYPE                                       
          9*     > 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/8mMt3
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $sum, !1 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        INIT_METHOD_CALL                                         !1, 'getNumericValue'
          3        DO_FCALL                                      0  $2      
          4        ASSIGN_OP                                     1  ~3      !0, $2
          5      > RETURN                                                   ~3
          6*     > RETURN                                                   null

End of Dynamic Function 0

End of function sumnumbers

Class Summable:
Function getnumericvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8mMt3
function name:  getNumericValue
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function getnumericvalue

End of class Summable.

Class One:
Function getnumericvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8mMt3
function name:  getNumericValue
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E > > RETURN                                                   1
   10     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function getnumericvalue

End of class One.

Class Two:
Function getnumericvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8mMt3
function name:  getNumericValue
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E > > RETURN                                                   2
   16     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function getnumericvalue

End of class Two.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.89 ms | 1005 KiB | 15 Q