Skip to content

Commit d59fc0a

Browse files
committed
Deprecate strftime() and gmstrftime()
These are deprecated in favor of date()/DateTime::format() (for locale-indendent formatting) and IntlDateFormatter::format() (for locale-dependent formatting). Part of https://wiki.php.net/rfc/deprecations_php_8_1.
1 parent aa733e8 commit d59fc0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+481
-35
lines changed

ext/date/php_date.stub.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ function gmmktime(
2020

2121
function checkdate(int $month, int $day, int $year): bool {}
2222

23+
/** @deprecated */
2324
function strftime(string $format, ?int $timestamp = null): string|false {}
2425

26+
/** @deprecated */
2527
function gmstrftime(string $format, ?int $timestamp = null): string|false {}
2628

2729
function time(): int {}

ext/date/php_date_arginfo.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: fbec11a67d5cc04667a012f25894f0d9e18833a6 */
2+
* Stub hash: bc0634c149cda640616f7ecd7e173a0d6497a911 */
33

44
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtotime, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
55
ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0)
@@ -559,8 +559,8 @@ static const zend_function_entry ext_functions[] = {
559559
ZEND_FE(mktime, arginfo_mktime)
560560
ZEND_FE(gmmktime, arginfo_gmmktime)
561561
ZEND_FE(checkdate, arginfo_checkdate)
562-
ZEND_FE(strftime, arginfo_strftime)
563-
ZEND_FE(gmstrftime, arginfo_gmstrftime)
562+
ZEND_DEP_FE(strftime, arginfo_strftime)
563+
ZEND_DEP_FE(gmstrftime, arginfo_gmstrftime)
564564
ZEND_FE(time, arginfo_time)
565565
ZEND_FE(localtime, arginfo_localtime)
566566
ZEND_FE(getdate, arginfo_getdate)

ext/date/tests/009.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,29 @@ var_dump(gmstrftime("blah", $t));
2323
echo "Done\n";
2424
?>
2525
--EXPECTF--
26+
Deprecated: Function strftime() is deprecated in %s on line %d
2627
bool(false)
28+
29+
Deprecated: Function strftime() is deprecated in %s on line %d
2730
string(%d) "Tue Tuesday Jun June Tue Jun 27 00:00:00 2006 %s
2831
%s %"
32+
33+
Deprecated: Function strftime() is deprecated in %s on line %d
2934
string(5) "%q %a"
35+
36+
Deprecated: Function strftime() is deprecated in %s on line %d
3037
string(4) "blah"
38+
39+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3140
bool(false)
41+
42+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3243
string(%d) "Mon Monday Jun June Mon Jun 26 21:00:00 2006 %s
3344
%s %"
45+
46+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3447
string(5) "%q %a"
48+
49+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3550
string(4) "blah"
3651
Done

ext/date/tests/009_win32.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,27 @@ echo "Done\n";
3535
setlocale(LC_TIME, $loc);
3636
?>
3737
--EXPECTF--
38+
Deprecated: Function strftime() is deprecated in %s on line %d
3839
bool(false)
40+
41+
Deprecated: Function strftime() is deprecated in %s on line %d
3942
string(%d) "Tue Tuesday Jun June 6/27/2006 12:00:00 AM 27 00 12 178 06 00 AM 00 26 26 2 6/27/2006 12:00:00 AM 06 2006 %s"
43+
44+
Deprecated: Function strftime() is deprecated in %s on line %d
4045
string(5) "%q %a"
46+
47+
Deprecated: Function strftime() is deprecated in %s on line %d
4148
string(4) "blah"
49+
50+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4251
bool(false)
52+
53+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4354
string(%d) "Mon Monday Jun June 6/26/2006 9:00:00 PM 26 21 09 177 06 00 PM 00 26 26 1 6/26/2006 9:00:00 PM 06 2006 %s"
55+
56+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4457
string(5) "%q %a"
58+
59+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4560
string(4) "blah"
4661
Done

ext/date/tests/bug33532.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ date.timezone=UTC
66
--SKIPIF--
77
<?php
88
if(PHP_OS == 'Darwin' || defined('PHP_WINDOWS_VERSION_MAJOR')) die("skip strftime uses system TZ on Darwin and Windows");
9-
if (!strftime('%Z')) die('skip strftime does not support %Z');
9+
if (!@strftime('%Z')) die('skip strftime does not support %Z');
1010
?>
1111
--FILE--
1212
<?php

ext/date/tests/bug65184.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
88
?>
99
--INI--
1010
date.timezone = UTC
11+
error_reporting=E_ALL&~E_DEPRECATED
1112
--FILE--
1213
<?php
1314
setlocale(LC_ALL, 'Japanese_Japan.932');

ext/date/tests/bug65371.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ function p($str)
1616
setlocale(LC_ALL, 'C');
1717
p('');
1818
?>
19-
--EXPECT--
19+
--EXPECTF--
2020
21+
22+
Deprecated: Function strftime() is deprecated in %s on line %d
2123
2224
e38182
25+
26+
Deprecated: Function strftime() is deprecated in %s on line %d
2327
e38182

ext/date/tests/gmstrftime_basic.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,9 @@ var_dump( gmstrftime($format) );
1717
?>
1818
--EXPECTF--
1919
*** Testing gmstrftime() : basic functionality ***
20+
21+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
2022
string(20) "Aug 08 2008 08:08:08"
23+
24+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
2125
string(%d) "%s %d %d %d:%d:%d"

ext/date/tests/gmstrftime_variation10.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,17 @@ foreach($inputs as $key =>$value) {
3434
*** Testing gmstrftime() : usage variation ***
3535

3636
--The ISO 8601:1988 week number--
37+
38+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3739
string(%d) "%d"
40+
41+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3842
string(2) "32"
3943

4044
--Weekday as decimal--
45+
46+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4147
string(%d) "%d"
48+
49+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4250
string(1) "5"

ext/date/tests/gmstrftime_variation11.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ var_dump( gmstrftime($format, $timestamp) );
1919
*** Testing gmstrftime() : usage variation ***
2020

2121
-- Testing gmstrftime() function with Abbreviated month name format %h --
22+
23+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
2224
string(%d) "%s"
25+
26+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
2327
string(3) "Aug"

ext/date/tests/gmstrftime_variation12.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@ var_dump( gmstrftime($format, $timestamp) );
2525
*** Testing gmstrftime() : usage variation ***
2626

2727
-- Testing gmstrftime() function with Abbreviated month name format %h --
28+
29+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
2830
string(%d) "%s"
31+
32+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
2933
string(3) "Aug"

ext/date/tests/gmstrftime_variation13.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,33 @@ foreach($inputs as $key =>$value) {
3030
*** Testing gmstrftime() : usage variation ***
3131

3232
--Century number--
33+
34+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3335
string(2) "%d"
36+
37+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3438
string(2) "20"
3539

3640
--Month Date Year--
41+
42+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3743
string(%d) "%d/%d/%d"
44+
45+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3846
string(8) "08/08/08"
3947

4048
--Year with century--
49+
50+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4151
string(%d) "%d"
52+
53+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4254
string(4) "2008"
4355

4456
--Year without century--
57+
58+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4559
string(2) "%d"
60+
61+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4662
string(2) "08"

ext/date/tests/gmstrftime_variation14.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,33 @@ foreach($inputs as $key =>$value) {
3636
*** Testing gmstrftime() : usage variation ***
3737

3838
--Century number--
39+
40+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3941
string(%d) "%d"
42+
43+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4044
string(2) "20"
4145

4246
--Month Date Year--
47+
48+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4349
string(%d) "%d/%d/%d"
50+
51+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4452
string(8) "08/08/08"
4553

4654
--Year with century--
55+
56+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4757
string(%d) "%d"
58+
59+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4860
string(4) "2008"
4961

5062
--Year without century--
63+
64+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
5165
string(%d) "%d"
66+
67+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
5268
string(2) "08"

ext/date/tests/gmstrftime_variation15.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,25 @@ foreach($inputs as $key =>$value) {
2929
*** Testing gmstrftime() : usage variation ***
3030

3131
--Time in a.m/p.m notation--
32+
33+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3234
string(%d) "%d:%d:%d %c%c"
35+
36+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3337
string(11) "08:08:08 AM"
3438

3539
--Time in 24 hour notation--
40+
41+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3642
string(%d) "%d:%d"
43+
44+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3745
string(5) "08:08"
3846

3947
--Current time %H:%M:%S format--
48+
49+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4050
string(%d) "%d:%d:%d"
51+
52+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4153
string(8) "08:08:08"

ext/date/tests/gmstrftime_variation16.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,25 @@ foreach($inputs as $key =>$value) {
3535
*** Testing gmstrftime() : usage variation ***
3636

3737
--Time in a.m/p.m notation--
38+
39+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3840
string(%d) "%d:%d:%d %s"
41+
42+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3943
string(11) "02:08:08 PM"
4044

4145
--Time in 24 hour notation--
46+
47+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4248
string(%d) "%d:%d"
49+
50+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4351
string(5) "14:08"
4452

4553
--Current time %H:%M:%S format--
54+
55+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4656
string(%d) "%d:%d:%d"
57+
58+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4759
string(8) "14:08:08"

ext/date/tests/gmstrftime_variation17.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ var_dump( gmstrftime($format, $timestamp) );
1919
*** Testing gmstrftime() : usage variation ***
2020

2121
-- Testing gmstrftime() function with Day of the month as decimal single digit format --
22-
string(2) "%A%d"
22+
23+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
24+
string(2) " 9"
25+
26+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
2327
string(2) " 8"

ext/date/tests/gmstrftime_variation18.phpt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@ var_dump( gmstrftime($format, $timestamp) );
2525
*** Testing gmstrftime() : usage variation ***
2626

2727
-- Testing gmstrftime() function with Day of the month as decimal single digit format --
28+
29+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
2830
string(%d) "%s"
31+
32+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
2933
string(2) " 8"

ext/date/tests/gmstrftime_variation19.phpt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,23 @@ foreach($inputs as $key =>$value) {
2424
};
2525

2626
?>
27-
--EXPECT--
27+
--EXPECTF--
2828
*** Testing gmstrftime() : usage variation ***
2929

3030
--Newline character--
31+
32+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3133
string(1) "
3234
"
35+
36+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3337
string(1) "
3438
"
3539

3640
--Tab character--
41+
42+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3743
string(1) " "
44+
45+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3846
string(1) " "

ext/date/tests/gmstrftime_variation20.phpt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,23 @@ foreach($inputs as $key =>$value) {
3030
};
3131

3232
?>
33-
--EXPECTREGEX--
34-
\*\*\* Testing gmstrftime\(\) : usage variation \*\*\*
33+
--EXPECTF--
34+
*** Testing gmstrftime() : usage variation ***
3535

3636
--Newline character--
37-
string\(1\) "
37+
38+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
39+
string(1) "
3840
"
39-
string\(1\) "
41+
42+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
43+
string(1) "
4044
"
4145

4246
--Tab character--
43-
string\(1\) "\s"
44-
string\(1\) "\s"
47+
48+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
49+
string(1) "%r\s%r"
50+
51+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
52+
string(1) "%r\s%r"

ext/date/tests/gmstrftime_variation21.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,25 @@ foreach($inputs as $key =>$value) {
2929
*** Testing gmstrftime() : usage variation ***
3030

3131
--Preferred date and time representation--
32+
33+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3234
string(%d) "%s %s %d %d:%d:%d %d"
35+
36+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3337
string(24) "Fri Aug 8 08:08:08 2008"
3438

3539
--Preferred date representation--
40+
41+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3642
string(%d) "%d/%d/%d"
43+
44+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
3745
string(8) "08/08/08"
3846

3947
--Preferred time representation--
48+
49+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4050
string(%d) "%d:%d:%d"
51+
52+
Deprecated: Function gmstrftime() is deprecated in %s on line %d
4153
string(8) "08:08:08"

0 commit comments

Comments
 (0)