File: bug65768.phpt

package info (click to toggle)
php5 5.6.33%2Bdfsg-0%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 157,872 kB
  • sloc: ansic: 756,065; php: 22,030; sh: 12,311; cpp: 8,771; xml: 6,179; yacc: 1,564; exp: 1,514; makefile: 1,467; pascal: 1,147; awk: 538; perl: 315; sql: 22
file content (36 lines) | stat: -rw-r--r-- 1,023 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--TEST--
Bug #65768: date_diff accepts only DateTime instance even though docs say about DateTimeInterface
--INI--
date.timezone=Europe/London
--FILE--
<?php

$dt1 = new DateTime("2010-10-20");
$dti1 = new DateTimeImmutable("2010-10-25");
$dti2 = new DateTimeImmutable("2010-10-28");

$diff1 = $dt1->diff($dti1);
echo $diff1->y, " ", $diff1->m, " ", $diff1->d, " ",
     $diff1->h, " ", $diff1->i, " ", $diff1->s, "\n";

$diff2 = $dti1->diff($dti2);
echo $diff2->y, " ", $diff2->m, " ", $diff2->d, " ",
     $diff2->h, " ", $diff2->i, " ", $diff2->s, "\n";

$diff3 = date_diff($dt1, $dti2);
echo $diff3->y, " ", $diff3->m, " ", $diff3->d, " ",
     $diff3->h, " ", $diff3->i, " ", $diff3->s, "\n";

class cdt1 extends DateTime implements DateTimeInterface {}

class cdt2 extends DateTimeImmutable implements DateTimeInterface {}

class cdt3 implements DateTimeInterface {}

?>
--EXPECTF--
0 0 5 0 0 0
0 0 3 0 0 0
0 0 8 0 0 0

Fatal error: DateTimeInterface can't be implemented by user classes in %sbug65768.php on line %d