3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Why is this allowed ? class MyDateTimeImmutable extends DateTimeImmutable implements DateTimeInterface { public function format(string $format): string { return 'Why is this allowed?'; } } // And why is this disallowed ? // Fatal error: DateTimeInterface can't be implemented by user classes class MyTime implements DateTimeInterface { }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AVYra
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    4     0  E >   DECLARE_CLASS                                                'mydatetimeimmutable', 'datetimeimmutable'
   14     1        DECLARE_CLASS                                                'mytime'
   16     2      > RETURN                                                       1

Class MyDateTimeImmutable:
Function format:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AVYra
function name:  format
number of ops:  4
compiled vars:  !0 = $format
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
    8     1      > RETURN                                                       'Why+is+this+allowed%3F'
    9     2*       VERIFY_RETURN_TYPE                                           
          3*     > RETURN                                                       null

End of function format

End of class MyDateTimeImmutable.

Class MyTime: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
150.93 ms | 480 KiB | 8 Q