3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Point { private $x; private $y; function __construct($x, $y) { $this->x = $x; $this->y = $y; } public function getX() { return $this->x; } public function getY() { return $this->y; } public function distanceFrom(Point $point) { return sqrt( pow($this->getX() - $point->getX(), 2) + pow($this->getY() - $point->getY(), 2) ); } } class Circle { private $center; private $radius; function __construct(Point $center, $radius) { $this->center = $center; $this->radius = $radius; } public function getCenter() { return $this->center; } public function getRadius() { return $this->radius; } public function contains(Point $point) { return $this->center->distanceFrom($point) <= $this->radius; } } $point = new Point(3, 4); $circle = new Circle(new Point(0,0), 2); var_dump($circle->contains($point));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PheV9
function name:  (null)
number of ops:  21
compiled vars:  !0 = $point, !1 = $circle
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   NEW                                              $2      'Point'
          1        SEND_VAL_EX                                              3
          2        SEND_VAL_EX                                              4
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   54     5        NEW                                              $5      'Circle'
          6        NEW                                              $6      'Point'
          7        SEND_VAL_EX                                              0
          8        SEND_VAL_EX                                              0
          9        DO_FCALL                                      0          
         10        SEND_VAR_NO_REF_EX                                       $6
         11        SEND_VAL_EX                                              2
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !1, $5
   56    14        INIT_FCALL                                               'var_dump'
         15        INIT_METHOD_CALL                                         !1, 'contains'
         16        SEND_VAR_EX                                              !0
         17        DO_FCALL                                      0  $10     
         18        SEND_VAR                                                 $10
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

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

End of function __construct

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

End of function getx

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

End of function gety

Function distancefrom:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PheV9
function name:  distanceFrom
number of ops:  25
compiled vars:  !0 = $point
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'sqrt'
   23     2        INIT_FCALL                                               'pow'
          3        INIT_METHOD_CALL                                         'getX'
          4        DO_FCALL                                      0  $1      
          5        INIT_METHOD_CALL                                         !0, 'getX'
          6        DO_FCALL                                      0  $2      
          7        SUB                                              ~3      $1, $2
          8        SEND_VAL                                                 ~3
          9        SEND_VAL                                                 2
         10        DO_ICALL                                         $4      
   24    11        INIT_FCALL                                               'pow'
         12        INIT_METHOD_CALL                                         'getY'
         13        DO_FCALL                                      0  $5      
         14        INIT_METHOD_CALL                                         !0, 'getY'
         15        DO_FCALL                                      0  $6      
         16        SUB                                              ~7      $5, $6
         17        SEND_VAL                                                 ~7
         18        SEND_VAL                                                 2
         19        DO_ICALL                                         $8      
         20        ADD                                              ~9      $4, $8
         21        SEND_VAL                                                 ~9
   22    22        DO_ICALL                                         $10     
   24    23      > RETURN                                                   $10
   26    24*     > RETURN                                                   null

End of function distancefrom

End of class Point.

Class Circle:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PheV9
function name:  __construct
number of ops:  7
compiled vars:  !0 = $center, !1 = $radius
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   36     2        ASSIGN_OBJ                                               'center'
          3        OP_DATA                                                  !0
   37     4        ASSIGN_OBJ                                               'radius'
          5        OP_DATA                                                  !1
   38     6      > RETURN                                                   null

End of function __construct

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

End of function getcenter

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

End of function getradius

Function contains:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PheV9
function name:  contains
number of ops:  9
compiled vars:  !0 = $point
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
   49     1        FETCH_OBJ_R                                      ~1      'center'
          2        INIT_METHOD_CALL                                         ~1, 'distanceFrom'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5        FETCH_OBJ_R                                      ~3      'radius'
          6        IS_SMALLER_OR_EQUAL                              ~4      $2, ~3
          7      > RETURN                                                   ~4
   50     8*     > RETURN                                                   null

End of function contains

End of class Circle.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.9 ms | 1021 KiB | 16 Q