Skip to content

Commit e96e4ac

Browse files
committed
More consistent parameter names for date/time functions
1 parent 0ef8e0c commit e96e4ac

File tree

6 files changed

+64
-62
lines changed

6 files changed

+64
-62
lines changed

Zend/tests/parameter_default_values/internal_declaration_error_int.phpt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ The default value is an integer in the parent class method's signature.
44
<?php
55
class MyDateTime extends DateTime
66
{
7-
public function setTime(int $hour, int $minute, int $second = 0, bool $microseconds = false)
7+
public function setTime(int $hour, int $minute, int $second = 0, bool $microsecond = false)
88
{
99
}
1010
}
11+
?>
1112
--EXPECTF--
12-
Fatal error: Declaration of MyDateTime::setTime(int $hour, int $minute, int $second = 0, bool $microseconds = false) must be compatible with DateTime::setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0) in %s on line %d
13+
Fatal error: Declaration of MyDateTime::setTime(int $hour, int $minute, int $second = 0, bool $microsecond = false) must be compatible with DateTime::setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0) in %s on line %d

Zend/tests/parameter_default_values/internal_declaration_error_null.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ class MyDateTime extends DateTime
88
{
99
}
1010
}
11+
?>
1112
--EXPECTF--
12-
Fatal error: Declaration of MyDateTime::createFromFormat() must be compatible with DateTime::createFromFormat(string $format, string $time, ?DateTimeZone $timezone = null) in %s on line %d
13+
Fatal error: Declaration of MyDateTime::createFromFormat() must be compatible with DateTime::createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null) in %s on line %d

Zend/tests/type_declarations/variance/internal_parent.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Internal class as parent
44
<?php
55

66
class Test extends DateTime {
7-
public static function createFromFormat($format, $time, Wrong $timezone = null) { }
7+
public static function createFromFormat($format, $datetime, Wrong $timezone = null) { }
88
}
99

1010
?>
1111
--EXPECTF--
12-
Fatal error: Could not check compatibility between Test::createFromFormat($format, $time, ?Wrong $timezone = null) and DateTime::createFromFormat(string $format, string $time, ?DateTimeZone $timezone = null), because class Wrong is not available in %s on line %d
12+
Fatal error: Could not check compatibility between Test::createFromFormat($format, $datetime, ?Wrong $timezone = null) and DateTime::createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null), because class Wrong is not available in %s on line %d

ext/date/php_date.stub.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/** @generate-function-entries */
44

5-
function strtotime(string $time, ?int $now = null): int|false {}
5+
function strtotime(string $datetime, ?int $now = null): int|false {}
66

77
function date(string $format, ?int $timestamp = null): string {}
88

@@ -11,14 +11,14 @@ function idate(string $format, ?int $timestamp = null): int|false {}
1111
function gmdate(string $format, ?int $timestamp = null): string {}
1212

1313
function mktime(
14-
int $hour, ?int $min = null, ?int $sec = null,
15-
?int $mon = null, ?int $day = null, ?int $year = null): int|false {}
14+
int $hour, ?int $minute = null, ?int $second = null,
15+
?int $month = null, ?int $day = null, ?int $year = null): int|false {}
1616

1717
function gmmktime(
18-
int $hour, ?int $min = null, ?int $sec = null,
19-
?int $mon = null, ?int $day = null, ?int $year = null): int|false {}
18+
int $hour, ?int $minute = null, ?int $second = null,
19+
?int $month = null, ?int $day = null, ?int $year = null): int|false {}
2020

21-
function checkdate(int $m, int $d, int $y): bool {}
21+
function checkdate(int $month, int $day, int $year): bool {}
2222

2323
function strftime(string $format, ?int $timestamp = null): string|false {}
2424

@@ -30,26 +30,26 @@ function localtime(?int $timestamp = null, bool $associative = false): array {}
3030

3131
function getdate(?int $timestamp = null): array {}
3232

33-
function date_create(string $time = "now", ?DateTimeZone $timezone = null): DateTime|false {}
33+
function date_create(string $datetime = "now", ?DateTimeZone $timezone = null): DateTime|false {}
3434

