3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Parcel { protected $weight; protected $destinationCountry; public function setWeight($weight) { echo "the weight is" . $weight; $this->weight = $weight; return $this; } public function setCountry($destinationCountry) { echo "country is " . $destinationCountry; $this->destinationCountry = $destinationCountry; return $this; } } $myParcel = new Parcel(); $myParcel->setWeight(5)->setCountry("India"); class Courier { public function calculateShipping(Parcel $parcel) { $rate = $this->getShippingRateForCountry($parcel->destinationCountry); $cost = $rate * $parcel->weight; return $cost; } public function getShippingRateForCountry() { return 1.2; } } //$myCourier = new Courier(); //$myCourier->calculateShipping
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sBVIW
function name:  (null)
number of ops:  10
compiled vars:  !0 = $myParcel
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $1      'Parcel'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   21     3        INIT_METHOD_CALL                                         !0, 'setWeight'
          4        SEND_VAL_EX                                              5
          5        DO_FCALL                                      0  $4      
          6        INIT_METHOD_CALL                                         $4, 'setCountry'
          7        SEND_VAL_EX                                              'India'
          8        DO_FCALL                                      0          
   37     9      > RETURN                                                   1

Class Parcel:
Function setweight:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sBVIW
function name:  setWeight
number of ops:  8
compiled vars:  !0 = $weight
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        CONCAT                                           ~1      'the+weight+is', !0
          2        ECHO                                                     ~1
    9     3        ASSIGN_OBJ                                               'weight'
          4        OP_DATA                                                  !0
   10     5        FETCH_THIS                                       ~3      
          6      > RETURN                                                   ~3
   11     7*     > RETURN                                                   null

End of function setweight

Function setcountry:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sBVIW
function name:  setCountry
number of ops:  8
compiled vars:  !0 = $destinationCountry
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        CONCAT                                           ~1      'country+is+', !0
          2        ECHO                                                     ~1
   15     3        ASSIGN_OBJ                                               'destinationCountry'
          4        OP_DATA                                                  !0
   16     5        FETCH_THIS                                       ~3      
          6      > RETURN                                                   ~3
   17     7*     > RETURN                                                   null

End of function setcountry

End of class Parcel.

Class Courier:
Function calculateshipping:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sBVIW
function name:  calculateShipping
number of ops:  12
compiled vars:  !0 = $parcel, !1 = $rate, !2 = $cost
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        INIT_METHOD_CALL                                         'getShippingRateForCountry'
          2        CHECK_FUNC_ARG                                           
          3        FETCH_OBJ_FUNC_ARG                               $3      !0, 'destinationCountry'
          4        SEND_FUNC_ARG                                            $3
          5        DO_FCALL                                      0  $4      
          6        ASSIGN                                                   !1, $4
   27     7        FETCH_OBJ_R                                      ~6      !0, 'weight'
          8        MUL                                              ~7      !1, ~6
          9        ASSIGN                                                   !2, ~7
   28    10      > RETURN                                                   !2
   29    11*     > RETURN                                                   null

End of function calculateshipping

Function getshippingrateforcountry:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sBVIW
function name:  getShippingRateForCountry
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E > > RETURN                                                   1.2
   33     1*     > RETURN                                                   null

End of function getshippingrateforcountry

End of class Courier.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.06 ms | 1403 KiB | 13 Q