3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sum($a) { return new class($a) { protected $value; public function __construct($value) { $this->value = $value; } public function __invoke($a) { return new static($this->value + $a); } public function __toString() { return (string) $this->value; } }; } echo sum(1)(2)(3)(4)(5); // 15 echo sum(10)(10)(10); // 30 echo sum(-1)(-2)(3)(-3)(2)(1); // 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TmBPo
function name:  (null)
number of ops:  46
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'sum'
          1        SEND_VAL                                                 1
          2        DO_FCALL                                      0  $0      
          3        INIT_DYNAMIC_CALL                                        $0
          4        SEND_VAL_EX                                              2
          5        DO_FCALL                                      0  $1      
          6        INIT_DYNAMIC_CALL                                        $1
          7        SEND_VAL_EX                                              3
          8        DO_FCALL                                      0  $2      
          9        INIT_DYNAMIC_CALL                                        $2
         10        SEND_VAL_EX                                              4
         11        DO_FCALL                                      0  $3      
         12        INIT_DYNAMIC_CALL                                        $3
         13        SEND_VAL_EX                                              5
         14        DO_FCALL                                      0  $4      
         15        ECHO                                                     $4
   26    16        INIT_FCALL                                               'sum'
         17        SEND_VAL                                                 10
         18        DO_FCALL                                      0  $5      
         19        INIT_DYNAMIC_CALL                                        $5
         20        SEND_VAL_EX                                              10
         21        DO_FCALL                                      0  $6      
         22        INIT_DYNAMIC_CALL                                        $6
         23        SEND_VAL_EX                                              10
         24        DO_FCALL                                      0  $7      
         25        ECHO                                                     $7
   27    26        INIT_FCALL                                               'sum'
         27        SEND_VAL                                                 -1
         28        DO_FCALL                                      0  $8      
         29        INIT_DYNAMIC_CALL                                        $8
         30        SEND_VAL_EX                                              -2
         31        DO_FCALL                                      0  $9      
         32        INIT_DYNAMIC_CALL                                        $9
         33        SEND_VAL_EX                                              3
         34        DO_FCALL                                      0  $10     
         35        INIT_DYNAMIC_CALL                                        $10
         36        SEND_VAL_EX                                              -3
         37        DO_FCALL                                      0  $11     
         38        INIT_DYNAMIC_CALL                                        $11
         39        SEND_VAL_EX                                              2
         40        DO_FCALL                                      0  $12     
         41        INIT_DYNAMIC_CALL                                        $12
         42        SEND_VAL_EX                                              1
         43        DO_FCALL                                      0  $13     
         44        ECHO                                                     $13
         45      > RETURN                                                   1

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

End of function sum

Class class@anonymous:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TmBPo
function name:  __construct
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        ASSIGN_OBJ                                               'value'
          2        OP_DATA                                                  !0
   11     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/TmBPo
function name:  __invoke
number of ops:  8
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     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
   16     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/TmBPo
function name:  __toString
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   FETCH_OBJ_R                                      ~0      'value'
          1        CAST                                          6  ~1      ~0
          2        VERIFY_RETURN_TYPE                                       ~1
          3      > RETURN                                                   ~1
   21     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function __tostring

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.55 ms | 1403 KiB | 16 Q