3v4l.org

run code in 300+ PHP versions simultaneously
<?php # Model class Car { private $name = null; private $description = null; private $price = 0; public function __construct($name, $price, $description = null) { $this->name = $name; $this->description = $description; $this->price = $price; } public function setName($name) {$this->name = $name;} public function getName() {return $this->name; } public function setDescription($description) {$this->description = $description; } public function getDescription() {return $this->description; } public function setPrice($price) {$this->price = $price;} public function getPrice() {return $this->price;} } # Presenter class CarPresenter { private $car; public function __construct($car) { $this->car = $car; } public function __call($method, $params = array()) { #if(method_exists($this, $method)) { # call_user_func_array(array($this, $method), $params); #} else if(method_exists($this->car, $method)) { return call_user_func_array(array($this->car, $method), $params); } } public function isExpesive() { return $this->car->getPrice() > 45000; } public function getDescription() { $description = $this->car->getDescription(); return is_null($description) ? 'No description' : $description; } } $car = new Car('Ferrari', 2000000); $car_presenter = new CarPresenter($car); echo $car_presenter->getName(); echo $car_presenter->isExpensive(); echo $car_presenter->getDescription();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1RsY
function name:  (null)
number of ops:  19
compiled vars:  !0 = $car, !1 = $car_presenter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   NEW                                              $2      'Car'
          1        SEND_VAL_EX                                              'Ferrari'
          2        SEND_VAL_EX                                              2000000
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   52     5        NEW                                              $5      'CarPresenter'
          6        SEND_VAR_EX                                              !0
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $5
   54     9        INIT_METHOD_CALL                                         !1, 'getName'
         10        DO_FCALL                                      0  $8      
         11        ECHO                                                     $8
   55    12        INIT_METHOD_CALL                                         !1, 'isExpensive'
         13        DO_FCALL                                      0  $9      
         14        ECHO                                                     $9
   56    15        INIT_METHOD_CALL                                         !1, 'getDescription'
         16        DO_FCALL                                      0  $10     
         17        ECHO                                                     $10
         18      > RETURN                                                   1

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

End of function __construct

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

End of function setname

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

End of function getname

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

End of function setdescription

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

End of function getdescription

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

End of function setprice

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

End of function getprice

End of class Car.

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

End of function __construct

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 16
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1RsY
function name:  __call
number of ops:  17
compiled vars:  !0 = $method, !1 = $params
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   35     2        INIT_FCALL                                               'method_exists'
          3        FETCH_OBJ_R                                      ~2      'car'
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $3      
          7      > JMPZ                                                     $3, ->16
   36     8    >   FETCH_OBJ_R                                      ~4      'car'
          9        INIT_ARRAY                                       ~5      ~4
         10        ADD_ARRAY_ELEMENT                                ~5      !0
         11        INIT_USER_CALL                                0          'call_user_func_array', ~5
         12        SEND_ARRAY                                               !1
         13        CHECK_UNDEF_ARGS                                         
         14        DO_FCALL                                      0  $6      
         15      > RETURN                                                   $6
   38    16    > > RETURN                                                   null

End of function __call

Function isexpesive:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1RsY
function name:  isExpesive
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   FETCH_OBJ_R                                      ~0      'car'
          1        INIT_METHOD_CALL                                         ~0, 'getPrice'
          2        DO_FCALL                                      0  $1      
          3        IS_SMALLER                                       ~2      45000, $1
          4      > RETURN                                                   ~2
   42     5*     > RETURN                                                   null

End of function isexpesive

Function getdescription:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/r1RsY
function name:  getDescription
number of ops:  11
compiled vars:  !0 = $description
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   FETCH_OBJ_R                                      ~1      'car'
          1        INIT_METHOD_CALL                                         ~1, 'getDescription'
          2        DO_FCALL                                      0  $2      
          3        ASSIGN                                                   !0, $2
   47     4        TYPE_CHECK                                    2          !0
          5      > JMPZ                                                     ~4, ->8
          6    >   QM_ASSIGN                                        ~5      'No+description'
          7      > JMP                                                      ->9
          8    >   QM_ASSIGN                                        ~5      !0
          9    > > RETURN                                                   ~5
   48    10*     > RETURN                                                   null

End of function getdescription

End of class CarPresenter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.06 ms | 1408 KiB | 15 Q