3535
function date_create_immutable(
36-
string $time = "now", ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
36+
string $datetime = "now", ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
3737

3838
function date_create_from_format(
39-
string $format, string $time, ?DateTimeZone $timezone = null): DateTime|false {}
39+
string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false {}
4040

4141
function date_create_immutable_from_format(
42-
string $format, string $time, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
42+
string $format, string $datetime, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
4343

44-
function date_parse(string $date): array {}
44+
function date_parse(string $datetime): array {}
4545

46-
function date_parse_from_format(string $format, string $date): array {}
46+
function date_parse_from_format(string $format, string $datetime): array {}
4747

4848
function date_get_last_errors(): array|false {}
4949

5050
function date_format(DateTimeInterface $object, string $format): string {}
5151

52-
function date_modify(DateTime $object, string $modify): DateTime|false {}
52+
function date_modify(DateTime $object, string $modifier): DateTime|false {}
5353

5454
function date_add(DateTime $object, DateInterval $interval): DateTime {}
5555

@@ -62,10 +62,10 @@ function date_timezone_set(DateTimeInterface $object, DateTimeZone $timezone): D
6262
function date_offset_get(DateTimeInterface $object): int {}
6363

6464
function date_diff(
65-
DateTimeInterface $object, DateTimeInterface $object2, bool $absolute = false): DateInterval {}
65+
DateTimeInterface $object1, DateTimeInterface $object2, bool $absolute = false): DateInterval {}
6666

6767
function date_time_set(
68-
DateTime $object, int $hour, int $minute, int $second = 0, int $microseconds = 0): DateTime {}
68+
DateTime $object, int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime {}
6969

7070
function date_date_set(DateTime $object, int $year, int $month, int $day): DateTime {}
7171

@@ -94,7 +94,7 @@ function timezone_abbreviations_list(): array {}
9494

9595
function timezone_version_get(): string {}
9696

97-
function date_interval_create_from_date_string(string $time): DateInterval|false {}
97+
function date_interval_create_from_date_string(string $datetime): DateInterval|false {}
9898

9999
function date_interval_format(DateInterval $object, string $format): string {}
100100

@@ -103,16 +103,16 @@ function date_default_timezone_set(string $timezone_identifier): bool {}
103103
function date_default_timezone_get(): string {}
104104

105105
function date_sunrise(
106-
int $time, int $retformat = SUNFUNCS_RET_STRING,
106+
int $timestamp, int $retformat = SUNFUNCS_RET_STRING,
107107
?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
108108
float $gmt_offset = 0): string|int|float|false {}
109109

110110
function date_sunset(
111-
int $time, int $retformat = SUNFUNCS_RET_STRING,
111+
int $timestamp, int $retformat = SUNFUNCS_RET_STRING,
112112
?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
113113
float $gmt_offset = 0): string|int|float|false {}
114114

115-
function date_sun_info(int $time, float $latitude, float $longitude): array {}
115+
function date_sun_info(int $timestamp, float $latitude, float $longitude): array {}
116116

117117
// NB: Adding return types to methods is a BC break!
118118
// For now only using @return annotations here.
@@ -139,7 +139,7 @@ public function __wakeup();
139139

140140
class DateTime implements DateTimeInterface
141141
{
142-
public function __construct(string $time = "now", ?DateTimeZone $timezone = null) {}
142+
public function __construct(string $datetime = "now", ?DateTimeZone $timezone = null) {}
143143

144144
public function __wakeup() {}
145145

@@ -155,7 +155,7 @@ public static function createFromInterface(DateTimeInterface $object): DateTime
155155
* @return DateTime|false
156156
* @alias date_create_from_format
157157
*/
158-
public static function createFromFormat(string $format, string $time, ?DateTimeZone $timezone = null) {}
158+
public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null) {}
159159

160160
/**
161161
* @return array|false
@@ -173,7 +173,7 @@ public function format(string $format) {}
173173
* @return DateTime|false
174174
* @alias date_modify
175175
*/
176-
public function modify(string $modify) {}
176+
public function modify(string $modifier) {}
177177

178178
/**
179179
* @return DateTime
@@ -209,7 +209,7 @@ public function getOffset() {}
209209
* @return DateTime
210210
* @alias date_time_set
211211
*/
212-
public function setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0) {}
212+
public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0) {}
213213

214214
/**
215215
* @return DateTime
@@ -221,7 +221,7 @@ public function setDate(int $year, int $month, int $day) {}
221221
* @return DateTime
222222
* @alias date_isodate_set
223223
*/
224-
public function setISODate(int $year, int $week, int $day = 1) {}
224+
public function setISODate(int $year, int $week, int $day_of_week = 1) {}
225225

226226
/**
227227
* @return DateTime
@@ -244,7 +244,7 @@ public function diff(DateTimeInterface $object, bool $absolute = false) {}
244244

245245
class DateTimeImmutable implements DateTimeInterface
246246
{
247-
public function __construct(string $time = "now", ?DateTimeZone $timezone = null) {}
247+
public function __construct(string $datetime = "now", ?DateTimeZone $timezone = null) {}
248248

249249
public function __wakeup() {}
250250

@@ -255,7 +255,7 @@ public static function __set_state(array $array) {}
255255
* @return DateTimeImmutable|false
256256
* @alias date_create_immutable_from_format
257257
*/
258-
public static function createFromFormat(string $format, string $time, ?DateTimeZone $timezone = null) {}
258+
public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null) {}
259259

260260
/**
261261
* @return array|false
@@ -294,7 +294,7 @@ public function getTimestamp() {}
294294
public function diff(DateTimeInterface $object, bool $absolute = false) {}
295295

296296
/** @return DateTimeImmutable|false */
297-
public function modify(string $modify) {}
297+
public function modify(string $modifier) {}
298298

299299
/** @return DateTimeImmutable */
300300
public function add(DateInterval $interval) {}
@@ -306,13 +306,13 @@ public function sub(DateInterval $interval) {}
306306
public function setTimezone(DateTimeZone $timezone) {}
307307

308308
/** @return DateTimeImmutable */
309-
public function setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0) {}
309+
public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0) {}
310310

311311
/** @return DateTimeImmutable */
312312
public function setDate(int $year, int $month, int $day) {}
313313

314314
/** @return DateTimeImmutable */
315-
public function setISODate(int $year, int $week, int $day = 1) {}
315+
public function setISODate(int $year, int $week, int $day_of_week = 1) {}
316316

317317
/** @return DateTimeImmutable */
318318
public function setTimestamp(int $timestamp) {}
@@ -377,7 +377,7 @@ public function __construct(string $interval_spec) {}
377377
* @return DateInterval|false
378378
* @alias date_interval_create_from_date_string
379379
*/
380-
public static function createFromDateString(string $time) {}
380+
public static function createFromDateString(string $datetime) {}
381381

382382
/**
383383
* @return string

0 commit comments

Comments
 (0)