Skip to content

Add stubs for IntlDateFormatter & MessageFormatter #4812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions ext/intl/dateformat/dateformat.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?php

class IntlDateFormatter
{
/**
* @param IntlTimeZone|DateTimeZone|string|null $timezone
* @param IntlCalendar|int|null $calendar
*/
public function __construct(?string $locale, int $datetype, int $timetype, $timezone = null, $calendar = null, string $pattern = "") {}

/**
* @param IntlTimeZone|DateTimeZone|string|null $timezone
* @param IntlCalendar|int|null $calendar
* @return IntlDateFormatter|null
*/
public static function create(?string $locale, int $datetype, int $timetype, $timezone = null, $calendar = null, string $pattern = "") {}

/** @return int|false */
public function getDateType() {}

/** @return int|false */
public function getTimeType() {}

/** @return int|false */
public function getCalendar() {}

/**
* @param IntlCalendar|int|null $which
* @return bool
*/
public function setCalendar($which) {}

/** @return string|false */
public function getTimeZoneId() {}

/** @return IntlCalendar|null|false */
public function getCalendarObject() {}

/** @return IntlTimeZone|false */
public function getTimeZone() {}

/**
* @param IntlTimeZone|DateTimeZone|string|null $zone
* @return ?bool
*/
public function setTimeZone($zone) {}

/** @return bool */
public function setPattern(string $pattern) {}

/** @return string|false */
public function getPattern() {}

/** @return string|false */
public function getLocale(int $which = UNKNOWN) {}

/** @return void */
public function setLenient(bool $lenient) {}

/** @return bool */
public function isLenient() {}

/**
* @param array|int $value
* @return string|false
*/
public function format($value) {}

/**
* @param IntlCalendar|DateTime $object
* @param array|int|string|null $format
* @return string|false
*/
public static function formatObject($object, $format = null, ?string $locale = null) {}

/** @return int|float|false */
public function parse(string $value, &$position = null) {}

/** @return array|false */
public function localtime(string $value, &$position = null) {}

/** @return int */
public function getErrorCode() {}

/** @return string */
public function getErrorMessage() {}
}

/**
* @param IntlTimeZone|DateTimeZone|string|null $timezone
* @param IntlCalendar|int|null $calendar
*/
function datefmt_create(?string $locale, int $datetype, int $timetype, $timezone = null, $calendar = null, string $pattern = ""): ?IntlDateFormatter {}

function datefmt_get_datetype(IntlDateFormatter $df): int|false {}

function datefmt_get_timetype(IntlDateFormatter $df): int|false {}

function datefmt_get_calendar(IntlDateFormatter $df): int|false {}

/** @param IntlCalendar|int|null $which */
function datefmt_set_calendar(IntlDateFormatter $df, $which): bool {}

function datefmt_get_timezone_id(IntlDateFormatter $df): string|false {}

function datefmt_get_calendar_object(IntlDateFormatter $df): IntlCalendar|false|null {}

function datefmt_get_timezone(IntlDateFormatter $df): IntlTimeZone|false {}

/** @param IntlTimeZone|DateTimeZone|string|null $zone */
function datefmt_set_timezone(IntlDateFormatter $df, $zone): ?bool {}

function datefmt_set_pattern(IntlDateFormatter $df, string $pattern): bool {}

function datefmt_get_pattern(IntlDateFormatter $df): string|false {}

function datefmt_get_locale(IntlDateFormatter $df, int $which = UNKNOWN): string|false {}

function datefmt_set_lenient(IntlDateFormatter $df, bool $lenient): void {}

function datefmt_is_lenient(IntlDateFormatter $df): bool {}

/** @param mixed $value */
function datefmt_format(IntlDateFormatter $df, $value): string|false {}

/**
* @param IntlCalendar|DateTimeInterface $object
* @param array|int|string|null $format
*/
function datefmt_format_object($object, $format = null, ?string $locale = null): string|false {}

function datefmt_parse(IntlDateFormatter $df, string $value, &$position = null): int|float|false {}

function datefmt_localtime(IntlDateFormatter $df, string $value, &$position = null): array|false {}

function datefmt_get_error_code(IntlDateFormatter $df): int {}

