3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Shape { public function getArea(); } class Rectangle implements Shape { private $width; private $height; public function setWidth($width) { $this->width = $width; } public function setHeight($height) { $this->height = $height; } public function getWidth() { return $this->width; } public function getHeight() { return $height->height; } public function getArea() { return $this->height * $this->width; } } class Cube extends Rectangle { public function setWidth($width) { parent::setWidth($width); parent::setHeight($width); } public function setHeight($height) { parent::setWidth($width); parent::setHeight($width); } } function setWidthAndReturnArea(Rectangle $rectangle, $width) { $rectangle->setWidth($width); return $this->getArea(); } $width = 2; $height = 2; $cube = new Cube(); $cube->setWidth($width); $cube->setHeight($height); $area = setWidthAndReturnArea($cube, $width = 4); if ($area == $width * $height) { echo '$cube gedraagt zich als een Rectangle'; } else { echo '$cube gedraagt zich niet als een Rectangle'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hNtPq
function name:  (null)
number of ops:  26
compiled vars:  !0 = $width, !1 = $height, !2 = $cube, !3 = $area
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'rectangle'
   34     1        DECLARE_CLASS                                            'cube', 'rectangle'
   54     2        ASSIGN                                                   !0, 2
   55     3        ASSIGN                                                   !1, 2
   57     4        NEW                                              $6      'Cube'
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !2, $6
   58     7        INIT_METHOD_CALL                                         !2, 'setWidth'
          8        SEND_VAR_EX                                              !0
          9        DO_FCALL                                      0          
   59    10        INIT_METHOD_CALL                                         !2, 'setHeight'
         11        SEND_VAR_EX                                              !1
         12        DO_FCALL                                      0          
   61    13        INIT_FCALL                                               'setwidthandreturnarea'
         14        SEND_VAR                                                 !2
         15        ASSIGN                                           ~11     !0, 4
         16        SEND_VAL                                                 ~11
         17        DO_FCALL                                      0  $12     
         18        ASSIGN                                                   !3, $12
   63    19        MUL                                              ~14     !0, !1
         20        IS_EQUAL                                                 !3, ~14
         21      > JMPZ                                                     ~15, ->24
   64    22    >   ECHO                                                     '%24cube+gedraagt+zich+als+een+Rectangle'
         23      > JMP                                                      ->25
   66    24    >   ECHO                                                     '%24cube+gedraagt+zich+niet+als+een+Rectangle'
   67    25    > > RETURN                                                   1

Function setwidthandreturnarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hNtPq
function name:  setWidthAndReturnArea
number of ops:  10
compiled vars:  !0 = $rectangle, !1 = $width
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   49     2        INIT_METHOD_CALL                                         !0, 'setWidth'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0          
   51     5        FETCH_THIS                                       $3      
          6        INIT_METHOD_CALL                                         $3, 'getArea'
          7        DO_FCALL                                      0  $4      
          8      > RETURN                                                   $4
   52     9*     > RETURN                                                   null

End of function setwidthandreturnarea

Class Shape:
Function getarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hNtPq
function name:  getArea
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E > > RETURN                                                   null

End of function getarea

End of class Shape.

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

End of function setwidth

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

End of function setheight

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

End of function getwidth

Function getheight:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hNtPq
function name:  getHeight
number of ops:  3
compiled vars:  !0 = $height
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~1      !0, 'height'
          1      > RETURN                                                   ~1
   26     2*     > RETURN                                                   null

End of function getheight

Function getarea:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hNtPq
function name:  getArea
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   FETCH_OBJ_R                                      ~0      'height'
          1        FETCH_OBJ_R                                      ~1      'width'
          2        MUL                                              ~2      ~0, ~1
          3      > RETURN                                                   ~2
   30     4*     > RETURN                                                   null

End of function getarea

End of class Rectangle.

Class Cube:
Function setwidth:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hNtPq
function name:  setWidth
number of ops:  8
compiled vars:  !0 = $width
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
   37     1        INIT_STATIC_METHOD_CALL                                  'setWidth'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
   38     4        INIT_STATIC_METHOD_CALL                                  'setHeight'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
   39     7      > RETURN                                                   null

End of function setwidth

Function setheight:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hNtPq
function name:  setHeight
number of ops:  8
compiled vars:  !0 = $height, !1 = $width
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   RECV                                             !0      
   42     1        INIT_STATIC_METHOD_CALL                                  'setWidth'
          2        SEND_VAR_EX                                              !1
          3        DO_FCALL                                      0          
   43     4        INIT_STATIC_METHOD_CALL                                  'setHeight'
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
   44     7      > RETURN                                                   null

End of function setheight

End of class Cube.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.39 ms | 1407 KiB | 14 Q