3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sum($a) { return new Sum($a); } class Sum { protected $value; public function __construct($value) { $this->value = $value; } public function __invoke($a) { return new static($this->value + $a); } public function __toString() { return $this->value; } } echo sum(1)(2)(3)(4)(5); //10
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VBDS1
function name:  (null)
number of ops:  18
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'sum'
   28     1        INIT_FCALL                                               'sum'
          2        SEND_VAL                                                 1
          3        DO_FCALL                                      0  $0      
          4        INIT_DYNAMIC_CALL                                        $0
          5        SEND_VAL_EX                                              2
          6        DO_FCALL                                      0  $1      
          7        INIT_DYNAMIC_CALL                                        $1
          8        SEND_VAL_EX                                              3
          9        DO_FCALL                                      0  $2      
         10        INIT_DYNAMIC_CALL                                        $2
         11        SEND_VAL_EX                                              4
         12        DO_FCALL                                      0  $3      
         13        INIT_DYNAMIC_CALL                                        $3
         14        SEND_VAL_EX                                              5
         15        DO_FCALL                                      0  $4      
         16        ECHO                                                     $4
         17      > RETURN                                                   1

Function sum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VBDS1
function name:  sum
number of ops:  6
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        NEW                                              $1      'Sum'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4      > RETURN                                                   $1
    6     5*     > RETURN                                                   null

End of function sum

Class Sum:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VBDS1
function name:  __construct
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        ASSIGN_OBJ                                               'value'
          2        OP_DATA                                                  !0
   15     3      > RETURN                                                   null

End of function __construct

Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VBDS1
function name:  __invoke
number of ops:  8
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        NEW                          static              $1      
          2        FETCH_OBJ_R                                      ~2      'value'
          3        ADD                                              ~3      ~2, !0
          4        SEND_VAL_EX                                              ~3
          5        DO_FCALL                                      0          
          6      > RETURN                                                   $1
   20     7*     > RETURN                                                   null

End of function __invoke

Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VBDS1
function name:  __toString
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   25     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function __tostring

End of class Sum.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.44 ms | 1394 KiB | 14 Q