summaryrefslogtreecommitdiff
path: root/ext/date/php_date.stub.php
blob: 667cbc1b91fa45408f2bca8dd76da18b5e3adf96 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<?php

/* TODO: Convert "uninitialized" into an exception. This will remove many
 * possibilities for false return values in here. */

/** @return int|false */
function strtotime(string $time, int $now = UNKNOWN) {}

function date(string $format, int $timestamp = UNKNOWN): string {}

/** @return int|false */
function idate(string $format, int $timestamp = UNKNOWN) {}

function gmdate(string $format, int $timestamp = UNKNOWN): string {}

/** @return int|false */
function mktime(
    int $hour, int $min = UNKNOWN, int $sec = UNKNOWN,
    int $mon = UNKNOWN, int $day = UNKNOWN, int $year = UNKNOWN) {}

/** @return int|false */
function gmmktime(
    int $hour, int $min = UNKNOWN, int $sec = UNKNOWN,
    int $mon = UNKNOWN, int $day = UNKNOWN, int $year = UNKNOWN) {}

function checkdate(int $m, int $d, int $y): bool {}

/** @return string|false */
function strftime(string $format, int $timestamp = UNKNOWN) {}

/** @return string|false */
function gmstrftime(string $format, int $timestamp = UNKNOWN) {}

function time(): int {}

function localtime(int $timestamp = UNKNOWN, bool $associative = false): array {}

function getdate(int $timestamp = UNKNOWN): array {}

/** @return DateTime|false */
function date_create(string $time, ?DateTimeZone $timezone = null) {}

/** @return DateTime|false */
function date_create_immutable(string $time, ?DateTimeZone $timezone = null) {}

/** @return DateTime|false */
function date_create_from_format(string $format, string $time, ?DateTimeZone $timezone = null) {}

/** @return DateTimeImmutable|false */
function date_create_immutable_from_format(
    string $format, string $time, ?DateTimeZone $timezone = null) {}

function date_parse(string $date): array {}

function date_parse_from_format(string $format, string $date): array {}

/** @return array|false */
function date_get_last_errors() {}

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

/** @return DateTime|false */
function date_modify(DateTime $object, string $modify) {}

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

function date_sub(DateTime $object, DateInterval $interval): DateTime {}

/** @return DateTimeZone|false */
function date_timezone_get(DateTimeInterface $object) {}

function date_timezone_set(DateTimeInterface $object, DateTimeZone $timezone): DateTime {}

function date_offset_get(DateTimeInterface $object): int {}

function date_diff(
    DateTimeInterface $object, DateTimeInterface $object2, bool $absolute = false): DateInterval {}

function date_time_set(
    DateTime $object, int $hour, int $minute, int $second = 0, int $microseconds = 0): DateTime {}

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

function date_isodate_set(DateTime $object, int $year, int $week, int $day = 1): DateTime {}

function date_timestamp_set(DateTime $object, int $timestamp): DateTime {}

/** @return int|false */
function date_timestamp_get(DateTimeInterface $object) {}

/** @return DateTimeZone|false */
function timezone_open(string $timezone) {}

function timezone_name_get(DateTimeZone $object): string {}

/** @return string|false */
function timezone_name_from_abbr(string $abbr, int $gmtoffset = -1, int $isdst = -1) {}

function timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime): int {}

/** @return array|false */
function timezone_transitions_get(
    DateTimeZone $object, int $timestamp_begin = PHP_INT_MIN, int $timestamp_end = PHP_INT_MAX) {}

/** @return array|false */
function timezone_location_get(DateTimeZone $object) {}

/** @return array|false */
function timezone_identifiers_list(int $what = DateTimeZone::ALL, ?string $country = null) {}

function timezone_abbreviations_list(): array {}

function timezone_version_get(): string {}

/** @return DateInterval|false */
function date_interval_create_from_date_string(string $time) {}

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

function date_default_timezone_set(string $timezone_identifier): bool {}

function date_default_timezone_get(): string {}

/** @return string|int|float|false */
function date_sunrise(
    int $time, int $retformat = SUNFUNCS_RET_STRING,
    float $latitude = UNKNOWN, float $longitude = UNKNOWN, float $zenith = UNKNOWN,
    float $gmt_offset = 0) {}

