3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Entity { private Decimal $subtotal; public function getSubtotal() { return $this->subtotal; } public function setSubtotal(Decimal $value) { $this->subtotal = $value; return $this; } } class Decimal { private string $value; public function __construct(string $value) { $this->value = $value; } public function getValue() { return $this->value; } public function toFixed(int $scale): Decimal { // rough example for adjusting precision - do not use return new self(bcadd($this->value, '0', $scale)); } } //////////////// $entity = new Entity(); $entity->setSubtotal((new Decimal('1337.987654321'))->toFixed(4)); echo $entity->getSubtotal()->getValue();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3DN9G
function name:  (null)
number of ops:  18
compiled vars:  !0 = $entity
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   45     0  E >   NEW                                                  $1      'Entity'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
   46     3        INIT_METHOD_CALL                                             !0, 'setSubtotal'
          4        NEW                                                  $4      'Decimal'
          5        SEND_VAL_EX                                                  '1337.987654321'
          6        DO_FCALL                                          0          
          7        INIT_METHOD_CALL                                             $4, 'toFixed'
          8        SEND_VAL_EX                                                  4
          9        DO_FCALL                                          0  $6      
         10        SEND_VAR_NO_REF_EX                                           $6
         11        DO_FCALL                                          0          
   48    12        INIT_METHOD_CALL                                             !0, 'getSubtotal'
         13        DO_FCALL                                          0  $8      
         14        INIT_METHOD_CALL                                             $8, 'getValue'
         15        DO_FCALL                                          0  $9      
         16        ECHO                                                         $9
         17      > RETURN                                                       1

Class Entity:
Function getsubtotal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3DN9G
function name:  getSubtotal
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                          ~0      'subtotal'
          1      > RETURN                                                       ~0
   12     2*     > RETURN                                                       null

End of function getsubtotal

Function setsubtotal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3DN9G
function name:  setSubtotal
number of ops:  6
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
   16     1        ASSIGN_OBJ                                                   'subtotal'
          2        OP_DATA                                                      !0
   18     3        FETCH_THIS                                           ~2      
          4      > RETURN                                                       ~2
   19     5*     > RETURN                                                       null

End of function setsubtotal

End of class Entity.

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

End of function __construct

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

End of function getvalue

Function tofixed:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3DN9G
function name:  toFixed
number of ops:  15
compiled vars:  !0 = $scale
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   36     0  E >   RECV                                                 !0      
   39     1        NEW                              self                $1      
          2        INIT_FCALL_BY_NAME                                           'bcadd'
          3        CHECK_FUNC_ARG                                               
          4        FETCH_OBJ_FUNC_ARG                                   $2      'value'
          5        SEND_FUNC_ARG                                                $2
          6        SEND_VAL_EX                                                  '0'
          7        SEND_VAR_EX                                                  !0
          8        DO_FCALL                                          0  $3      
          9        SEND_VAR_NO_REF_EX                                           $3
         10        DO_FCALL                                          0          
         11        VERIFY_RETURN_TYPE                                           $1
         12      > RETURN                                                       $1
   40    13*       VERIFY_RETURN_TYPE                                           
         14*     > RETURN                                                       null

End of function tofixed

End of class Decimal.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.14 ms | 1882 KiB | 13 Q