3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Entity { #[ORM\Column(type: 'decimal', precision: 10, scale: 4)] private Decimal $subtotal; public function getSubtotal() { return $this->subtotal; } public function setSubtotal(Decimal $value) { $this->subtotal = $value->toFixed(4); return $this; } } class Decimal { private string $value = '0.0'; public function __construct(string $value) { $this->value = $value; } public function getValue(): string { 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')); echo $entity->getSubtotal()->getValue();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b56uQ
function name:  (null)
number of ops:  15
compiled vars:  !0 = $entity
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   44     0  E >   NEW                                                  $1      'Entity'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
   45     3        INIT_METHOD_CALL                                             !0, 'setSubtotal'
          4        NEW                                                  $4      'Decimal'
          5        SEND_VAL_EX                                                  '1337.987654321'
          6        DO_FCALL                                          0          
          7        SEND_VAR_NO_REF_EX                                           $4
          8        DO_FCALL                                          0          
   47     9        INIT_METHOD_CALL                                             !0, 'getSubtotal'
         10        DO_FCALL                                          0  $7      
         11        INIT_METHOD_CALL                                             $7, 'getValue'
         12        DO_FCALL                                          0  $8      
         13        ECHO                                                         $8
         14      > RETURN                                                       1

Class Entity:
Function getsubtotal:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/b56uQ
function name:  getSubtotal
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   FETCH_OBJ_R                                          ~0      'subtotal'
          1      > RETURN                                                       ~0
   11     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/b56uQ
function name:  setSubtotal
number of ops:  9
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   RECV                                                 !0      
   15     1        INIT_METHOD_CALL                                             !0, 'toFixed'
          2        SEND_VAL_EX                                                  4
          3        DO_FCALL                                          0  $2      
          4        ASSIGN_OBJ                                                   'subtotal'
          5        OP_DATA                                                      $2
   17     6        FETCH_THIS                                           ~3      
          7      > RETURN                                                       ~3
   18     8*     > 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/b56uQ
function name:  __construct
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   RECV                                                 !0      
   27     1        ASSIGN_OBJ                                                   'value'
          2        OP_DATA                                                      !0
   28     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/b56uQ
function name:  getValue
number of ops:  5
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   32     0  E >   FETCH_OBJ_R                                          ~0      'value'
          1        VERIFY_RETURN_TYPE                                           ~0
          2      > RETURN                                                       ~0
   33     3*       VERIFY_RETURN_TYPE                                           
          4*     > 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/b56uQ
function name:  toFixed
number of ops:  15
compiled vars:  !0 = $scale
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   35     0  E >   RECV                                                 !0      
   38     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
   39    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:
167.59 ms | 1879 KiB | 13 Q