From: Derick Rethans Date: Sun, 26 Jul 2020 09:38:53 +0000 (+0100) Subject: Another pass of improving ext/date argument names X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f66627abffeef11774e6d4de1726642275077eb2;p=php Another pass of improving ext/date argument names --- diff --git a/Zend/tests/parameter_default_values/internal_declaration_error_class_const.phpt b/Zend/tests/parameter_default_values/internal_declaration_error_class_const.phpt index 2e0e6e2aea..69e7607bb3 100644 --- a/Zend/tests/parameter_default_values/internal_declaration_error_class_const.phpt +++ b/Zend/tests/parameter_default_values/internal_declaration_error_class_const.phpt @@ -8,5 +8,6 @@ class MyDateTimeZone extends DateTimeZone { } } +?> --EXPECTF-- -Fatal error: Declaration of MyDateTimeZone::listIdentifiers() must be compatible with DateTimeZone::listIdentifiers(int $what = DateTimeZone::ALL, ?string $country = null) in %s on line %d +Fatal error: Declaration of MyDateTimeZone::listIdentifiers() must be compatible with DateTimeZone::listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null) in %s on line %d diff --git a/Zend/tests/parameter_default_values/internal_declaration_error_const.phpt b/Zend/tests/parameter_default_values/internal_declaration_error_const.phpt index 58924076e3..9335abd5d6 100644 --- a/Zend/tests/parameter_default_values/internal_declaration_error_const.phpt +++ b/Zend/tests/parameter_default_values/internal_declaration_error_const.phpt @@ -8,5 +8,6 @@ class MyDateTimeZone extends DateTimeZone { } } +?> --EXPECTF-- -Fatal error: Declaration of MyDateTimeZone::getTransitions() must be compatible with DateTimeZone::getTransitions(int $timestamp_begin = PHP_INT_MIN, int $timestamp_end = PHP_INT_MAX) in %s on line %d +Fatal error: Declaration of MyDateTimeZone::getTransitions() must be compatible with DateTimeZone::getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX) in %s on line %d diff --git a/Zend/tests/parameter_default_values/internal_declaration_error_false.phpt b/Zend/tests/parameter_default_values/internal_declaration_error_false.phpt index e7cb522c54..80c98a4052 100644 --- a/Zend/tests/parameter_default_values/internal_declaration_error_false.phpt +++ b/Zend/tests/parameter_default_values/internal_declaration_error_false.phpt @@ -7,5 +7,6 @@ interface MyDateTimeInterface extends DateTimeInterface { public function diff(); } +?> --EXPECTF-- -Fatal error: Declaration of MyDateTimeInterface::diff() must be compatible with DateTimeInterface::diff(DateTimeInterface $object, bool $absolute = false) in %s on line %d +Fatal error: Declaration of MyDateTimeInterface::diff() must be compatible with DateTimeInterface::diff(DateTimeInterface $targetObject, bool $absolute = false) in %s on line %d diff --git a/ext/date/php_date.stub.php b/ext/date/php_date.stub.php index 626906180a..dd65a65181 100644 --- a/ext/date/php_date.stub.php +++ b/ext/date/php_date.stub.php @@ -2,7 +2,7 @@ /** @generate-function-entries */ -function strtotime(string $datetime, ?int $now = null): int|false {} +function strtotime(string $datetime, ?int $baseTimestamp = null): int|false {} function date(string $format, ?int $timestamp = null): string {} @@ -62,7 +62,7 @@ function date_timezone_set(DateTimeInterface $object, DateTimeZone $timezone): D function date_offset_get(DateTimeInterface $object): int {} function date_diff( - DateTimeInterface $object1, DateTimeInterface $object2, bool $absolute = false): DateInterval {} + DateTimeInterface $baseObject, DateTimeInterface $targetObject, bool $absolute = false): DateInterval {} function date_time_set( DateTime $object, int $hour, int $minute, int $second = 0, int $microsecond = 0): DateTime {} @@ -84,7 +84,7 @@ function timezone_name_from_abbr(string $abbr, int $gmtoffset = -1, int $isdst = function timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime): int {} function timezone_transitions_get( - DateTimeZone $object, int $timestamp_begin = PHP_INT_MIN, int $timestamp_end = PHP_INT_MAX): array|false {} + DateTimeZone $object, int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX): array|false {} function timezone_location_get(DateTimeZone $object): array|false {} @@ -98,7 +98,7 @@ function date_interval_create_from_date_string(string $datetime): DateInterval|f function date_interval_format(DateInterval $object, string $format): string {} -function date_default_timezone_set(string $timezone_identifier): bool {} +function date_default_timezone_set(string $timezoneID): bool {} function date_default_timezone_get(): string {} @@ -132,7 +132,7 @@ interface DateTimeInterface public function getTimestamp(); /** @return DateInterval|false */ - public function diff(DateTimeInterface $object, bool $absolute = false); + public function diff(DateTimeInterface $targetObject, bool $absolute = false); public function __wakeup(); } @@ -221,7 +221,7 @@ class DateTime implements DateTimeInterface * @return DateTime * @alias date_isodate_set */ - public function setISODate(int $year, int $week, int $day_of_week = 1) {} + public function setISODate(int $year, int $week, int $dayOfWeek = 1) {} /** * @return DateTime @@ -239,7 +239,7 @@ class DateTime implements DateTimeInterface * @return DateInterval|false * @alias date_diff */ - public function diff(DateTimeInterface $object, bool $absolute = false) {} + public function diff(DateTimeInterface $targetObject, bool $absolute = false) {} } class DateTimeImmutable implements DateTimeInterface @@ -312,7 +312,7 @@ class DateTimeImmutable implements DateTimeInterface public function setDate(int $year, int $month, int $day) {} /** @return DateTimeImmutable */ - public function setISODate(int $year, int $week, int $day_of_week = 1) {} + public function setISODate(int $year, int $week, int $dayOfWeek = 1) {} /** @return DateTimeImmutable */ public function setTimestamp(int $timestamp) {} @@ -337,13 +337,13 @@ class DateTimeZone * @return int * @alias timezone_offset_get */ - public function getOffset(DateTimeInterface $datetime) {} + public function getOffset(DateTimeInterface $object) {} /** * @return array|false * @alias timezone_transitions_get */ - public function getTransitions(int $timestamp_begin = PHP_INT_MIN, int $timestamp_end = PHP_INT_MAX) {} + public function getTransitions(int $timestampBegin = PHP_INT_MIN, int $timestampEnd = PHP_INT_MAX) {} /** * @return array|false @@ -361,7 +361,7 @@ class DateTimeZone * @return array|false * @alias timezone_identifiers_list */ - public static function listIdentifiers(int $what = DateTimeZone::ALL, ?string $country = null) {} + public static function listIdentifiers(int $timezoneGroup = DateTimeZone::ALL, ?string $countryCode = null) {} public function __wakeup() {} @@ -371,7 +371,7 @@ class DateTimeZone class DateInterval { - public function __construct(string $interval_spec) {} + public function __construct(string $duration) {} /** * @return DateInterval|false diff --git a/ext/date/php_date_arginfo.h b/ext/date/php_date_arginfo.h index 58e0faee53..af4dabf292 100644 --- a/ext/date/php_date_arginfo.h +++ b/ext/date/php_date_arginfo.h @@ -1,9 +1,9 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: dbb98fcf9462d309d4276ba76cfbbe20172d2f30 */ + * Stub hash: 8791b7918a9d72cb4f1c1ab6703324e3c7a805c5 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_strtotime, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, datetime, IS_STRING, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, now, IS_LONG, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, baseTimestamp, IS_LONG, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date, 0, 1, IS_STRING, 0) @@ -119,8 +119,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_offset_get, 0, 1, IS_LONG, ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_date_diff, 0, 2, DateInterval, 0) - ZEND_ARG_OBJ_INFO(0, object1, DateTimeInterface, 0) - ZEND_ARG_OBJ_INFO(0, object2, DateTimeInterface, 0) + ZEND_ARG_OBJ_INFO(0, baseObject, DateTimeInterface, 0) + ZEND_ARG_OBJ_INFO(0, targetObject, DateTimeInterface, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, absolute, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -176,8 +176,8 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_timezone_transitions_get, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE) ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestamp_begin, IS_LONG, 0, "PHP_INT_MIN") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestamp_end, IS_LONG, 0, "PHP_INT_MAX") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestampBegin, IS_LONG, 0, "PHP_INT_MIN") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestampEnd, IS_LONG, 0, "PHP_INT_MAX") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_timezone_location_get, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE) @@ -205,7 +205,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_interval_format, 0, 2, IS_S ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_default_timezone_set, 0, 1, _IS_BOOL, 0) - ZEND_ARG_TYPE_INFO(0, timezone_identifier, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, timezoneID, IS_STRING, 0) ZEND_END_ARG_INFO() #define arginfo_date_default_timezone_get arginfo_timezone_version_get @@ -239,7 +239,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_DateTimeInterface_getTimestamp arginfo_class_DateTimeInterface_getTimezone ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTimeInterface_diff, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0) + ZEND_ARG_OBJ_INFO(0, targetObject, DateTimeInterface, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, absolute, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -308,7 +308,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTime_setISODate, 0, 0, 2) ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, week, IS_LONG, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, day_of_week, IS_LONG, 0, "1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, dayOfWeek, IS_LONG, 0, "1") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTime_setTimestamp, 0, 0, 1) @@ -337,7 +337,10 @@ ZEND_END_ARG_INFO() #define arginfo_class_DateTimeImmutable_getTimestamp arginfo_class_DateTimeInterface_getTimezone -#define arginfo_class_DateTimeImmutable_diff arginfo_class_DateTimeInterface_diff +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTimeImmutable_diff, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, absolute, _IS_BOOL, 0, "false") +ZEND_END_ARG_INFO() #define arginfo_class_DateTimeImmutable_modify arginfo_class_DateTime_modify @@ -370,12 +373,12 @@ ZEND_END_ARG_INFO() #define arginfo_class_DateTimeZone_getName arginfo_class_DateTimeInterface_getTimezone ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTimeZone_getOffset, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, datetime, DateTimeInterface, 0) + ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTimeZone_getTransitions, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestamp_begin, IS_LONG, 0, "PHP_INT_MIN") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestamp_end, IS_LONG, 0, "PHP_INT_MAX") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestampBegin, IS_LONG, 0, "PHP_INT_MIN") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestampEnd, IS_LONG, 0, "PHP_INT_MAX") ZEND_END_ARG_INFO() #define arginfo_class_DateTimeZone_getLocation arginfo_class_DateTimeInterface_getTimezone @@ -383,8 +386,8 @@ ZEND_END_ARG_INFO() #define arginfo_class_DateTimeZone_listAbbreviations arginfo_class_DateTimeInterface_getTimezone ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateTimeZone_listIdentifiers, 0, 0, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, what, IS_LONG, 0, "DateTimeZone::ALL") - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, country, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timezoneGroup, IS_LONG, 0, "DateTimeZone::ALL") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, countryCode, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_class_DateTimeZone___wakeup arginfo_class_DateTimeInterface_getTimezone @@ -392,7 +395,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_DateTimeZone___set_state arginfo_class_DateTime___set_state ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateInterval___construct, 0, 0, 1) - ZEND_ARG_TYPE_INFO(0, interval_spec, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, duration, IS_STRING, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_DateInterval_createFromDateString, 0, 0, 1) diff --git a/ext/date/tests/68062.phpt b/ext/date/tests/68062.phpt index 2a7c6ad61a..3a185e0c71 100644 --- a/ext/date/tests/68062.phpt +++ b/ext/date/tests/68062.phpt @@ -12,6 +12,7 @@ try { } catch (TypeError $e) { echo $e->getMessage(), "\n"; } +?> --EXPECT-- 3600 -DateTimeZone::getOffset(): Argument #1 ($datetime) must be of type DateTimeInterface, int given +DateTimeZone::getOffset(): Argument #1 ($object) must be of type DateTimeInterface, int given diff --git a/ext/date/tests/bug70245.phpt b/ext/date/tests/bug70245.phpt index 58e7f10e13..cdc9d4e37a 100644 --- a/ext/date/tests/bug70245.phpt +++ b/ext/date/tests/bug70245.phpt @@ -10,4 +10,4 @@ try { } ?> --EXPECT-- -strtotime(): Argument #2 ($now) must be of type ?int, DateTime given +strtotime(): Argument #2 ($baseTimestamp) must be of type ?int, DateTime given diff --git a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_toString_Internal.phpt b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_toString_Internal.phpt index 6c7701d5c0..5999d7f652 100644 --- a/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_toString_Internal.phpt +++ b/ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_toString_Internal.phpt @@ -24,5 +24,5 @@ Parameter #1 [ int $minute ] Parameter #2 [ int $second = 0 ] Parameter #3 [ int $microsecond = 0 ] ---------- -Parameter #0 [ int $what = DateTimeZone::ALL ] -Parameter #1 [ ?string $country = null ] +Parameter #0 [ int $timezoneGroup = DateTimeZone::ALL ] +Parameter #1 [ ?string $countryCode = null ]