/** @return string|int|float|false */
function date_sunset(
    int $time, int $retformat = SUNFUNCS_RET_STRING,
    float $latitude = UNKNOWN, float $longitude = UNKNOWN, float $zenith = UNKNOWN,
    float $gmt_offset = 0) {}

function date_sun_info(int $time, float $latitude, float $longitude): array {}

// NB: Adding return types to methods is a BC break!
// For now only using @return annotations here.

interface DateTimeInterface {
    /** @return string */
    public function format(string $format);

    /** @return DateTimeZone|false */
    public function getTimezone();

    /** @return int|false */
    public function getOffset();

    /** @return int|false */
    public function getTimestamp();

    /** @return DateInterval|false */
    public function diff(DateTimeInterface $object, bool $absolute = false);

    public function __wakeup();
}

class DateTime implements DateTimeInterface {
    public function __construct(string $time, ?DateTimeZone $timezone = null);

    /** @return DateTime */
    public static function __set_state(array $array);

    /** @return DateTime */
    public static function createFromImmutable(DateTimeImmutable $object);

    /** @return DateTime|false */
    public static function createFromFormat(
        string $format, string $time, ?DateTimeZone $timezone = null);

    /** @return array|false */
    public static function getLastErrors();

    /** @return DateTime|false */
    public function modify(string $modify);

    /** @return DateTime */
    public function add(DateInterval $interval);

    /** @return DateTime */
    public function sub(DateInterval $interval);

    /** @return DateTime */
    public function setTimezone(DateTimeZone $timezone);

    /** @return DateTime */
    public function setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0);

    /** @return DateTime */
    public function setDate(int $year, int $month, int $day);

    /** @return DateTime */
    public function setISODate(int $year, int $week, int $day = 1);

    /** @return DateTime */
    public function setTimestamp(int $timestampt);
}

class DateTimeImmutable implements DateTimeInterface {
    public function __construct(string $time, ?DateTimeZone $timezone = null);

    /** @return DateTimeZone */
    public static function __set_state();

    /** @return DateTimeImmutable */
    public static function createFromMutable(DateTime $object);

    /** @return DateTimeImmutable|false */
    public function modify(string $modify);

    /** @return DateTimeImmutable */
    public function add(DateInterval $interval);

    /** @return DateTimeImmutable */
    public function sub(DateInterval $interval);

    /** @return DateTimeImmutable */
    public function setTimezone(DateTimeZone $timezone);

    /** @return DateTimeImmutable */
    public function setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0);

    /** @return DateTimeImmutable */
    public function setDate(int $year, int $month, int $day);

    /** @return DateTimeImmutable */
    public function setISODate(int $year, int $week, int $day = 1);

    /** @return DateTimeImmutable */
    public function setTimestamp(int $timestamp);
}

class DateTimeZone {
    public function __construct(string $timezone);

    /** @return string */
    public function getName();

    /** @return int */
    public function getOffset(DateTimeInterface $datetime);

    /** @return array|false */
    public function getTransitions(
        int $timestamp_begin = PHP_INT_MIN, int $timestamp_end = PHP_INT_MAX);

    /** @return array|false */
    public function getLocation();

    /** @return array */
    public static function listAbbreviations();

    /** @return array|false */
    public static function listIdentifiers(int $what = DateTimeZone::ALL, ?string $country = null);

    public function __wakeup();

    /** @return DateTimeZone */
    public static function __set_state();
}

class DateInterval {
    public function __construct(string $interval_spec);

    /** @return DateInterval|false */
    public static function createFromDateString(string $time);

    /** @return string */
    public function format(string $format);

    public function __wakeup();

    /** @return DateInterval */
    public static function __set_state(array $array);
}

class DatePeriod implements Traversable {
    /* Has an overloaded signature */
    public function __construct($start, $interval = UNKNOWN, $end = UNKNOWN);

    /** @return DateTimeInterface */
    public function getStartDate();

    /** @return DateTimeInterface|null */
    public function getEndDate();

    /** @return DateInterval */
    public function getDateInterval();

    /** @return int|null */
    public function getRecurrences();

    public function __wakeup();

    /** @return DatePeriod */
    public static function __set_state(array $array);
}