3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Currency { public $currencyCode; public function __construct($currencyCode) { $this->currencyCode = $currencyCode; } public function equals(Currency $currency) { return $this->currencyCode === $currency->currencyCode; } } class Money { public $amount; public $currency; public function __construct($amount, Currency $currency = null) { $this->currency = $currency ?: new Currency('USD'); } } $revenue = new Money(55, new Currency('GBP')); var_dump($revenue->currency->equals(new Currency('GBP'))); $assets = new Money(55); var_dump($revenue->currency->equals(new Currency('USD')));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Hc0ok
function name:  (null)
number of ops:  33
compiled vars:  !0 = $revenue, !1 = $assets
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   NEW                                              $2      'Money'
          1        SEND_VAL_EX                                              55
          2        NEW                                              $3      'Currency'
          3        SEND_VAL_EX                                              'GBP'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $3
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !0, $2
   31     8        INIT_FCALL                                               'var_dump'
          9        FETCH_OBJ_R                                      ~7      !0, 'currency'
         10        INIT_METHOD_CALL                                         ~7, 'equals'
         11        NEW                                              $8      'Currency'
         12        SEND_VAL_EX                                              'GBP'
         13        DO_FCALL                                      0          
         14        SEND_VAR_NO_REF_EX                                       $8
         15        DO_FCALL                                      0  $10     
         16        SEND_VAR                                                 $10
         17        DO_ICALL                                                 
   33    18        NEW                                              $12     'Money'
         19        SEND_VAL_EX                                              55
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !1, $12
   35    22        INIT_FCALL                                               'var_dump'
         23        FETCH_OBJ_R                                      ~15     !0, 'currency'
         24        INIT_METHOD_CALL                                         ~15, 'equals'
         25        NEW                                              $16     'Currency'
         26        SEND_VAL_EX                                              'USD'
         27        DO_FCALL                                      0          
         28        SEND_VAR_NO_REF_EX                                       $16
         29        DO_FCALL                                      0  $18     
         30        SEND_VAR                                                 $18
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

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

End of function __construct

Function equals:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Hc0ok
function name:  equals
number of ops:  6
compiled vars:  !0 = $currency
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'currencyCode'
          2        FETCH_OBJ_R                                      ~2      !0, 'currencyCode'
          3        IS_IDENTICAL                                     ~3      ~1, ~2
          4      > RETURN                                                   ~3
   15     5*     > RETURN                                                   null

End of function equals

End of class Currency.

Class Money:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Hc0ok
function name:  __construct
number of ops:  10
compiled vars:  !0 = $amount, !1 = $currency
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   25     2        JMP_SET                                          ~3      !1, ->7
          3        NEW                                              $4      'Currency'
          4        SEND_VAL_EX                                              'USD'
          5        DO_FCALL                                      0          
          6        QM_ASSIGN                                        ~3      $4
          7        ASSIGN_OBJ                                               'currency'
          8        OP_DATA                                                  ~3
   26     9      > RETURN                                                   null

End of function __construct

End of class Money.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.48 ms | 1400 KiB | 15 Q