]> granicus.if.org Git - php/commitdiff
Another pass of improving ext/date argument names
authorDerick Rethans <github@derickrethans.nl>
Sun, 26 Jul 2020 09:38:53 +0000 (10:38 +0100)
committerDerick Rethans <github@derickrethans.nl>
Sun, 26 Jul 2020 09:38:53 +0000 (10:38 +0100)
Zend/tests/parameter_default_values/internal_declaration_error_class_const.phpt
Zend/tests/parameter_default_values/internal_declaration_error_const.phpt
Zend/tests/parameter_default_values/internal_declaration_error_false.phpt
ext/date/php_date.stub.php
ext/date/php_date_arginfo.h
ext/date/tests/68062.phpt
ext/date/tests/bug70245.phpt
ext/reflection/tests/internal_parameter_default_value/ReflectionParameter_toString_Internal.phpt

index 2e0e6e2aea847c16970c9e9db19c9b111dfd05d4..69e7607bb350cd1ef4a1f736eb97cb5bdeaa787d 100644 (file)
@@ -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
index 58924076e314822c7e8d8cdedaa951a1943cd572..9335abd5d6a9124e7d3354572af7c79f8e886f62 100644 (file)
@@ -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
index e7cb522c54588f1be8656dc7d1e86f67c1c21ce4..80c98a405253aeca81501ac84a2bae7ac2f78db5 100644 (file)
@@ -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
index 626906180a5e2b17adc6f93f4e96573ea3e59e79..dd65a65181c7b8a3afcd51fb26d3c9247c0ba838 100644 (file)
@@ -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
index 58e0faee53178fe71235568273f7f3c0849564bd..af4dabf2921bafdf20910dc79f9eed65110a5b93 100644 (file)
@@ -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)
index 2a7c6ad61af38a38545528132576d321182f5f1e..3a185e0c7160a3d10b366cf397029c9051b0997c 100644 (file)
@@ -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
index 58e7f10e1302fd898396ad5232cdd44b58206dd5..cdc9d4e37a7c6092ee20629667fafb003858b5d1 100644 (file)
@@ -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
index 6c7701d5c07b094b9331ee4c9eac5296c95ec06b..5999d7f652c37e4cfb4771ae5edc69a5ce157cb3 100644 (file)
@@ -24,5 +24,5 @@ Parameter #1 [ <required> int $minute ]
 Parameter #2 [ <optional> int $second = 0 ]
 Parameter #3 [ <optional> int $microsecond = 0 ]
 ----------
-Parameter #0 [ <optional> int $what = DateTimeZone::ALL ]
-Parameter #1 [ <optional> ?string $country = null ]
+Parameter #0 [ <optional> int $timezoneGroup = DateTimeZone::ALL ]
+Parameter #1 [ <optional> ?string $countryCode = null ]