3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C{ protected $date; public function __construct(){ $this->date=new DateTime(); } public function getCurrent(){ return clone $date; } } class A extends C{ public function getDate(){ return $this->getCurrent()->add(new DateInterval('P10D')); } public function getDateAgain(){ return $this->getCurrent()->add(new DateInterval('P10D')); } } class B extends C{ public function getDate(){ return $this->getCurrent()->add(new DateInterval('P20D')); } } $a=new A(); $b=new B(); echo $a->getDate()->format('Y-m-d') . "\n"; echo $b->getDate()->format('Y-m-d') . "\n"; echo $a->getDateAgain()->format('Y-m-d') . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  (null)
number of ops:  28
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $2      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   29     3        NEW                                              $5      'B'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   30     6        INIT_METHOD_CALL                                         !0, 'getDate'
          7        DO_FCALL                                      0  $8      
          8        INIT_METHOD_CALL                                         $8, 'format'
          9        SEND_VAL_EX                                              'Y-m-d'
         10        DO_FCALL                                      0  $9      
         11        CONCAT                                           ~10     $9, '%0A'
         12        ECHO                                                     ~10
   31    13        INIT_METHOD_CALL                                         !1, 'getDate'
         14        DO_FCALL                                      0  $11     
         15        INIT_METHOD_CALL                                         $11, 'format'
         16        SEND_VAL_EX                                              'Y-m-d'
         17        DO_FCALL                                      0  $12     
         18        CONCAT                                           ~13     $12, '%0A'
         19        ECHO                                                     ~13
   32    20        INIT_METHOD_CALL                                         !0, 'getDateAgain'
         21        DO_FCALL                                      0  $14     
         22        INIT_METHOD_CALL                                         $14, 'format'
         23        SEND_VAL_EX                                              'Y-m-d'
         24        DO_FCALL                                      0  $15     
         25        CONCAT                                           ~16     $15, '%0A'
         26        ECHO                                                     ~16
         27      > RETURN                                                   1

Class C:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   NEW                                              $1      'DateTime'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'date'
          3        OP_DATA                                                  $1
    9     4      > RETURN                                                   null

End of function __construct

Function getcurrent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  getCurrent
number of ops:  3
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   CLONE                                            ~1      !0
          1      > RETURN                                                   ~1
   12     2*     > RETURN                                                   null

End of function getcurrent

End of class C.

Class A:
Function getdate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  getDate
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   INIT_METHOD_CALL                                         'getCurrent'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'add'
          3        NEW                                              $1      'DateInterval'
          4        SEND_VAL_EX                                              'P10D'
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $1
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   17     9*     > RETURN                                                   null

End of function getdate

Function getdateagain:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  getDateAgain
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_METHOD_CALL                                         'getCurrent'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'add'
          3        NEW                                              $1      'DateInterval'
          4        SEND_VAL_EX                                              'P10D'
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $1
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   20     9*     > RETURN                                                   null

End of function getdateagain

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   NEW                                              $1      'DateTime'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'date'
          3        OP_DATA                                                  $1
    9     4      > RETURN                                                   null

End of function __construct

Function getcurrent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  getCurrent
number of ops:  3
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   CLONE                                            ~1      !0
          1      > RETURN                                                   ~1
   12     2*     > RETURN                                                   null

End of function getcurrent

End of class A.

Class B:
Function getdate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  getDate
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_METHOD_CALL                                         'getCurrent'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'add'
          3        NEW                                              $1      'DateInterval'
          4        SEND_VAL_EX                                              'P20D'
          5        DO_FCALL                                      0          
          6        SEND_VAR_NO_REF_EX                                       $1
          7        DO_FCALL                                      0  $3      
          8      > RETURN                                                   $3
   25     9*     > RETURN                                                   null

End of function getdate

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   NEW                                              $1      'DateTime'
          1        DO_FCALL                                      0          
          2        ASSIGN_OBJ                                               'date'
          3        OP_DATA                                                  $1
    9     4      > RETURN                                                   null

End of function __construct

Function getcurrent:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MYNp6
function name:  getCurrent
number of ops:  3
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   CLONE                                            ~1      !0
          1      > RETURN                                                   ~1
   12     2*     > RETURN                                                   null

End of function getcurrent

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.95 ms | 1403 KiB | 13 Q