3v4l.org

run code in 500+ PHP versions simultaneously
<?php function sum($x) { return new class ($x) { function __construct(private int $x = 0) {} function __invoke($num): static { return new static($num + $this->x); } function __toString(): string { return (string)$this->x; } }; } echo sum(1000)(400)(80)(8)(200)(20)(2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lpCht
function name:  (null)
number of ops:  23
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                                   'sum'
          1        SEND_VAL                                                     1000
          2        DO_FCALL                                          0  $0      
          3        INIT_DYNAMIC_CALL                                            $0
          4        SEND_VAL_EX                                                  400
          5        DO_FCALL                                          0  $1      
          6        INIT_DYNAMIC_CALL                                            $1
          7        SEND_VAL_EX                                                  80
          8        DO_FCALL                                          0  $2      
          9        INIT_DYNAMIC_CALL                                            $2
         10        SEND_VAL_EX                                                  8
         11        DO_FCALL                                          0  $3      
         12        INIT_DYNAMIC_CALL                                            $3
         13        SEND_VAL_EX                                                  200
         14        DO_FCALL                                          0  $4      
         15        INIT_DYNAMIC_CALL                                            $4
         16        SEND_VAL_EX                                                  20
         17        DO_FCALL                                          0  $5      
         18        INIT_DYNAMIC_CALL                                            $5
         19        SEND_VAL_EX                                                  2
         20        DO_FCALL                                          0  $6      
         21        ECHO                                                         $6
         22      > RETURN                                                       1

Function sum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lpCht
function name:  sum
number of ops:  7
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        DECLARE_ANON_CLASS                                   <unknown> 
          2        NEW                                                  $2      $1
          3        SEND_VAR_EX                                                  !0
          4        DO_FCALL                                          0          
          5      > RETURN                                                       $2
   17     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/lpCht
function name:  __construct
number of ops:  4
compiled vars:  !0 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                            !0      0
          1        ASSIGN_OBJ                                                   'x'
          2        OP_DATA                                                      !0
          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/lpCht
function name:  __invoke
number of ops:  10
compiled vars:  !0 = $num
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
    9     1        NEW                              static              $1      
          2        FETCH_OBJ_R                                          ~2      'x'
          3        ADD                                                  ~3      !0, ~2
          4        SEND_VAL_EX                                                  ~3
          5        DO_FCALL                                          0          
          6        VERIFY_RETURN_TYPE                                           $1
          7      > RETURN                                                       $1
   10     8*       VERIFY_RETURN_TYPE                                           
          9*     > 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/lpCht
function name:  __toString
number of ops:  6
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   FETCH_OBJ_R                                          ~0      'x'
          1        CAST                                              6  ~1      ~0
          2        VERIFY_RETURN_TYPE                                           ~1
          3      > RETURN                                                       ~1
   15     4*       VERIFY_RETURN_TYPE                                           
          5*     > RETURN                                                       null

End of function __tostring

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
155.75 ms | 1587 KiB | 14 Q