function datefmt_get_error_message(IntlDateFormatter $df): string {}
161 changes: 161 additions & 0 deletions ext/intl/dateformat/dateformat_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/* This is a generated file, edit the .stub.php file instead. */

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 3)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, datetype, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, timetype, IS_LONG, 0)
ZEND_ARG_INFO(0, timezone)
ZEND_ARG_INFO(0, calendar)
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_IntlDateFormatter_create arginfo_class_IntlDateFormatter___construct

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_getDateType, 0, 0, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_IntlDateFormatter_getTimeType arginfo_class_IntlDateFormatter_getDateType

#define arginfo_class_IntlDateFormatter_getCalendar arginfo_class_IntlDateFormatter_getDateType

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setCalendar, 0, 0, 1)
ZEND_ARG_INFO(0, which)
ZEND_END_ARG_INFO()

#define arginfo_class_IntlDateFormatter_getTimeZoneId arginfo_class_IntlDateFormatter_getDateType

#define arginfo_class_IntlDateFormatter_getCalendarObject arginfo_class_IntlDateFormatter_getDateType

#define arginfo_class_IntlDateFormatter_getTimeZone arginfo_class_IntlDateFormatter_getDateType

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setTimeZone, 0, 0, 1)
ZEND_ARG_INFO(0, zone)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setPattern, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_IntlDateFormatter_getPattern arginfo_class_IntlDateFormatter_getDateType

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_getLocale, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_setLenient, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, lenient, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

#define arginfo_class_IntlDateFormatter_isLenient arginfo_class_IntlDateFormatter_getDateType

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_format, 0, 0, 1)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_formatObject, 0, 0, 1)
ZEND_ARG_INFO(0, object)
ZEND_ARG_INFO(0, format)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter_parse, 0, 0, 1)
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
ZEND_ARG_INFO(1, position)
ZEND_END_ARG_INFO()

#define arginfo_class_IntlDateFormatter_localtime arginfo_class_IntlDateFormatter_parse

#define arginfo_class_IntlDateFormatter_getErrorCode arginfo_class_IntlDateFormatter_getDateType

#define arginfo_class_IntlDateFormatter_getErrorMessage arginfo_class_IntlDateFormatter_getDateType

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_datefmt_create, 0, 3, IntlDateFormatter, 1)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, datetype, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, timetype, IS_LONG, 0)
ZEND_ARG_INFO(0, timezone)
ZEND_ARG_INFO(0, calendar)
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_datetype, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_END_ARG_INFO()

#define arginfo_datefmt_get_timetype arginfo_datefmt_get_datetype

#define arginfo_datefmt_get_calendar arginfo_datefmt_get_datetype

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_calendar, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_ARG_INFO(0, which)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_timezone_id, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_datefmt_get_calendar_object, 0, 1, IntlCalendar, MAY_BE_FALSE|MAY_BE_NULL)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_datefmt_get_timezone, 0, 1, IntlTimeZone, MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_timezone, 0, 2, _IS_BOOL, 1)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_ARG_INFO(0, zone)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_pattern, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_ARG_TYPE_INFO(0, pattern, IS_STRING, 0)
ZEND_END_ARG_INFO()

#define arginfo_datefmt_get_pattern arginfo_datefmt_get_timezone_id

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_get_locale, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_ARG_TYPE_INFO(0, which, IS_LONG, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_set_lenient, 0, 2, IS_VOID, 0)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_ARG_TYPE_INFO(0, lenient, _IS_BOOL, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_is_lenient, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_format, 0, 2, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_format_object, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_INFO(0, object)
ZEND_ARG_INFO(0, format)
ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_parse, 0, 2, MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
ZEND_ARG_INFO(1, position)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_datefmt_localtime, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0)
ZEND_ARG_INFO(1, position)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_get_error_code, 0, 1, IS_LONG, 0)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_datefmt_get_error_message, 0, 1, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, df, IntlDateFormatter, 0)
ZEND_END_ARG_INFO()
4 changes: 2 additions & 2 deletions ext/intl/dateformat/dateformat_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ PHP_FUNCTION( datefmt_is_lenient )
}
/* }}} */

/* {{{ proto string IntlDateFormatter::setLenient()
/* {{{ proto void IntlDateFormatter::setLenient()
* Set formatter lenient. }}} */
/* {{{ proto string datefmt_setLenient(IntlDateFormatter $mf)
/* {{{ proto void datefmt_setLenient(IntlDateFormatter $mf)
* Set formatter lenient.
*/
PHP_FUNCTION( datefmt_set_lenient )
Expand Down
Loading