xref: /php-src/ext/date/php_date.stub.php (revision c4d9a37e)
1<?php
2
3/** @generate-class-entries */
4
5/**
6 * @var string
7 * @cvalue DATE_FORMAT_RFC3339
8 */
9const DATE_ATOM = "Y-m-d\\TH:i:sP";
10
11/**
12 * @var string
13 * @cvalue DATE_FORMAT_COOKIE
14 */
15const DATE_COOKIE = "l, d-M-Y H:i:s T";
16
17/**
18 * @var string
19 * @cvalue DATE_FORMAT_ISO8601
20 */
21const DATE_ISO8601 = "Y-m-d\\TH:i:sO";
22
23/**
24 * @var string
25 * @cvalue DATE_FORMAT_ISO8601_EXPANDED
26 */
27const DATE_ISO8601_EXPANDED = "X-m-d\\TH:i:sP";
28
29/**
30 * @var string
31 * @cvalue DATE_FORMAT_RFC822
32 */
33const DATE_RFC822 = "D, d M y H:i:s O";
34
35/**
36 * @var string
37 * @cvalue DATE_FORMAT_RFC850
38 */
39const DATE_RFC850 = "l, d-M-y H:i:s T";
40
41/**
42 * @var string
43 * @cvalue DATE_FORMAT_RFC1036
44 */
45const DATE_RFC1036 = "D, d M y H:i:s O";
46
47/**
48 * @var string
49 * @cvalue DATE_FORMAT_RFC1123
50 */
51const DATE_RFC1123 = "D, d M Y H:i:s O";
52
53/**
54 * @var string
55 * @cvalue DATE_FORMAT_RFC7231
56 */
57const DATE_RFC7231 = "D, d M Y H:i:s \\G\\M\\T";
58
59/**
60 * @var string
61 * @cvalue DATE_FORMAT_RFC2822
62 */
63const DATE_RFC2822 = "D, d M Y H:i:s O";
64
65/**
66 * @var string
67 * @cvalue DATE_FORMAT_RFC3339
68 */
69const DATE_RFC3339 = "Y-m-d\\TH:i:sP";
70
71/**
72 * @var string
73 * @cvalue DATE_FORMAT_RFC3339_EXTENDED
74 */
75const DATE_RFC3339_EXTENDED = "Y-m-d\\TH:i:s.vP";
76
77/** @var string */
78const DATE_RSS = DATE_RFC1123;
79
80/** @var string */
81const DATE_W3C = DATE_RFC3339;
82
83/**
84 * @var int
85 * @cvalue SUNFUNCS_RET_TIMESTAMP
86 */
87const SUNFUNCS_RET_TIMESTAMP = UNKNOWN;
88
89/**
90 * @var int
91 * @cvalue SUNFUNCS_RET_STRING
92 */
93const SUNFUNCS_RET_STRING = UNKNOWN;
94
95/**
96 * @var int
97 * @cvalue SUNFUNCS_RET_DOUBLE
98 */
99const SUNFUNCS_RET_DOUBLE = UNKNOWN;
100
101function strtotime(string $datetime, ?int $baseTimestamp = null): int|false {}
102
103/** @refcount 1 */
104function date(string $format, ?int $timestamp = null): string {}
105
106function idate(string $format, ?int $timestamp = null): int|false {}
107
108/** @refcount 1 */
109function gmdate(string $format, ?int $timestamp = null): string {}
110
111function mktime(
112    int $hour, ?int $minute = null, ?int $second = null,
113    ?int $month = null, ?int $day = null, ?int $year = null): int|false {}
114
115function gmmktime(
116    int $hour, ?int $minute = null, ?int $second = null,
117    ?int $month = null, ?int $day = null, ?int $year = null): int|false {}
118
119function checkdate(int $month, int $day, int $year): bool {}
120
121/**
122 * @refcount 1
123 * @deprecated
124 */
125function strftime(string $format, ?int $timestamp = null): string|false {}
126
127/**
128 * @refcount 1
129 * @deprecated
130 */
131function gmstrftime(string $format, ?int $timestamp = null): string|false {}
132
133function time(): int {}
134
135/**
136 * @return array<int|string, int>
137 * @refcount 1
138 */
139function localtime(?int $timestamp = null, bool $associative = false): array {}
140
141/**
142 * @return array<int|string, int|string>
143 * @refcount 1
144 */
145function getdate(?int $timestamp = null): array {}
146
147/** @refcount 1 */
148function date_create(string $datetime = "now", ?DateTimeZone $timezone = null): DateTime|false {}
149
150/** @refcount 1 */
151function date_create_immutable(
152    string $datetime = "now", ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
153
154/** @refcount 1 */
155function date_create_from_format(
156    string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false {}
157
158/** @refcount 1 */
159function date_create_immutable_from_format(
160    string $format, string $datetime, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
161
162/**
163 * @return array<string, mixed>
164 * @refcount 1
165 */
166function date_parse(string $datetime): array {}
167
168/**
169 * @return array<string, mixed>
170 * @refcount 1
171 */
172function date_parse_from_format(string $format, string $datetime): array {}
173
174/**
175 * @return array<string, int|array>|false
176 * @refcount 1
177 */
178function date_get_last_errors(): array|false {}
179
180/** @refcount 1 */
181function date_format(DateTimeInterface $object, string $format): string {}
182
183function date_modify(DateTime $object, string $modifier): DateTime|false {}
184
185function date_add(DateTime $object, DateInterval $interval): DateTime {}
186
187function date_sub(DateTime $object, DateInterval $interval): DateTime {}
188
189/** @refcount 1 */
190function date_timezone_get(DateTimeInterface $object): DateTimeZone|false {}
191
192function date_timezone_set(DateTime $object, DateTimeZone $timezone): DateTime {}
193
194function date_offset_get(DateTimeInterface $object): int {}
195
196/** @refcount 1 */
197function date_diff(
198    DateTimeInterface $baseObject, DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
199
200function date_time_set(
201    DateTime $object, int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime {}
202
203function date_date_set(DateTime $object, int $year, int $month, int $day): DateTime {}
204
205function date_isodate_set(DateTime $object, int $year, int $week, int $dayOfWeek = 1): DateTime {}
206
207function date_timestamp_set(DateTime $object, int $timestamp): DateTime {}
208
209function date_timestamp_get(DateTimeInterface $object): int {}
210
211/** @refcount 1 */
212function timezone_open(string $timezone): DateTimeZone|false {}
213
214/** @refcount 1 */
215function timezone_name_get(DateTimeZone $object): string {}
216
217/** @refcount 1 */
218function timezone_name_from_abbr(string $abbr, int $utcOffset = -1, int $isDST = -1): string|false {}
219
220function timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime): int {}
221
222/**
223 * @return array<int, array>|false
224 * @refcount 1
225 */
226function timezone_transitions_get(
227    DateTimeZone $object, int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false {}
228
229/**
230 * @return array<string, float|string>|false
231 * @refcount 1
232 */
233function timezone_location_get(DateTimeZone $object): array|false {}
234
235/**
236 * @return array<int, string>
237 * @refcount 1
238 */
239function timezone_identifiers_list(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array {}
240
241/**
242 * @return array<string, array>
243 * @refcount 1
244 */
245function timezone_abbreviations_list(): array {}
246
247/** @refcount 1 */
248function timezone_version_get(): string {}
249
250/** @refcount 1 */
251function date_interval_create_from_date_string(string $datetime): DateInterval|false {}
252
253/** @refcount 1 */
254function date_interval_format(DateInterval $object, string $format): string {}
255
256function date_default_timezone_set(string $timezoneId): bool {}
257
258/** @refcount 1 */
259function date_default_timezone_get(): string {}
260
261/**
262 * @refcount 1
263 * @deprecated
264 */
265function date_sunrise(
266    int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
267    ?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
268    ?float $utcOffset = null): string|int|float|false {}
269
270/**
271 * @refcount 1
272 * @deprecated
273 */
274function date_sunset(
275    int $timestamp, int $returnFormat = SUNFUNCS_RET_STRING,
276    ?float $latitude = null, ?float $longitude = null, ?float $zenith = null,
277    ?float $utcOffset = null): string|int|float|false {}
278
279/**
280 * @return array<string, bool|int>
281 * @refcount 1
282 */
283function date_sun_info(int $timestamp, float $latitude, float $longitude): array {}
284
285interface DateTimeInterface
286{
287
288    public const string ATOM = DATE_ATOM;
289
290    public const string COOKIE = DATE_COOKIE;
291
292    public const string ISO8601 = DATE_ISO8601;
293
294    public const string ISO8601_EXPANDED = DATE_ISO8601_EXPANDED;
295
296    public const string RFC822 = DATE_RFC822;
297
298    public const string RFC850 = DATE_RFC850;
299
300    public const string RFC1036 = DATE_RFC1036;
301
302    public const string RFC1123 = DATE_RFC1123;
303
304    public const string RFC7231 = DATE_RFC7231;
305
306    public const string RFC2822 = DATE_RFC2822;
307
308    public const string RFC3339 = DATE_RFC3339;
309
310    public const string RFC3339_EXTENDED = DATE_RFC3339_EXTENDED;
311
312    public const string RSS = DATE_RSS;
313
314    public const string W3C = DATE_W3C;
315
316    /** @tentative-return-type */
317    public function format(string $format): string;
318
319    /** @tentative-return-type */
320    public function getTimezone(): DateTimeZone|false;
321
322    /** @tentative-return-type */
323    public function getOffset(): int;
324
325    /** @tentative-return-type */
326    public function getTimestamp(): int;
327
328    public function getMicrosecond(): int;
329
330    /** @tentative-return-type */
331    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval;
332
333    /** @tentative-return-type */
334    public function __wakeup(): void;
335
336    public function __serialize(): array;
337
338    public function __unserialize(array $data): void;
339}
340
341class DateTime implements DateTimeInterface
342{
343    public function __construct(string $datetime = "now", ?DateTimeZone $timezone = null) {}
344
345    public function __serialize(): array {}
346
347    public function __unserialize(array $data): void {}
348
349    /** @tentative-return-type */
350    public function __wakeup(): void {}
351
352    /** @tentative-return-type */
353    public static function __set_state(array $array): DateTime {}
354
355    /** @tentative-return-type */
356    public static function createFromImmutable(DateTimeImmutable $object): static {}
357
358    /** @return static */
359    public static function createFromInterface(DateTimeInterface $object): DateTime {} // TODO return type should be static
360
361    /**
362     * @tentative-return-type
363     * @alias date_create_from_format
364     */
365    public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTime|false {}
366
367    /** @tentative-return-type */
368    public static function createFromTimestamp(int|float $timestamp): static {}
369
370    /**
371     * @return array<string, int|array>|false
372     * @tentative-return-type
373     * @alias date_get_last_errors
374     */
375    public static function getLastErrors(): array|false {}
376
377    /**
378     * @tentative-return-type
379     * @alias date_format
380     */
381    public function format(string $format): string {}
382
383    /**
384     * @tentative-return-type
385     */
386    public function modify(string $modifier): DateTime|false {}
387
388    /**
389     * @tentative-return-type
390     * @alias date_add
391     */
392    public function add(DateInterval $interval): DateTime {}
393
394    /**
395     * @tentative-return-type
396     */
397    public function sub(DateInterval $interval): DateTime {}
398
399    /**
400     * @tentative-return-type
401     * @alias date_timezone_get
402     */
403    public function getTimezone(): DateTimeZone|false {}
404
405    /**
406     * @tentative-return-type
407     * @alias date_timezone_set
408     */
409    public function setTimezone(DateTimeZone $timezone): DateTime {}
410
411    /**
412     * @tentative-return-type
413     * @alias date_offset_get
414     */
415    public function getOffset(): int {}
416
417    public function getMicrosecond(): int {}
418
419    /**
420     * @tentative-return-type
421     * @alias date_time_set
422     */
423    public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime {}
424
425    /**
426     * @tentative-return-type
427     * @alias date_date_set
428     */
429    public function setDate(int $year, int $month, int $day): DateTime {}
430
431    /**
432     * @tentative-return-type
433     * @alias date_isodate_set
434     */
435    public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTime {}
436
437    /**
438     * @tentative-return-type
439     * @alias date_timestamp_set
440     */
441    public function setTimestamp(int $timestamp): DateTime {}
442
443    public function setMicrosecond(int $microsecond): static {}
444
445    /**
446     * @tentative-return-type
447     * @alias date_timestamp_get
448     */
449    public function getTimestamp(): int {}
450
451    /**
452     * @tentative-return-type
453     * @alias date_diff
454     */
455    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
456}
457
458class DateTimeImmutable implements DateTimeInterface
459{
460    public function __construct(string $datetime = "now", ?DateTimeZone $timezone = null) {}
461
462    public function __serialize(): array {}
463
464    public function __unserialize(array $data): void {}
465
466    /** @tentative-return-type */
467    public function __wakeup(): void {}
468
469    /** @tentative-return-type */
470    public static function __set_state(array $array): DateTimeImmutable {}
471
472    /**
473     * @tentative-return-type
474     * @alias date_create_immutable_from_format
475     */
476    public static function createFromFormat(string $format, string $datetime, ?DateTimeZone $timezone = null): DateTimeImmutable|false {}
477
478    /** @tentative-return-type */
479    public static function createFromTimestamp(int|float $timestamp): static {}
480
481    /**
482     * @return array<string, int|array>|false
483     * @tentative-return-type
484     * @alias date_get_last_errors
485     */
486    public static function getLastErrors(): array|false {}
487
488    /**
489     * @tentative-return-type
490     * @alias date_format
491     */
492    public function format(string $format): string {}
493
494    /**
495     * @tentative-return-type
496     * @alias date_timezone_get
497     */
498    public function getTimezone(): DateTimeZone|false {}
499
500    /**
501     * @tentative-return-type
502     * @alias date_offset_get
503     */
504    public function getOffset(): int {}
505
506    /**
507     * @tentative-return-type
508     * @alias date_timestamp_get
509     */
510    public function getTimestamp(): int {}
511
512    /**
513     * @alias DateTime::getMicrosecond
514     */
515    public function getMicrosecond(): int {}
516
517    /**
518     * @tentative-return-type
519     * @alias date_diff
520     */
521    public function diff(DateTimeInterface $targetObject, bool $absolute = false): DateInterval {}
522
523    /** @tentative-return-type */
524    public function modify(string $modifier): DateTimeImmutable|false {}
525
526    /** @tentative-return-type */
527    public function add(DateInterval $interval): DateTimeImmutable {}
528
529    /** @tentative-return-type */
530    public function sub(DateInterval $interval): DateTimeImmutable {}
531
532    /** @tentative-return-type */
533    public function setTimezone(DateTimeZone $timezone): DateTimeImmutable {}
534
535    /** @tentative-return-type */
536    public function setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTimeImmutable {}
537
538    /** @tentative-return-type */
539    public function setDate(int $year, int $month, int $day): DateTimeImmutable {}
540
541    /** @tentative-return-type */
542    public function setISODate(int $year, int $week, int $dayOfWeek = 1): DateTimeImmutable {}
543
544    /** @tentative-return-type */
545    public function setTimestamp(int $timestamp): DateTimeImmutable {}
546
547    public function setMicrosecond(int $microsecond): static {}
548
549    /** @tentative-return-type */
550    public static function createFromMutable(DateTime $object): static {}
551
552    /** @return static */
553    public static function createFromInterface(DateTimeInterface $object): DateTimeImmutable {} // TODO return type should be static
554}
555
556class DateTimeZone
557{
558    /** @cvalue PHP_DATE_TIMEZONE_GROUP_AFRICA */
559    public const int AFRICA = UNKNOWN;
560    /** @cvalue PHP_DATE_TIMEZONE_GROUP_AMERICA */
561    public const int AMERICA = UNKNOWN;
562    /** @cvalue PHP_DATE_TIMEZONE_GROUP_ANTARCTICA */
563    public const int ANTARCTICA = UNKNOWN;
564    /** @cvalue PHP_DATE_TIMEZONE_GROUP_ARCTIC */
565    public const int ARCTIC = UNKNOWN;
566    /** @cvalue PHP_DATE_TIMEZONE_GROUP_ASIA */
567    public const int ASIA = UNKNOWN;
568    /** @cvalue PHP_DATE_TIMEZONE_GROUP_ATLANTIC */
569    public const int ATLANTIC = UNKNOWN;
570    /** @cvalue PHP_DATE_TIMEZONE_GROUP_AUSTRALIA */
571    public const int AUSTRALIA = UNKNOWN;
572    /** @cvalue PHP_DATE_TIMEZONE_GROUP_EUROPE */
573    public const int EUROPE = UNKNOWN;
574    /** @cvalue PHP_DATE_TIMEZONE_GROUP_INDIAN */
575    public const int INDIAN = UNKNOWN;
576    /** @cvalue PHP_DATE_TIMEZONE_GROUP_PACIFIC */
577    public const int PACIFIC = UNKNOWN;
578    /** @cvalue PHP_DATE_TIMEZONE_GROUP_UTC */
579    public const int UTC = UNKNOWN;
580    /** @cvalue PHP_DATE_TIMEZONE_GROUP_ALL */
581    public const int ALL = UNKNOWN;
582    /** @cvalue PHP_DATE_TIMEZONE_GROUP_ALL_W_BC */
583    public const int ALL_WITH_BC = UNKNOWN;
584    /** @cvalue PHP_DATE_TIMEZONE_PER_COUNTRY */
585    public const int PER_COUNTRY = UNKNOWN;
586
587    public function __construct(string $timezone) {}
588
589    /**
590     * @tentative-return-type
591     * @alias timezone_name_get
592     */
593    public function getName(): string {}
594
595    /**
596     * @tentative-return-type
597     * @alias timezone_offset_get
598     */
599    public function getOffset(DateTimeInterface $datetime): int {}
600
601    /**
602     * @return array<int, array>|false
603     * @tentative-return-type
604     * @alias timezone_transitions_get
605     */
606    public function getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false {}
607
608    /**
609     * @return array<string, float|string>|false
610     * @tentative-return-type
611     * @alias timezone_location_get
612     */
613    public function getLocation(): array|false {}
614
615    /**
616     * @return array<string, array>
617     * @tentative-return-type
618     * @alias timezone_abbreviations_list
619     */
620    public static function listAbbreviations(): array {}
621
622    /**
623     * @return array<int, string>
624     * @tentative-return-type
625     * @alias timezone_identifiers_list
626     */
627    public static function listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null): array {}
628
629    public function __serialize(): array {}
630
631    public function __unserialize(array $data): void {}
632
633    /** @tentative-return-type */
634    public function __wakeup(): void {}
635
636    /** @tentative-return-type */
637    public static function __set_state(array $array): DateTimeZone {}
638}
639
640class DateInterval
641{
642    public function __construct(string $duration) {}
643
644    /**
645     * @tentative-return-type
646     */
647    public static function createFromDateString(string $datetime): DateInterval|false {}
648
649    /**
650     * @tentative-return-type
651     * @alias date_interval_format
652     */
653    public function format(string $format): string {}
654
655    public function __serialize(): array;
656
657    public function __unserialize(array $data): void;
658
659    /** @tentative-return-type */
660    public function __wakeup(): void {}
661
662    /** @tentative-return-type */
663    public static function __set_state(array $array): DateInterval {}
664}
665
666class DatePeriod implements IteratorAggregate
667{
668    /** @cvalue PHP_DATE_PERIOD_EXCLUDE_START_DATE */
669    public const int EXCLUDE_START_DATE = UNKNOWN;
670    /** @cvalue PHP_DATE_PERIOD_INCLUDE_END_DATE */
671    public const int INCLUDE_END_DATE = UNKNOWN;
672
673    /** @readonly */
674    public ?DateTimeInterface $start;
675    /** @readonly */
676    public ?DateTimeInterface $current;
677    /** @readonly */
678    public ?DateTimeInterface $end;
679    /** @readonly */
680    public ?DateInterval $interval;
681    /** @readonly */
682    public int $recurrences;
683    /** @readonly */
684    public bool $include_start_date;
685    /** @readonly */
686    public bool $include_end_date;
687
688    public static function createFromISO8601String(string $specification, int $options = 0): static {}
689
690    /**
691     * @param DateTimeInterface|string $start
692     * @param DateInterval|int $interval
693     * @param DateTimeInterface|int $end
694     * @param int $options
695     */
696    public function __construct($start, $interval = UNKNOWN, $end = UNKNOWN, $options = UNKNOWN) {}
697
698    /** @tentative-return-type */
699    public function getStartDate(): DateTimeInterface {}
700
701    /** @tentative-return-type */
702    public function getEndDate(): ?DateTimeInterface {}
703
704    /** @tentative-return-type */
705    public function getDateInterval(): DateInterval {}
706
707    /** @tentative-return-type */
708    public function getRecurrences(): ?int {}
709
710    public function __serialize(): array;
711
712    public function __unserialize(array $data): void;
713
714    /** @tentative-return-type */
715    public function __wakeup(): void {}
716
717    /** @tentative-return-type */
718    public static function __set_state(array $array): DatePeriod {}
719
720    public function getIterator(): Iterator {}
721}
722
723/**
724 * @strict-properties
725 */
726class DateError extends Error
727{
728}
729
730/**
731 * @strict-properties
732 */
733class DateObjectError extends DateError
734{
735}
736
737/**
738 * @strict-properties
739 */
740class DateRangeError extends DateError
741{
742}
743
744/**
745 * @strict-properties
746 */
747class DateException extends Exception
748{
749}
750
751/**
752 * @strict-properties
753 */
754class DateInvalidTimeZoneException extends DateException
755{
756}
757
758/**
759 * @strict-properties
760 */
761class DateInvalidOperationException extends DateException
762{
763}
764
765/**
766 * @strict-properties
767 */
768class DateMalformedStringException extends DateException
769{
770}
771
772/**
773 * @strict-properties
774 */
775class DateMalformedIntervalStringException extends DateException
776{
777}
778
779/**
780 * @strict-properties
781 */
782class DateMalformedPeriodStringException extends DateException
783{
784}
785