3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Shape { public function __construct() {} abstract public function area(); abstract public function sides(); public function info() { return "This ".get_class($this)." has ".$this->sides()." sides and an area of ".$this->area()."\n"; } } class Square extends Shape { public function __construct($s) { parent::__construct(); $this->width = $s; } public function area() { return $this->width * $this-width; } public function sides() { return 4; } } class Rectangle extends Square { public function __construct($w,$h) { parent::__construct($w); $this->height = $h; } public function area() { return $this->width * $this->height; } } class Circle extends Shape { public function __construct($r) { parent::__construct(); $this->radius = $r; } public function area() { return $this->radius * $this->radius * M_PI; } public function sides() { return 1; } } $s = new Rectangle(3,15); print($s->info()); $c = new Circle(3); print($c->info()); $q = new Square(3); print($q->info()); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  (null)
number of ops:  23
compiled vars:  !0 = $s, !1 = $c, !2 = $q
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   NEW                                              $3      'Rectangle'
          1        SEND_VAL_EX                                              3
          2        SEND_VAL_EX                                              15
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   67     5        INIT_METHOD_CALL                                         !0, 'info'
          6        DO_FCALL                                      0  $6      
          7        ECHO                                                     $6
   69     8        NEW                                              $7      'Circle'
          9        SEND_VAL_EX                                              3
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !1, $7
   70    12        INIT_METHOD_CALL                                         !1, 'info'
         13        DO_FCALL                                      0  $10     
         14        ECHO                                                     $10
   72    15        NEW                                              $11     'Square'
         16        SEND_VAL_EX                                              3
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !2, $11
   73    19        INIT_METHOD_CALL                                         !2, 'info'
         20        DO_FCALL                                      0  $14     
         21        ECHO                                                     $14
   75    22      > RETURN                                                   1

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

End of function __construct

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

End of function area

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

End of function sides

Function info:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  info
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        CONCAT                                           ~2      'This+', ~1
          3        CONCAT                                           ~3      ~2, '+has+'
          4        INIT_METHOD_CALL                                         'sides'
          5        DO_FCALL                                      0  $4      
          6        CONCAT                                           ~5      ~3, $4
          7        CONCAT                                           ~6      ~5, '+sides+and+an+area+of+'
          8        INIT_METHOD_CALL                                         'area'
          9        DO_FCALL                                      0  $7      
         10        CONCAT                                           ~8      ~6, $7
         11        CONCAT                                           ~9      ~8, '%0A'
         12      > RETURN                                                   ~9
   13    13*     > RETURN                                                   null

End of function info

End of class Shape.

Class Square:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  __construct
number of ops:  6
compiled vars:  !0 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_STATIC_METHOD_CALL                                  
          2        DO_FCALL                                      0          
   21     3        ASSIGN_OBJ                                               'width'
          4        OP_DATA                                                  !0
   22     5      > RETURN                                                   null

End of function __construct

Function area:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  area
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   FETCH_OBJ_R                                      ~0      'width'
          1        FETCH_THIS                                       ~1      
          2        MUL                                              ~2      ~0, ~1
          3        FETCH_CONSTANT                                   ~3      'width'
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
   27     6*     > RETURN                                                   null

End of function area

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

End of function sides

Function info:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  info
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        CONCAT                                           ~2      'This+', ~1
          3        CONCAT                                           ~3      ~2, '+has+'
          4        INIT_METHOD_CALL                                         'sides'
          5        DO_FCALL                                      0  $4      
          6        CONCAT                                           ~5      ~3, $4
          7        CONCAT                                           ~6      ~5, '+sides+and+an+area+of+'
          8        INIT_METHOD_CALL                                         'area'
          9        DO_FCALL                                      0  $7      
         10        CONCAT                                           ~8      ~6, $7
         11        CONCAT                                           ~9      ~8, '%0A'
         12      > RETURN                                                   ~9
   13    13*     > RETURN                                                   null

End of function info

End of class Square.

Class Rectangle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  __construct
number of ops:  8
compiled vars:  !0 = $w, !1 = $h
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   39     2        INIT_STATIC_METHOD_CALL                                  
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   40     5        ASSIGN_OBJ                                               'height'
          6        OP_DATA                                                  !1
   41     7      > RETURN                                                   null

End of function __construct

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

End of function area

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

End of function sides

Function info:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  info
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        CONCAT                                           ~2      'This+', ~1
          3        CONCAT                                           ~3      ~2, '+has+'
          4        INIT_METHOD_CALL                                         'sides'
          5        DO_FCALL                                      0  $4      
          6        CONCAT                                           ~5      ~3, $4
          7        CONCAT                                           ~6      ~5, '+sides+and+an+area+of+'
          8        INIT_METHOD_CALL                                         'area'
          9        DO_FCALL                                      0  $7      
         10        CONCAT                                           ~8      ~6, $7
         11        CONCAT                                           ~9      ~8, '%0A'
         12      > RETURN                                                   ~9
   13    13*     > RETURN                                                   null

End of function info

End of class Rectangle.

Class Circle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  __construct
number of ops:  6
compiled vars:  !0 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
   53     1        INIT_STATIC_METHOD_CALL                                  
          2        DO_FCALL                                      0          
   54     3        ASSIGN_OBJ                                               'radius'
          4        OP_DATA                                                  !0
   55     5      > RETURN                                                   null

End of function __construct

Function area:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  area
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   FETCH_OBJ_R                                      ~0      'radius'
          1        FETCH_OBJ_R                                      ~1      'radius'
          2        MUL                                              ~2      ~0, ~1
          3        MUL                                              ~3      ~2, 3.14159
          4      > RETURN                                                   ~3
   60     5*     > RETURN                                                   null

End of function area

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

End of function sides

Function info:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D51ZQ
function name:  info
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   FETCH_THIS                                       ~0      
          1        GET_CLASS                                        ~1      ~0
          2        CONCAT                                           ~2      'This+', ~1
          3        CONCAT                                           ~3      ~2, '+has+'
          4        INIT_METHOD_CALL                                         'sides'
          5        DO_FCALL                                      0  $4      
          6        CONCAT                                           ~5      ~3, $4
          7        CONCAT                                           ~6      ~5, '+sides+and+an+area+of+'
          8        INIT_METHOD_CALL                                         'area'
          9        DO_FCALL                                      0  $7      
         10        CONCAT                                           ~8      ~6, $7
         11        CONCAT                                           ~9      ~8, '%0A'
         12      > RETURN                                                   ~9
   13    13*     > RETURN                                                   null

End of function info

End of class Circle.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.89 ms | 1411 KiB | 13 Q