diff --git a/ext/com_dotnet/com_extension.stub.php b/ext/com_dotnet/com_extension.stub.php index 90c14df5bc72f..8323b0796b8b3 100644 --- a/ext/com_dotnet/com_extension.stub.php +++ b/ext/com_dotnet/com_extension.stub.php @@ -61,6 +61,7 @@ function com_create_guid(): string|false {} /** @param array|string|null $sinkinterface */ function com_event_sink(variant $comobject, object $sinkobject, $sinkinterface = UNKNOWN): bool {} +/** @param com|dotnet|variant|string $comobject */ function com_print_typeinfo($comobject, ?string $dispinterface = null, bool $wantsink = false): bool {} function com_message_pump(int $timeoutms = 0): bool {} diff --git a/ext/com_dotnet/com_extension_arginfo.h b/ext/com_dotnet/com_extension_arginfo.h index afe2f1b6add27..aec8108d8893e 100644 --- a/ext/com_dotnet/com_extension_arginfo.h +++ b/ext/com_dotnet/com_extension_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: caec4bba1103a07a86803ac0192782fef7d6680f */ + * Stub hash: 48167f9ee38966beaf550cd0a7b07d873575b48e */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_variant_set, 0, 2, IS_VOID, 0) ZEND_ARG_OBJ_INFO(0, variant, variant, 0) diff --git a/ext/date/php_date.stub.php b/ext/date/php_date.stub.php index c86b51d7cacb6..bb97cf5b86ca8 100644 --- a/ext/date/php_date.stub.php +++ b/ext/date/php_date.stub.php @@ -393,7 +393,12 @@ public static function __set_state(array $array) {} class DatePeriod implements IteratorAggregate { - /* Has an overloaded signature */ + /** + * @param DateTimeInterface|string $start + * @param DateInterval|int $interval + * @param DateTimeInterface|int $end + * @param int $options + */ public function __construct($start, $interval = UNKNOWN, $end = UNKNOWN, $options = UNKNOWN) {} /** @return DateTimeInterface */ diff --git a/ext/date/php_date_arginfo.h b/ext/date/php_date_arginfo.h index b15ff5008ceeb..bc12d852bb905 100644 --- a/ext/date/php_date_arginfo.h +++ b/ext/date/php_date_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: aa0e2c059662d4015658b85c932126b34934b5a4 */ + * Stub hash: fee95924adec03c89fdd677ec26bb6eea34d4b3c */ 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) diff --git a/ext/exif/exif.stub.php b/ext/exif/exif.stub.php index 86e4cc5258e3e..9cc099ba2a465 100644 --- a/ext/exif/exif.stub.php +++ b/ext/exif/exif.stub.php @@ -7,7 +7,12 @@ function exif_tagname(int $index): string|false {} /** @param resource|string $filename */ function exif_read_data($filename, ?string $sections_needed = null, bool $sub_arrays = false, bool $read_thumbnail = false): array|false {} -/** @param resource|string $filename */ +/** + * @param resource|string $filename + * @param int $width + * @param int $height + * @param int $imagetype + */ function exif_thumbnail($filename, &$width = null, &$height = null, &$imagetype = null): string|false {} function exif_imagetype(string $filename): int|false {} diff --git a/ext/exif/exif_arginfo.h b/ext/exif/exif_arginfo.h index 5edef59fc6db1..b16f457c56d10 100644 --- a/ext/exif/exif_arginfo.h +++ b/ext/exif/exif_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 62f6ca1a43c69d917711eae9118caf5a658722d9 */ + * Stub hash: d8cb3719a7de74b27b306c30b6be0af0647b6af4 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_exif_tagname, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, index, IS_LONG, 0) diff --git a/ext/intl/calendar/calendar.stub.php b/ext/intl/calendar/calendar.stub.php index d3a7958ee94c8..bc09ae70a37c8 100644 --- a/ext/intl/calendar/calendar.stub.php +++ b/ext/intl/calendar/calendar.stub.php @@ -235,7 +235,7 @@ public function isSet(int $field) {} * @return bool * @alias intlcal_set */ - public function set(int $year, int $month, int $dayOfMonth = UNKNOWN, $hour = UNKNOWN, int $minute = UNKNOWN, int $second = UNKNOWN) {} + public function set(int $year, int $month, int $dayOfMonth = UNKNOWN, int $hour = UNKNOWN, int $minute = UNKNOWN, int $second = UNKNOWN) {} /** * @return bool @@ -283,6 +283,14 @@ public function toDateTime() {} class IntlGregorianCalendar extends IntlCalendar { + /** + * @param DateTimeZone|IntlTimeZone|string|int|null $timeZoneOrYear + * @param string|int|null $localeOrMonth + * @param int $dayOfMonth + * @param int $hour + * @param int $minute + * @param int $second + */ public function __construct($timeZoneOrYear = UNKNOWN, $localeOrMonth = UNKNOWN, $dayOfMonth = UNKNOWN, $hour = UNKNOWN, $minute = UNKNOWN, $second = UNKNOWN) {} /** diff --git a/ext/intl/calendar/calendar_arginfo.h b/ext/intl/calendar/calendar_arginfo.h index 47ea9200fe33a..99626bd19e42c 100644 --- a/ext/intl/calendar/calendar_arginfo.h +++ b/ext/intl/calendar/calendar_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8b8a98d5035880031ac42fda5e58bde54c1d85fc */ + * Stub hash: 3facb6bdce18efae3d6b9594d1fcddfb220dd54d */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -115,7 +115,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlCalendar_set, 0, 0, 2) ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, month, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, dayOfMonth, IS_LONG, 0) - ZEND_ARG_INFO(0, hour) + ZEND_ARG_TYPE_INFO(0, hour, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, minute, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, second, IS_LONG, 0) ZEND_END_ARG_INFO() diff --git a/ext/intl/collator/collator.stub.php b/ext/intl/collator/collator.stub.php index 6e8c61c21ab81..68a7da192f450 100644 --- a/ext/intl/collator/collator.stub.php +++ b/ext/intl/collator/collator.stub.php @@ -22,7 +22,7 @@ public function compare(string $str1, string $str2) {} * @return bool * @alias collator_sort */ - public function sort(array &$arr, $sort_flag = Collator::SORT_REGULAR) {} + public function sort(array &$arr, int $sort_flag = Collator::SORT_REGULAR) {} /** * @return bool diff --git a/ext/intl/collator/collator_arginfo.h b/ext/intl/collator/collator_arginfo.h index 7d045b35a8bea..f0fd448077032 100644 --- a/ext/intl/collator/collator_arginfo.h +++ b/ext/intl/collator/collator_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 95fee5001472494653e6a83467c3c0079ea70728 */ + * Stub hash: 4cb1470cf2566c9d947be638c7d14a14a10290dd */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0) @@ -14,17 +14,14 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_sort, 0, 0, 1) ZEND_ARG_TYPE_INFO(1, arr, IS_ARRAY, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, sort_flag, "Collator::SORT_REGULAR") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, sort_flag, IS_LONG, 0, "Collator::SORT_REGULAR") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_sortWithSortKeys, 0, 0, 1) ZEND_ARG_TYPE_INFO(1, arr, IS_ARRAY, 0) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_asort, 0, 0, 1) - ZEND_ARG_TYPE_INFO(1, arr, IS_ARRAY, 0) - ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, sort_flag, IS_LONG, 0, "Collator::SORT_REGULAR") -ZEND_END_ARG_INFO() +#define arginfo_class_Collator_asort arginfo_class_Collator_sort ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Collator_getAttribute, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, attr, IS_LONG, 0) diff --git a/ext/intl/converter/converter.stub.php b/ext/intl/converter/converter.stub.php index fd6aa175b0fdb..f888a78b03601 100644 --- a/ext/intl/converter/converter.stub.php +++ b/ext/intl/converter/converter.stub.php @@ -9,7 +9,10 @@ public function __construct(?string $destination_encoding = null, ?string $sourc /** @return string|false */ public function convert(string $str, bool $reverse = false) {} - /** @return string|null */ + /** + * @param int $error + * @return string|null + */ public function fromUCallback(int $reason, array $source, int $codePoint, &$error) {} /** @return array|false|null */ @@ -54,7 +57,10 @@ public function setSourceEncoding(string $encoding) {} /** @return bool */ public function setSubstChars(string $chars) {} - /** @return string|null */ + /** + * @param int $error + * @return string|null + */ public function toUCallback(int $reason, string $source, string $codeUnits, &$error) {} /** @return string|false */ diff --git a/ext/intl/converter/converter_arginfo.h b/ext/intl/converter/converter_arginfo.h index 5a72ad68eeefd..513d8e4525841 100644 --- a/ext/intl/converter/converter_arginfo.h +++ b/ext/intl/converter/converter_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 3c63c9077f864e122292eef8655489549de9277a */ + * Stub hash: 9eef3fe293c07ab77f4c8b6d8d53a3798f8a9865 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_UConverter___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, destination_encoding, IS_STRING, 1, "null") diff --git a/ext/intl/dateformat/dateformat.stub.php b/ext/intl/dateformat/dateformat.stub.php index e86c8c93ada2c..cdb5aedb03c40 100644 --- a/ext/intl/dateformat/dateformat.stub.php +++ b/ext/intl/dateformat/dateformat.stub.php @@ -114,12 +114,14 @@ public function format($value) {} public static function formatObject($object, $format = null, ?string $locale = null) {} /** + * @param int $position * @return int|float|false * @alias datefmt_parse */ public function parse(string $value, &$position = null) {} /** + * @param int $position * @return array|false * @alias datefmt_localtime */ diff --git a/ext/intl/dateformat/dateformat_arginfo.h b/ext/intl/dateformat/dateformat_arginfo.h index 0dadfd9dd06d6..ae128d8bf9696 100644 --- a/ext/intl/dateformat/dateformat_arginfo.h +++ b/ext/intl/dateformat/dateformat_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 86faf2e51b67db2801ce691d4d24bfdae5feb6fc */ + * Stub hash: e98080c0b9107da6a2bf3ce99929554eb9a3c70e */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlDateFormatter___construct, 0, 0, 3) ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 1) diff --git a/ext/intl/formatter/formatter.stub.php b/ext/intl/formatter/formatter.stub.php index 2d5dc119666a5..4608c1917d57d 100644 --- a/ext/intl/formatter/formatter.stub.php +++ b/ext/intl/formatter/formatter.stub.php @@ -19,6 +19,7 @@ public static function create(string $locale, int $style, string $pattern = "") public function format(int|float $value, int $type = NumberFormatter::TYPE_DEFAULT) {} /** + * @param int $position * @return int|float|false * @alias numfmt_parse */ @@ -31,6 +32,8 @@ public function parse(string $value, int $type = NumberFormatter::TYPE_DOUBLE, & public function formatCurrency(float $value, string $currency) {} /** + * @param string $currency + * @param int $position * @return float|false * @alias numfmt_parse_currency */ diff --git a/ext/intl/formatter/formatter_arginfo.h b/ext/intl/formatter/formatter_arginfo.h index 051a98f941e97..ffc4eb5018646 100644 --- a/ext/intl/formatter/formatter_arginfo.h +++ b/ext/intl/formatter/formatter_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 3ff6f141d025bccb37ff597089f00bcc72462627 */ + * Stub hash: 041569278b83b65f67fb4848d00d5423e6728165 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_NumberFormatter___construct, 0, 0, 2) ZEND_ARG_TYPE_INFO(0, locale, IS_STRING, 0) diff --git a/ext/intl/php_intl.stub.php b/ext/intl/php_intl.stub.php index bbb09d03c8d28..8cb198e7d678c 100644 --- a/ext/intl/php_intl.stub.php +++ b/ext/intl/php_intl.stub.php @@ -98,7 +98,14 @@ function intlcal_get_error_code(IntlCalendar $calendar): int|false {} function intlcal_get_error_message(IntlCalendar $calendar): string|false {} -/** @param IntlTimeZone|DateTimeZone|string|null $timeZone */ +/** + * @param DateTimeZone|IntlTimeZone|string|int|null $timeZoneOrYear + * @param string|int|null $localeOrMonth + * @param int $dayOfMonth + * @param int $hour + * @param int $minute + * @param int $second + */ function intlgregcal_create_instance($timeZoneOrYear = UNKNOWN, $localeOrMonth = UNKNOWN, $dayOfMonth = UNKNOWN, $hour = UNKNOWN, $minute = UNKNOWN, $second = UNKNOWN): ?IntlGregorianCalendar {} function intlgregcal_set_gregorian_change(IntlGregorianCalendar $calendar, float $change): bool {} @@ -393,6 +400,10 @@ function intltz_get_gmt(): IntlTimeZone {} function intltz_get_id(IntlTimeZone $tz): string|false {} +/** + * @param int $rawOffset + * @param int $dstOffset + */ function intltz_get_offset(IntlTimeZone $tz, float $date, bool $local, &$rawOffset, &$dstOffset): bool {} function intltz_get_raw_offset(IntlTimeZone $tz): int {} diff --git a/ext/intl/php_intl_arginfo.h b/ext/intl/php_intl_arginfo.h index 93dcec79e38a5..d66163c1b5087 100644 --- a/ext/intl/php_intl_arginfo.h +++ b/ext/intl/php_intl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: ef46b927a82d0bdecea9438ff6ba0000b73b3b56 */ + * Stub hash: 57c63e06f2c6cf6c58a63081f19fe3e6d6901e88 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_intlcal_create_instance, 0, 0, IntlCalendar, 1) ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, timeZone, "null") diff --git a/ext/intl/spoofchecker/spoofchecker.stub.php b/ext/intl/spoofchecker/spoofchecker.stub.php index 82b749b1eb77f..b3f71599796ef 100644 --- a/ext/intl/spoofchecker/spoofchecker.stub.php +++ b/ext/intl/spoofchecker/spoofchecker.stub.php @@ -6,10 +6,16 @@ class Spoofchecker { public function __construct() {} - /** @return bool */ + /** + * @param int $error + * @return bool + */ public function isSuspicious(string $text, &$error = null) {} - /** @return bool */ + /** + * @param int $error + * @return bool + */ public function areConfusable(string $s1, string $s2, &$error = null) {} /** @return void */ diff --git a/ext/intl/spoofchecker/spoofchecker_arginfo.h b/ext/intl/spoofchecker/spoofchecker_arginfo.h index 26ca66080a7e0..925195fcda3ff 100644 --- a/ext/intl/spoofchecker/spoofchecker_arginfo.h +++ b/ext/intl/spoofchecker/spoofchecker_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: dbcdb94753d19921594c48a735d6bd9194b02996 */ + * Stub hash: 5f4ea7ab66c1748a8de076fca4b62a7d0a235598 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Spoofchecker___construct, 0, 0, 0) ZEND_END_ARG_INFO() diff --git a/ext/intl/timezone/timezone.stub.php b/ext/intl/timezone/timezone.stub.php index e470ee844052d..5e6208bb73f15 100644 --- a/ext/intl/timezone/timezone.stub.php +++ b/ext/intl/timezone/timezone.stub.php @@ -44,6 +44,7 @@ public static function createTimeZoneIDEnumeration(int $zoneType, ?string $regio public static function fromDateTimeZone(DateTimeZone $zone) {} /** + * @param bool $isSystemID * @return string|false * @alias intltz_get_canonical_id */ @@ -92,6 +93,8 @@ public static function getGMT() {} public function getID() {} /** + * @param int $rawOffset + * @param int $dstOffset * @return bool * @alias intltz_get_offset */ diff --git a/ext/intl/timezone/timezone_arginfo.h b/ext/intl/timezone/timezone_arginfo.h index 494c46391b5dd..b21975eed4531 100644 --- a/ext/intl/timezone/timezone_arginfo.h +++ b/ext/intl/timezone/timezone_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: df98b2edbdf806c52a9c165b52124b6b0de7acb2 */ + * Stub hash: 94e3c8228a0625a2c5825b0747fb1e5e08808b50 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlTimeZone___construct, 0, 0, 0) ZEND_END_ARG_INFO() diff --git a/ext/intl/uchar/uchar.stub.php b/ext/intl/uchar/uchar.stub.php index a01552f8c9425..6f793a61477eb 100644 --- a/ext/intl/uchar/uchar.stub.php +++ b/ext/intl/uchar/uchar.stub.php @@ -47,7 +47,7 @@ public static function enumCharTypes(callable $callback) {} public static function foldCase(int|string $codepoint, int $options = IntlChar::FOLD_CASE_DEFAULT) {} /** @return int */ - public static function forDigit(int $digit, $radix = 10) {} + public static function forDigit(int $digit, int $radix = 10) {} #if U_ICU_VERSION_MAJOR_NUM >= 52 /** @return int|string|null */ diff --git a/ext/intl/uchar/uchar_arginfo.h b/ext/intl/uchar/uchar_arginfo.h index 6f0175b803e1a..3ea897c189270 100644 --- a/ext/intl/uchar/uchar_arginfo.h +++ b/ext/intl/uchar/uchar_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 2f9658fe9c23180244786ed48a5ca542b7ed95ea */ + * Stub hash: 61f9c0a6c5048d25e070379f2f98fa10f8ce25ee */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlChar_hasBinaryProperty, 0, 0, 2) ZEND_ARG_TYPE_MASK(0, codepoint, MAY_BE_LONG|MAY_BE_STRING, NULL) @@ -53,7 +53,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_IntlChar_forDigit, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, digit, IS_LONG, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, radix, "10") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, radix, IS_LONG, 0, "10") ZEND_END_ARG_INFO() #if U_ICU_VERSION_MAJOR_NUM >= 52 diff --git a/ext/ldap/ldap.stub.php b/ext/ldap/ldap.stub.php index 9739ce59c293d..d8851b3314129 100644 --- a/ext/ldap/ldap.stub.php +++ b/ext/ldap/ldap.stub.php @@ -267,6 +267,11 @@ function ldap_parse_reference($link, $entry, &$referrals): bool {} /** * @param resource $link * @param resource $result + * @param int $errcode + * @param string $matcheddn + * @param string $errmsg + * @param array $referrals + * @param array $serverctrls */ function ldap_parse_result($link, $result, &$errcode, &$matcheddn = null, &$errmsg = null, &$referrals = null, &$serverctrls = null): bool {} #endif diff --git a/ext/ldap/ldap_arginfo.h b/ext/ldap/ldap_arginfo.h index 94a64918c776e..078fe220cd4fe 100644 --- a/ext/ldap/ldap_arginfo.h +++ b/ext/ldap/ldap_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: fb889b72e823f3033a54209059f8c6803961cef3 */ + * Stub hash: 6b5e8ddfbdc436fab3a263d6922146ca7c2f3845 */ #if defined(HAVE_ORALDAP) ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0) diff --git a/ext/mysqli/mysqli.stub.php b/ext/mysqli/mysqli.stub.php index 84d95b24d7012..7f6bdf880b93c 100644 --- a/ext/mysqli/mysqli.stub.php +++ b/ext/mysqli/mysqli.stub.php @@ -415,7 +415,7 @@ public function bind_param(string $types, mixed &...$vars) {} * @return bool * @alias mysqli_stmt_bind_result */ - public function bind_result(&...$vars) {} + public function bind_result(mixed &...$vars) {} /** * @return bool diff --git a/ext/mysqli/mysqli_arginfo.h b/ext/mysqli/mysqli_arginfo.h index 28145d146089f..8f82ead3ed899 100644 --- a/ext/mysqli/mysqli_arginfo.h +++ b/ext/mysqli/mysqli_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 0fb73727b9ca9f4fa9827fecd948b60948ddc423 */ + * Stub hash: 9f7063a0495441cb184f15b895771a32e8ef3195 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING) ZEND_ARG_OBJ_INFO(0, mysql_link, mysqli, 0) @@ -641,7 +641,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_stmt_bind_param, 0, 0, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_mysqli_stmt_bind_result, 0, 0, 0) - ZEND_ARG_VARIADIC_INFO(1, vars) + ZEND_ARG_VARIADIC_TYPE_INFO(1, vars, IS_MIXED, 0) ZEND_END_ARG_INFO() #define arginfo_class_mysqli_stmt_close arginfo_class_mysqli_character_set_name diff --git a/ext/pcntl/pcntl.stub.php b/ext/pcntl/pcntl.stub.php index 3c1fd97968a8f..0c56b04966543 100644 --- a/ext/pcntl/pcntl.stub.php +++ b/ext/pcntl/pcntl.stub.php @@ -4,10 +4,16 @@ function pcntl_fork(): int {} -/** @param int $status */ +/** + * @param int $status + * @param array $rusage + */ function pcntl_waitpid(int $pid, &$status, int $options = 0, &$rusage = []): int {} -/** @param int $status */ +/** + * @param int $status + * @param array $rusage + */ function pcntl_wait(&$status, int $options = 0, &$rusage = []): int {} /** @param callable|int $handler */ diff --git a/ext/pcntl/pcntl_arginfo.h b/ext/pcntl/pcntl_arginfo.h index 6e67d4613d59c..4c34a762c81e8 100644 --- a/ext/pcntl/pcntl_arginfo.h +++ b/ext/pcntl/pcntl_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 243017c5440bff0b3ee3296705d8455d0fac5b7e */ + * Stub hash: df744f88533ce9b84864fa2aa4dd7a5b7373231d */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pcntl_fork, 0, 0, IS_LONG, 0) ZEND_END_ARG_INFO() diff --git a/ext/pdo/pdo_dbh.stub.php b/ext/pdo/pdo_dbh.stub.php index bde46dd712e2f..a35e34e098a2d 100644 --- a/ext/pdo/pdo_dbh.stub.php +++ b/ext/pdo/pdo_dbh.stub.php @@ -37,7 +37,7 @@ public function lastInsertId(?string $name = null) {} public function prepare(string $statement, array $driver_options = []) {} /** @return PDOStatement|false */ - public function query(string $statement, ?int $fetch_mode = null, ...$fetch_mode_args) {} + public function query(string $statement, ?int $fetch_mode = null, mixed ...$fetch_mode_args) {} /** @return string|false */ public function quote(string $string, int $parameter_type = PDO::PARAM_STR) {} diff --git a/ext/pdo/pdo_dbh_arginfo.h b/ext/pdo/pdo_dbh_arginfo.h index 1057c54665274..b5cf1d81d0e78 100644 --- a/ext/pdo/pdo_dbh_arginfo.h +++ b/ext/pdo/pdo_dbh_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 36270d1418fc4ddd8f79018372b0ef00fb6f5889 */ + * Stub hash: 623f0a96bc1ae5eadcac5ba92eb73189cd3230cd */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, dsn, IS_STRING, 0) @@ -41,7 +41,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_query, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, statement, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fetch_mode, IS_LONG, 1, "null") - ZEND_ARG_VARIADIC_INFO(0, fetch_mode_args) + ZEND_ARG_VARIADIC_TYPE_INFO(0, fetch_mode_args, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDO_quote, 0, 0, 1) diff --git a/ext/pdo/pdo_stmt.stub.php b/ext/pdo/pdo_stmt.stub.php index bab620d627c80..d34607de8c1a8 100644 --- a/ext/pdo/pdo_stmt.stub.php +++ b/ext/pdo/pdo_stmt.stub.php @@ -4,17 +4,11 @@ class PDOStatement implements IteratorAggregate { - /** - * @param mixed $driverdata - * @return bool - */ - public function bindColumn(int|string $column, &$param, int $type = 0, int $maxlen = 0, $driverdata = null) {} + /** @return bool */ + public function bindColumn(int|string $column, &$param, int $type = 0, int $maxlen = 0, mixed $driverdata = null) {} - /** - * @param mixed $driver_options - * @return bool - */ - public function bindParam(int|string $parameter, &$param, int $type = PDO::PARAM_STR, int $maxlen = 0, $driverdata = null) {} + /** @return bool */ + public function bindParam(int|string $parameter, &$param, int $type = PDO::PARAM_STR, int $maxlen = 0, mixed $driverdata = null) {} /** * @param int|string $parameter @@ -75,7 +69,7 @@ public function rowCount() {} public function setAttribute(int $attribute, $value) {} /** @return bool */ - public function setFetchMode(int $mode, ...$params) {} + public function setFetchMode(int $mode, mixed ...$params) {} public function getIterator(): Iterator {} } diff --git a/ext/pdo/pdo_stmt_arginfo.h b/ext/pdo/pdo_stmt_arginfo.h index aa9227d83bab8..517c15b61471a 100644 --- a/ext/pdo/pdo_stmt_arginfo.h +++ b/ext/pdo/pdo_stmt_arginfo.h @@ -1,12 +1,12 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 590a642abbc8d54be143a1c595e9e704888e9b5f */ + * Stub hash: 1802a0ceaa7be9a7644d1b943d2b7d70be23ec75 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindColumn, 0, 0, 2) ZEND_ARG_TYPE_MASK(0, column, MAY_BE_LONG|MAY_BE_STRING, NULL) ZEND_ARG_INFO(1, param) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "0") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxlen, IS_LONG, 0, "0") - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, driverdata, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, driverdata, IS_MIXED, 0, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindParam, 0, 0, 2) @@ -14,7 +14,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindParam, 0, 0, 2) ZEND_ARG_INFO(1, param) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_LONG, 0, "PDO::PARAM_STR") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxlen, IS_LONG, 0, "0") - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, driverdata, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, driverdata, IS_MIXED, 0, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_bindValue, 0, 0, 2) @@ -78,7 +78,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PDOStatement_setFetchMode, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0) - ZEND_ARG_VARIADIC_INFO(0, params) + ZEND_ARG_VARIADIC_TYPE_INFO(0, params, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_PDOStatement_getIterator, 0, 0, Iterator, 0) diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 61a6473aca066..97be3e900c117 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -537,7 +537,9 @@ finish: ; */ PHP_METHOD(Phar, webPhar) { - zval *mimeoverride = NULL, *rewrite = NULL; + zval *mimeoverride = NULL; + zend_fcall_info rewrite_fci = {0}; + zend_fcall_info_cache rewrite_fcc; char *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL; size_t alias_len = 0, f404_len = 0, free_pathinfo = 0; size_t ru_len = 0; @@ -550,7 +552,7 @@ PHP_METHOD(Phar, webPhar) phar_entry_info *info = NULL; size_t sapi_mod_name_len = strlen(sapi_module.name); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!saz", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!saf!", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite_fci, &rewrite_fcc) == FAILURE) { RETURN_THROWS(); } @@ -668,38 +670,23 @@ PHP_METHOD(Phar, webPhar) not_cgi = 1; } - if (rewrite) { - zend_fcall_info fci; - zend_fcall_info_cache fcc; + if (ZEND_FCI_INITIALIZED(rewrite_fci)) { zval params, retval; ZVAL_STRINGL(¶ms, entry, entry_len); - if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL)) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: invalid rewrite callback"); + rewrite_fci.param_count = 1; + rewrite_fci.params = ¶ms; + rewrite_fci.retval = &retval; -cleanup_fail: - zval_ptr_dtor(¶ms); - if (free_pathinfo) { - efree(path_info); - } - efree(entry); - efree(pt); - RETURN_THROWS(); - } - - fci.param_count = 1; - fci.params = ¶ms; - fci.retval = &retval; - - if (FAILURE == zend_call_function(&fci, &fcc)) { + if (FAILURE == zend_call_function(&rewrite_fci, &rewrite_fcc)) { if (!EG(exception)) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: failed to call rewrite callback"); } goto cleanup_fail; } - if (Z_TYPE_P(fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) { + if (Z_TYPE_P(rewrite_fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); goto cleanup_fail; } @@ -707,8 +694,8 @@ PHP_METHOD(Phar, webPhar) switch (Z_TYPE(retval)) { case IS_STRING: efree(entry); - entry = estrndup(Z_STRVAL_P(fci.retval), Z_STRLEN_P(fci.retval)); - entry_len = Z_STRLEN_P(fci.retval); + entry = estrndup(Z_STRVAL_P(rewrite_fci.retval), Z_STRLEN_P(rewrite_fci.retval)); + entry_len = Z_STRLEN_P(rewrite_fci.retval); break; case IS_TRUE: case IS_FALSE: @@ -723,7 +710,15 @@ PHP_METHOD(Phar, webPhar) return; default: zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); - goto cleanup_fail; + +cleanup_fail: + zval_ptr_dtor(¶ms); + if (free_pathinfo) { + efree(path_info); + } + efree(entry); + efree(pt); + RETURN_THROWS(); } } @@ -1703,6 +1698,10 @@ PHP_METHOD(Phar, buildFromDirectory) zval arg, arg2, iter, iteriter, regexiter; struct _phar_t pass; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) { + RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { @@ -1711,10 +1710,6 @@ PHP_METHOD(Phar, buildFromDirectory) RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, ®ex, ®ex_len) == FAILURE) { - RETURN_THROWS(); - } - if (ZEND_SIZE_T_UINT_OVFL(dir_len)) { RETURN_FALSE; } @@ -1838,6 +1833,10 @@ PHP_METHOD(Phar, buildFromIterator) char *base = NULL; struct _phar_t pass; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s", &obj, zend_ce_traversable, &base, &base_len) == FAILURE) { + RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { @@ -1846,10 +1845,6 @@ PHP_METHOD(Phar, buildFromIterator) RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s", &obj, zend_ce_traversable, &base, &base_len) == FAILURE) { - RETURN_THROWS(); - } - if (ZEND_SIZE_T_UINT_OVFL(base_len)) { RETURN_FALSE; } @@ -1891,12 +1886,13 @@ PHP_METHOD(Phar, count) { /* mode can be ignored, maximum depth is 1 */ zend_long mode; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &mode) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + RETURN_LONG(zend_hash_num_elements(&phar_obj->archive->manifest)); } /* }}} */ @@ -1907,12 +1903,13 @@ PHP_METHOD(Phar, count) PHP_METHOD(Phar, isFileFormat) { zend_long type; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &type) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + switch (type) { case PHAR_FORMAT_TAR: RETURN_BOOL(phar_obj->archive->is_tar); @@ -2341,12 +2338,13 @@ PHP_METHOD(Phar, convertToExecutable) zend_object *ret; /* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */ zend_long format = 9021976, method = 9021976; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls", &format, &method, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (PHAR_G(readonly)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot write out executable phar archive, phar is read-only"); @@ -2444,12 +2442,13 @@ PHP_METHOD(Phar, convertToData) zend_object *ret; /* a number that is not 0, 1 or 2 (Which is also Greg's birthday so there) */ zend_long format = 9021976, method = 9021976; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls", &format, &method, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + switch (format) { case 9021976: case PHAR_FORMAT_SAME: /* null is converted to 0 */ @@ -2538,12 +2537,12 @@ PHP_METHOD(Phar, convertToData) */ PHP_METHOD(Phar, isCompressed) { - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (phar_obj->archive->flags & PHAR_FILE_COMPRESSED_GZ) { RETURN_LONG(PHAR_ENT_COMPRESSED_GZ); } @@ -2560,12 +2559,13 @@ PHP_METHOD(Phar, isCompressed) PHP_METHOD(Phar, isWritable) { php_stream_statbuf ssb; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (!phar_obj->archive->is_writeable) { RETURN_FALSE; } @@ -2589,6 +2589,11 @@ PHP_METHOD(Phar, delete) size_t fname_len; char *error; phar_entry_info *entry; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { + RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { @@ -2597,10 +2602,6 @@ PHP_METHOD(Phar, delete) RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { - RETURN_THROWS(); - } - if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); @@ -2635,12 +2636,12 @@ PHP_METHOD(Phar, delete) /* {{{ Returns the alias for the Phar or NULL. */ PHP_METHOD(Phar, getAlias) { - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (phar_obj->archive->alias && phar_obj->archive->alias != phar_obj->archive->fname) { RETURN_STRINGL(phar_obj->archive->alias, phar_obj->archive->alias_len); } @@ -2650,12 +2651,12 @@ PHP_METHOD(Phar, getAlias) /* {{{ Returns the real path to the phar archive on disk */ PHP_METHOD(Phar, getPath) { - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + RETURN_STRINGL(phar_obj->archive->fname, phar_obj->archive->fname_len); } /* }}} */ @@ -2670,6 +2671,10 @@ PHP_METHOD(Phar, setAlias) size_t alias_len, oldalias_len; int old_temp, readd = 0; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &alias, &alias_len) == FAILURE) { + RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { @@ -2693,83 +2698,79 @@ PHP_METHOD(Phar, setAlias) RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &alias, &alias_len) == SUCCESS) { - if (alias_len == phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) { - RETURN_TRUE; - } - if (alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { - spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", alias, fd_ptr->fname); - if (SUCCESS == phar_free_alias(fd_ptr, alias, alias_len)) { - efree(error); - goto valid_alias; - } - zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); + if (alias_len == phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) { + RETURN_TRUE; + } + if (alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { + spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", alias, fd_ptr->fname); + if (SUCCESS == phar_free_alias(fd_ptr, alias, alias_len)) { efree(error); - RETURN_THROWS(); - } - if (!phar_validate_alias(alias, alias_len)) { - zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, - "Invalid alias \"%s\" specified for phar \"%s\"", alias, phar_obj->archive->fname); - RETURN_THROWS(); + goto valid_alias; } + zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); + efree(error); + RETURN_THROWS(); + } + if (!phar_validate_alias(alias, alias_len)) { + zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, + "Invalid alias \"%s\" specified for phar \"%s\"", alias, phar_obj->archive->fname); + RETURN_THROWS(); + } valid_alias: - if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { - zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); - RETURN_THROWS(); - } - if (phar_obj->archive->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len))) { - zend_hash_str_del(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len); - readd = 1; - } + if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { + zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); + RETURN_THROWS(); + } + if (phar_obj->archive->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len))) { + zend_hash_str_del(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len); + readd = 1; + } - oldalias = phar_obj->archive->alias; - oldalias_len = phar_obj->archive->alias_len; - old_temp = phar_obj->archive->is_temporary_alias; + oldalias = phar_obj->archive->alias; + oldalias_len = phar_obj->archive->alias_len; + old_temp = phar_obj->archive->is_temporary_alias; - if (alias_len) { - phar_obj->archive->alias = estrndup(alias, alias_len); - } else { - phar_obj->archive->alias = NULL; - } + if (alias_len) { + phar_obj->archive->alias = estrndup(alias, alias_len); + } else { + phar_obj->archive->alias = NULL; + } - phar_obj->archive->alias_len = alias_len; - phar_obj->archive->is_temporary_alias = 0; - phar_flush(phar_obj->archive, NULL, 0, 0, &error); + phar_obj->archive->alias_len = alias_len; + phar_obj->archive->is_temporary_alias = 0; + phar_flush(phar_obj->archive, NULL, 0, 0, &error); - if (error) { - phar_obj->archive->alias = oldalias; - phar_obj->archive->alias_len = oldalias_len; - phar_obj->archive->is_temporary_alias = old_temp; - zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); - if (readd) { - zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), oldalias, oldalias_len, phar_obj->archive); - } - efree(error); - RETURN_THROWS(); + if (error) { + phar_obj->archive->alias = oldalias; + phar_obj->archive->alias_len = oldalias_len; + phar_obj->archive->is_temporary_alias = old_temp; + zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); + if (readd) { + zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), oldalias, oldalias_len, phar_obj->archive); } + efree(error); + RETURN_THROWS(); + } - zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, phar_obj->archive); - - if (oldalias) { - efree(oldalias); - } + zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, phar_obj->archive); - RETURN_TRUE; + if (oldalias) { + efree(oldalias); } - RETURN_FALSE; + RETURN_TRUE; } /* }}} */ /* {{{ Return version info of Phar archive */ PHP_METHOD(Phar, getVersion) { - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + RETURN_STRING(phar_obj->archive->version); } /* }}} */ @@ -2777,12 +2778,12 @@ PHP_METHOD(Phar, getVersion) /* {{{ Do not flush a writeable phar (save its contents) until explicitly requested */ PHP_METHOD(Phar, startBuffering) { - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + phar_obj->archive->donotflush = 1; } /* }}} */ @@ -2790,12 +2791,12 @@ PHP_METHOD(Phar, startBuffering) /* {{{ Returns whether write operations are flushing to disk immediately. */ PHP_METHOD(Phar, isBuffering) { - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + RETURN_BOOL(phar_obj->archive->donotflush); } /* }}} */ @@ -2805,12 +2806,12 @@ PHP_METHOD(Phar, stopBuffering) { char *error; - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot write out phar archive, phar is read-only"); @@ -2837,6 +2838,7 @@ PHP_METHOD(Phar, setStub) size_t stub_len; zend_long len = -1; php_stream *stream; + PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { @@ -2893,7 +2895,7 @@ PHP_METHOD(Phar, setStub) RETURN_TRUE; } - RETURN_FALSE; + RETURN_THROWS(); } /* }}} */ @@ -2915,6 +2917,11 @@ PHP_METHOD(Phar, setDefaultStub) zend_string *stub = NULL; size_t index_len = 0, webindex_len = 0; int created_stub = 0; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); if (phar_obj->archive->is_data) { @@ -2928,10 +2935,6 @@ PHP_METHOD(Phar, setDefaultStub) RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s", &index, &index_len, &webindex, &webindex_len) == FAILURE) { - RETURN_THROWS(); - } - if (ZEND_NUM_ARGS() > 0 && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) { php_error_docref(NULL, E_WARNING, "Method accepts no arguments for a tar- or zip-based phar stub, %d given", ZEND_NUM_ARGS()); RETURN_FALSE; @@ -2989,6 +2992,10 @@ PHP_METHOD(Phar, setSignatureAlgorithm) char *error, *key = NULL; size_t key_len = 0; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|s", &algo, &key, &key_len) != SUCCESS) { + RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { @@ -2997,10 +3004,6 @@ PHP_METHOD(Phar, setSignatureAlgorithm) RETURN_THROWS(); } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "l|s", &algo, &key, &key_len) != SUCCESS) { - return; - } - switch (algo) { case PHAR_SIG_SHA256: case PHAR_SIG_SHA512: @@ -3032,12 +3035,12 @@ PHP_METHOD(Phar, setSignatureAlgorithm) /* {{{ Returns a hash signature, or FALSE if the archive is unsigned. */ PHP_METHOD(Phar, getSignature) { - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (phar_obj->archive->signature) { zend_string *unknown; @@ -3073,12 +3076,12 @@ PHP_METHOD(Phar, getSignature) /* {{{ Return whether phar was modified */ PHP_METHOD(Phar, getModified) { - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + RETURN_BOOL(phar_obj->archive->is_modified); } /* }}} */ @@ -3151,12 +3154,13 @@ PHP_METHOD(Phar, compress) size_t ext_len = 0; uint32_t flags; zend_object *ret; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|s", &method, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot compress phar archive, phar is read-only"); @@ -3216,12 +3220,13 @@ PHP_METHOD(Phar, decompress) char *ext = NULL; size_t ext_len = 0; zend_object *ret; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &ext, &ext_len) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot decompress phar archive, phar is read-only"); @@ -3257,12 +3262,13 @@ PHP_METHOD(Phar, compressFiles) char *error; uint32_t flags; zend_long method; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Phar is readonly, cannot change compression"); @@ -3329,12 +3335,14 @@ PHP_METHOD(Phar, compressFiles) PHP_METHOD(Phar, decompressFiles) { char *error; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); + if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Phar is readonly, cannot change compression"); @@ -3378,11 +3386,12 @@ PHP_METHOD(Phar, copy) phar_entry_info *oldentry, newentry = {0}, *temp; size_t tmp_len = 0; - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { RETURN_THROWS(); } + + PHAR_ARCHIVE_OBJECT(); + if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot copy \"%s\" to \"%s\", phar is read-only", oldfile, newfile); @@ -3472,12 +3481,12 @@ PHP_METHOD(Phar, offsetExists) size_t fname_len; phar_entry_info *entry; - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (zend_hash_str_exists(&phar_obj->archive->manifest, fname, (uint32_t) fname_len)) { if (NULL != (entry = zend_hash_str_find_ptr(&phar_obj->archive->manifest, fname, (uint32_t) fname_len))) { if (entry->is_deleted) { @@ -3508,12 +3517,13 @@ PHP_METHOD(Phar, offsetGet) zval zfname; phar_entry_info *entry; zend_string *sfname; - PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + /* security is 0 here so that we can get a better error message than "entry doesn't exist" */ if (!(entry = phar_get_entry_info_dir(phar_obj->archive, fname, fname_len, 1, &error, 0))) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Entry %s does not exist%s%s", fname, error?", ":"", error?error:""); @@ -3682,6 +3692,12 @@ PHP_METHOD(Phar, offsetSet) char *fname, *cont_str = NULL; size_t fname_len, cont_len; zval *zresource; + + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { @@ -3689,10 +3705,6 @@ PHP_METHOD(Phar, offsetSet) RETURN_THROWS(); } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { - RETURN_THROWS(); - } if (fname_len == sizeof(".phar/stub.php")-1 && !memcmp(fname, ".phar/stub.php", sizeof(".phar/stub.php")-1)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot set stub \".phar/stub.php\" directly in phar \"%s\", use setStub", phar_obj->archive->fname); RETURN_THROWS(); @@ -3718,14 +3730,15 @@ PHP_METHOD(Phar, offsetUnset) char *fname, *error; size_t fname_len; phar_entry_info *entry; - PHAR_ARCHIVE_OBJECT(); - if (PHAR_G(readonly) && !phar_obj->archive->is_data) { - zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly"); + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { + PHAR_ARCHIVE_OBJECT(); + + if (PHAR_G(readonly) && !phar_obj->archive->is_data) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly"); RETURN_THROWS(); } @@ -3768,12 +3781,12 @@ PHP_METHOD(Phar, addEmptyDir) char *dirname; size_t dirname_len; - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (dirname_len >= sizeof(".phar")-1 && !memcmp(dirname, ".phar", sizeof(".phar")-1)) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot create a directory in magic \".phar\" directory"); RETURN_THROWS(); @@ -3791,12 +3804,12 @@ PHP_METHOD(Phar, addFile) php_stream *resource; zval zresource; - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (!strstr(fname, "://") && php_check_open_basedir(fname)) { zend_throw_exception_ex(spl_ce_RuntimeException, 0, "phar error: unable to open file \"%s\" to add to phar archive, open_basedir restrictions prevent this", fname); RETURN_THROWS(); @@ -3824,12 +3837,12 @@ PHP_METHOD(Phar, addFromString) char *localname, *cont_str; size_t localname_len, cont_len; - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + phar_add_file(&(phar_obj->archive), localname, localname_len, cont_str, cont_len, NULL); } /* }}} */ @@ -3843,12 +3856,12 @@ PHP_METHOD(Phar, getStub) php_stream_filter *filter = NULL; phar_entry_info *stub; - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + if (phar_obj->archive->is_tar || phar_obj->archive->is_zip) { if (NULL != (stub = zend_hash_str_find_ptr(&(phar_obj->archive->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) { @@ -3934,12 +3947,12 @@ PHP_METHOD(Phar, getStub) /* {{{ Returns TRUE if the phar has global metadata, FALSE otherwise. */ PHP_METHOD(Phar, hasMetadata) { - PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ARCHIVE_OBJECT(); + RETURN_BOOL(phar_metadata_tracker_has_data(&phar_obj->archive->metadata_tracker, phar_obj->archive->is_persistent)); } /* }}} */ @@ -3949,13 +3962,14 @@ PHP_METHOD(Phar, getMetadata) { HashTable *unserialize_options = NULL; phar_metadata_tracker *tracker; - PHAR_ARCHIVE_OBJECT(); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_ARRAY_HT(unserialize_options) ZEND_PARSE_PARAMETERS_END(); + PHAR_ARCHIVE_OBJECT(); + tracker = &phar_obj->archive->metadata_tracker; if (phar_metadata_tracker_has_data(tracker, phar_obj->archive->is_persistent)) { phar_metadata_tracker_unserialize_or_copy(tracker, return_value, phar_obj->archive->is_persistent, unserialize_options, "Phar::getMetadata"); @@ -4000,6 +4014,10 @@ PHP_METHOD(Phar, setMetadata) char *error; zval *metadata; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) { + RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { @@ -4007,10 +4025,6 @@ PHP_METHOD(Phar, setMetadata) RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) { - RETURN_THROWS(); - } - if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); RETURN_THROWS(); @@ -4036,6 +4050,10 @@ PHP_METHOD(Phar, delMetadata) { char *error; + if (zend_parse_parameters_none() == FAILURE) { + RETURN_THROWS(); + } + PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { @@ -4043,10 +4061,6 @@ PHP_METHOD(Phar, delMetadata) RETURN_THROWS(); } - if (zend_parse_parameters_none() == FAILURE) { - RETURN_THROWS(); - } - if (!phar_metadata_tracker_has_data(&phar_obj->archive->metadata_tracker, phar_obj->archive->is_persistent)) { RETURN_TRUE; } @@ -4282,19 +4296,22 @@ PHP_METHOD(Phar, extractTo) php_stream *fp; php_stream_statbuf ssb; char *pathto; - zend_string *filename; + zend_string *filename = NULL; size_t pathto_len; int ret; zval *zval_file; - zval *zval_files = NULL; + HashTable *files_ht = NULL; zend_bool overwrite = 0; char *error = NULL; - PHAR_ARCHIVE_OBJECT(); + ZEND_PARSE_PARAMETERS_START(1, 3) + Z_PARAM_PATH(pathto, pathto_len) + Z_PARAM_OPTIONAL + Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(filename, files_ht) + Z_PARAM_BOOL(overwrite) + ZEND_PARSE_PARAMETERS_END(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { - RETURN_THROWS(); - } + PHAR_ARCHIVE_OBJECT(); fp = php_stream_open_wrapper(phar_obj->archive->fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, NULL); @@ -4333,47 +4350,32 @@ PHP_METHOD(Phar, extractTo) RETURN_THROWS(); } - if (zval_files) { - switch (Z_TYPE_P(zval_files)) { - case IS_NULL: - filename = NULL; - break; - case IS_STRING: - filename = Z_STR_P(zval_files); - break; - case IS_ARRAY: - if (zend_hash_num_elements(Z_ARRVAL_P(zval_files)) == 0) { - RETURN_FALSE; - } + if (files_ht) { + if (zend_hash_num_elements(files_ht) == 0) { + RETURN_FALSE; + } - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(zval_files), zval_file) { - ZVAL_DEREF(zval_file); - if (IS_STRING != Z_TYPE_P(zval_file)) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, - "Invalid argument, array of filenames to extract contains non-string value"); - RETURN_THROWS(); - } - switch (extract_helper(phar_obj->archive, Z_STR_P(zval_file), pathto, pathto_len, overwrite, &error)) { - case -1: - zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%s\" failed: %s", - phar_obj->archive->fname, error); - efree(error); - RETURN_THROWS(); - case 0: - zend_throw_exception_ex(phar_ce_PharException, 0, - "phar error: attempted to extract non-existent file or directory \"%s\" from phar \"%s\"", - ZSTR_VAL(Z_STR_P(zval_file)), phar_obj->archive->fname); - RETURN_THROWS(); - } - } ZEND_HASH_FOREACH_END(); - RETURN_TRUE; - default: + ZEND_HASH_FOREACH_VAL(files_ht, zval_file) { + ZVAL_DEREF(zval_file); + if (IS_STRING != Z_TYPE_P(zval_file)) { zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, - "Invalid argument, expected a filename (string) or array of filenames"); + "Invalid argument, array of filenames to extract contains non-string value"); RETURN_THROWS(); - } - } else { - filename = NULL; + } + switch (extract_helper(phar_obj->archive, Z_STR_P(zval_file), pathto, pathto_len, overwrite, &error)) { + case -1: + zend_throw_exception_ex(phar_ce_PharException, 0, "Extraction from phar \"%s\" failed: %s", + phar_obj->archive->fname, error); + efree(error); + RETURN_THROWS(); + case 0: + zend_throw_exception_ex(phar_ce_PharException, 0, + "phar error: attempted to extract non-existent file or directory \"%s\" from phar \"%s\"", + ZSTR_VAL(Z_STR_P(zval_file)), phar_obj->archive->fname); + RETURN_THROWS(); + } + } ZEND_HASH_FOREACH_END(); + RETURN_TRUE; } ret = extract_helper(phar_obj->archive, filename, pathto, pathto_len, overwrite, &error); @@ -4490,12 +4492,12 @@ PHP_METHOD(PharFileInfo, __destruct) /* {{{ Returns the compressed size */ PHP_METHOD(PharFileInfo, getCompressedSize) { - PHAR_ENTRY_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + RETURN_LONG(entry_obj->entry->compressed_filesize); } /* }}} */ @@ -4505,12 +4507,13 @@ PHP_METHOD(PharFileInfo, isCompressed) { /* a number that is not Phar::GZ or Phar::BZ2 */ zend_long method = 9021976; - PHAR_ENTRY_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &method) == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + switch (method) { case 9021976: RETURN_BOOL(entry_obj->entry->flags & PHAR_ENT_COMPRESSION_MASK); @@ -4528,12 +4531,12 @@ PHP_METHOD(PharFileInfo, isCompressed) /* {{{ Returns CRC32 code or throws an exception if not CRC checked */ PHP_METHOD(PharFileInfo, getCRC32) { - PHAR_ENTRY_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + if (entry_obj->entry->is_dir) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \ "Phar entry is a directory, does not have a CRC"); \ @@ -4552,12 +4555,12 @@ PHP_METHOD(PharFileInfo, getCRC32) /* {{{ Returns whether file entry is CRC checked */ PHP_METHOD(PharFileInfo, isCRCChecked) { - PHAR_ENTRY_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + RETURN_BOOL(entry_obj->entry->is_crc_checked); } /* }}} */ @@ -4565,12 +4568,12 @@ PHP_METHOD(PharFileInfo, isCRCChecked) /* {{{ Returns the Phar file entry flags */ PHP_METHOD(PharFileInfo, getPharFlags) { - PHAR_ENTRY_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + RETURN_LONG(entry_obj->entry->flags & ~(PHAR_ENT_PERM_MASK|PHAR_ENT_COMPRESSION_MASK)); } /* }}} */ @@ -4580,6 +4583,11 @@ PHP_METHOD(PharFileInfo, chmod) { char *error; zend_long perms; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &perms) == FAILURE) { + RETURN_THROWS(); + } + PHAR_ENTRY_OBJECT(); if (entry_obj->entry->is_temp_dir) { @@ -4593,10 +4601,6 @@ PHP_METHOD(PharFileInfo, chmod) RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &perms) == FAILURE) { - RETURN_THROWS(); - } - if (entry_obj->entry->is_persistent) { phar_archive_data *phar = entry_obj->entry->phar; @@ -4639,12 +4643,12 @@ PHP_METHOD(PharFileInfo, chmod) /* {{{ Returns the metadata of the entry */ PHP_METHOD(PharFileInfo, hasMetadata) { - PHAR_ENTRY_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + RETURN_BOOL(phar_metadata_tracker_has_data(&entry_obj->entry->metadata_tracker, entry_obj->entry->is_persistent)); } /* }}} */ @@ -4654,13 +4658,14 @@ PHP_METHOD(PharFileInfo, getMetadata) { HashTable *unserialize_options = NULL; phar_metadata_tracker *tracker; - PHAR_ENTRY_OBJECT(); ZEND_PARSE_PARAMETERS_START(0, 1) Z_PARAM_OPTIONAL Z_PARAM_ARRAY_HT(unserialize_options) ZEND_PARSE_PARAMETERS_END(); + PHAR_ENTRY_OBJECT(); + tracker = &entry_obj->entry->metadata_tracker; if (phar_metadata_tracker_has_data(tracker, entry_obj->entry->is_persistent)) { phar_metadata_tracker_unserialize_or_copy(tracker, return_value, entry_obj->entry->is_persistent, unserialize_options, "PharFileInfo::getMetadata"); @@ -4674,6 +4679,10 @@ PHP_METHOD(PharFileInfo, setMetadata) char *error; zval *metadata; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) { + RETURN_THROWS(); + } + PHAR_ENTRY_OBJECT(); if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) { @@ -4687,10 +4696,6 @@ PHP_METHOD(PharFileInfo, setMetadata) RETURN_THROWS(); } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &metadata) == FAILURE) { - RETURN_THROWS(); - } - if (entry_obj->entry->is_persistent) { phar_archive_data *phar = entry_obj->entry->phar; @@ -4723,12 +4728,12 @@ PHP_METHOD(PharFileInfo, delMetadata) { char *error; - PHAR_ENTRY_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + if (PHAR_G(readonly) && !entry_obj->entry->phar->is_data) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Write operations disabled by the php.ini setting phar.readonly"); RETURN_THROWS(); @@ -4780,12 +4785,12 @@ PHP_METHOD(PharFileInfo, getContent) phar_entry_info *link; zend_string *str; - PHAR_ENTRY_OBJECT(); - if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + if (entry_obj->entry->is_dir) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "phar error: Cannot retrieve contents, \"%s\" in phar \"%s\" is a directory", entry_obj->entry->filename, entry_obj->entry->phar->fname); @@ -4826,12 +4831,13 @@ PHP_METHOD(PharFileInfo, compress) { zend_long method; char *error; - PHAR_ENTRY_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + if (entry_obj->entry->is_tar) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Cannot compress with Gzip compression, not possible with tar-based phar archives"); @@ -4952,12 +4958,13 @@ PHP_METHOD(PharFileInfo, decompress) { char *error; char *compression_type; - PHAR_ENTRY_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { RETURN_THROWS(); } + PHAR_ENTRY_OBJECT(); + if (entry_obj->entry->is_dir) { zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, \ "Phar entry is a directory, cannot set compression"); \ diff --git a/ext/phar/phar_object.stub.php b/ext/phar/phar_object.stub.php index fe5fed140602a..7f0eca1034f8f 100644 --- a/ext/phar/phar_object.stub.php +++ b/ext/phar/phar_object.stub.php @@ -58,7 +58,7 @@ public function delete(string $entry) {} public function delMetadata() {} /** @return bool */ - public function extractTo(string $pathto, $files = null, bool $overwrite = false) {} + public function extractTo(string $pathto, array|string|null $files = null, bool $overwrite = false) {} /** @return string|null */ public function getAlias() {} @@ -140,7 +140,7 @@ public function setSignatureAlgorithm(int $algorithm, string $privatekey = UNKNO * @param resource $newstub * @return bool */ - public function setStub($newstub, $maxlen = -1) {} + public function setStub($newstub, int $maxlen = -1) {} /** @return void */ public function startBuffering() {} @@ -180,13 +180,13 @@ final public static function unlinkArchive(string $archive): bool {} final public static function webPhar( ?string $alias = null, ?string $index = null, string $f404 = UNKNOWN, - array $mimetypes = [], $rewrites = UNKNOWN): void {} + array $mimetypes = [], ?callable $rewrites = null): void {} } class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAccess { /** @alias Phar::__construct */ - public function __construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS, ?string $alias = null, $fileformat = 0) {} + public function __construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS|FilesystemIterator::UNIX_PATHS, ?string $alias = null, int $fileformat = 0) {} /** @alias Phar::__destruct */ public function __destruct() {} @@ -285,7 +285,7 @@ public function delMetadata() {} * @return bool * @alias Phar::extractTo */ - public function extractTo(string $pathto, $files = null, bool $overwrite = false) {} + public function extractTo(string $pathto, array|string|null $files = null, bool $overwrite = false) {} /** * @return string|null @@ -418,7 +418,7 @@ public function setSignatureAlgorithm(int $algorithm, string $privatekey = UNKNO * @return bool * @alias Phar::setStub */ - public function setStub($newstub, $maxlen = -1) {} + public function setStub($newstub, int $maxlen = -1) {} /** * @return void @@ -479,7 +479,7 @@ final public static function unlinkArchive(string $archive): bool {} /** @alias Phar::webPhar */ final public static function webPhar( ?string $alias = null, ?string $index = null, string $f404 = UNKNOWN, - array $mimetypes = [], $rewrites = UNKNOWN): void {} + array $mimetypes = [], ?callable $rewrites = null): void {} } class PharFileInfo extends SplFileInfo @@ -519,11 +519,11 @@ public function getPharFlags() {} public function hasMetadata() {} /** @return bool */ - public function isCompressed($compression_type = 9021976) {} + public function isCompressed(int $compression_type = 9021976) {} /** @return bool */ public function isCRCChecked() {} /** @return void */ - public function setMetadata($metadata) {} + public function setMetadata(mixed $metadata) {} } diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index a4b446d7c5c35..67b5ba558029f 100644 --- a/ext/phar/phar_object_arginfo.h +++ b/ext/phar/phar_object_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 586c79f097e9153b70f6c6e208daa08acc0ce1d4 */ + * Stub hash: f25efd47b496a7d06a30c77911a565a49e383bce */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -74,7 +74,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_extractTo, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, pathto, IS_STRING, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, files, "null") + ZEND_ARG_TYPE_MASK(0, files, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, overwrite, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -139,7 +139,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setStub, 0, 0, 1) ZEND_ARG_INFO(0, newstub) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, maxlen, "-1") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, maxlen, IS_LONG, 0, "-1") ZEND_END_ARG_INFO() #define arginfo_class_Phar_startBuffering arginfo_class_Phar___destruct @@ -206,14 +206,14 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_webPhar, 0, 0, IS_VOI ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, index, IS_STRING, 1, "null") ZEND_ARG_TYPE_INFO(0, f404, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimetypes, IS_ARRAY, 0, "[]") - ZEND_ARG_INFO(0, rewrites) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, rewrites, IS_CALLABLE, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PharData___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, alias, IS_STRING, 1, "null") - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, fileformat, "0") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, fileformat, IS_LONG, 0, "0") ZEND_END_ARG_INFO() #define arginfo_class_PharData___destruct arginfo_class_Phar___destruct @@ -355,12 +355,14 @@ ZEND_END_ARG_INFO() #define arginfo_class_PharFileInfo_hasMetadata arginfo_class_Phar___destruct ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PharFileInfo_isCompressed, 0, 0, 0) - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, compression_type, "9021976") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, compression_type, IS_LONG, 0, "9021976") ZEND_END_ARG_INFO() #define arginfo_class_PharFileInfo_isCRCChecked arginfo_class_Phar___destruct -#define arginfo_class_PharFileInfo_setMetadata arginfo_class_Phar_setMetadata +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_PharFileInfo_setMetadata, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, metadata, IS_MIXED, 0) +ZEND_END_ARG_INFO() ZEND_METHOD(Phar, __construct); diff --git a/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc index 3c9986da00772..442f1fb18f679 100644 --- a/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc +++ b/ext/phar/tests/cache_list/files/frontcontroller16.phar.inc @@ -7,7 +7,7 @@ echo "hi"; $a->setStub('getMessage() . "\n"); } echo "oops did not run\n"; diff --git a/ext/phar/tests/cache_list/frontcontroller31.phpt b/ext/phar/tests/cache_list/frontcontroller31.phpt index 54128759f097b..897272999cff6 100644 --- a/ext/phar/tests/cache_list/frontcontroller31.phpt +++ b/ext/phar/tests/cache_list/frontcontroller31.phpt @@ -12,5 +12,9 @@ REQUEST_URI=/frontcontroller31.php Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller16.phar ---EXPECT-- -phar error: invalid rewrite callback +--EXPECTF-- +Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrites) must be a valid callback or null, class "fail" not found in %s:%d +Stack trace: +#0 %s(%d): Phar::webPhar('test.phar', '/index.php', '', Array, Array) +#1 {main} + thrown in %s on line %d diff --git a/ext/phar/tests/files/frontcontroller16.phar.inc b/ext/phar/tests/files/frontcontroller16.phar.inc index 3c9986da00772..442f1fb18f679 100644 --- a/ext/phar/tests/files/frontcontroller16.phar.inc +++ b/ext/phar/tests/files/frontcontroller16.phar.inc @@ -7,7 +7,7 @@ echo "hi"; $a->setStub('getMessage() . "\n"); } echo "oops did not run\n"; diff --git a/ext/phar/tests/frontcontroller31.phpt b/ext/phar/tests/frontcontroller31.phpt index a02c937b58da8..0554180b86bcc 100644 --- a/ext/phar/tests/frontcontroller31.phpt +++ b/ext/phar/tests/frontcontroller31.phpt @@ -11,5 +11,9 @@ REQUEST_URI=/frontcontroller31.php Content-type: text/html; charset=UTF-8 --FILE_EXTERNAL-- files/frontcontroller16.phar ---EXPECT-- -phar error: invalid rewrite callback +--EXPECTF-- +Fatal error: Uncaught TypeError: Phar::webPhar(): Argument #5 ($rewrites) must be a valid callback or null, class "fail" not found in %s:%d +Stack trace: +#0 %s(%d): Phar::webPhar('test.phar', '/index.php', '', Array, Array) +#1 {main} + thrown in %s on line %d diff --git a/ext/phar/tests/phar_buildfromiterator1.phpt b/ext/phar/tests/phar_buildfromiterator1.phpt index aac85ff33efff..c403e8c939be9 100644 --- a/ext/phar/tests/phar_buildfromiterator1.phpt +++ b/ext/phar/tests/phar_buildfromiterator1.phpt @@ -10,7 +10,8 @@ phar.readonly=0 $phar = new Phar(__DIR__ . '/buildfromiterator1.phar'); try { ini_set('phar.readonly', 1); - $phar->buildFromIterator(1); + + $phar->buildFromIterator(new ArrayIterator([])); } catch (Exception $e) { var_dump(get_class($e)); echo $e->getMessage() . "\n"; diff --git a/ext/phar/tests/phar_extract.phpt b/ext/phar/tests/phar_extract.phpt index bbe95dec0dd84..0ccd9d50d5603 100644 --- a/ext/phar/tests/phar_extract.phpt +++ b/ext/phar/tests/phar_extract.phpt @@ -45,8 +45,8 @@ var_dump(file_get_contents(__DIR__ . '/extract1-2/file2.txt')); var_dump(is_dir(__DIR__ . '/extract1-2/one/level')); try { - $a->extractTo(__DIR__ . '/whatever', 134); -} catch (Exception $e) { + $a->extractTo(__DIR__ . '/whatever', new stdClass()); +} catch (TypeError $e) { echo $e->getMessage(), "\n"; } @@ -141,7 +141,7 @@ string(2) "hi" string(3) "hi3" string(3) "hi2" bool(false) -Invalid argument, expected a filename (string) or array of filenames +Phar::extractTo(): Argument #2 ($files) must be of type string|array|null, stdClass given Phar::extractTo(): Argument #1 ($pathto) must be a valid path, array given Invalid argument, extraction path must be non-zero length Unable to use path "%soops" for extraction, it is a file, must be a directory diff --git a/ext/spl/spl_directory.stub.php b/ext/spl/spl_directory.stub.php index 513dfef8aa3a9..ce56654eb62f1 100755 --- a/ext/spl/spl_directory.stub.php +++ b/ext/spl/spl_directory.stub.php @@ -206,7 +206,7 @@ public function fgets() {} public function fread(int $length) {} /** @return array|false */ - public function fgetcsv(string $delimiter = ",", string $enclosure = '"', $escape = "\\") {} + public function fgetcsv(string $delimiter = ",", string $enclosure = '"', string $escape = "\\") {} /** @return int|false */ public function fputcsv(array $fields, string $delimiter = ',', string $enclosure = '"', string $escape = "\\") {} @@ -217,7 +217,10 @@ public function setCsvControl(string $delimiter = ",", string $enclosure = "\"", /** @return array */ public function getCsvControl() {} - /** @return bool */ + /** + * @param int $wouldblock + * @return bool + */ public function flock(int $operation, &$wouldblock = null) {} /** @return bool */ @@ -235,11 +238,8 @@ public function fgetc() {} /** @return int */ public function fpassthru() {} - /** - * @param string $format - * @return array|int - */ - public function fscanf(string $format, &...$params) {} + /** @return array|int|false|null */ + public function fscanf(string $format, mixed &...$params) {} /** @return int|false */ public function fwrite(string $str, int $length = 0) {} diff --git a/ext/spl/spl_directory_arginfo.h b/ext/spl/spl_directory_arginfo.h index 0f167f7f19df5..57b096caf71f9 100644 --- a/ext/spl/spl_directory_arginfo.h +++ b/ext/spl/spl_directory_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: d6b772ea08c57acdea65e983098f5bc4168daaa6 */ + * Stub hash: 55701f921c7df2f344dd6b110558fd97efec9891 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, file_name, IS_STRING, 0) @@ -173,7 +173,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileObject_fgetcsv, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, delimiter, IS_STRING, 0, "\",\"") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, enclosure, IS_STRING, 0, "\'\"\'") - ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, escape, "\"\\\\\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, escape, IS_STRING, 0, "\"\\\\\"") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileObject_fputcsv, 0, 0, 1) @@ -211,7 +211,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileObject_fscanf, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0) - ZEND_ARG_VARIADIC_INFO(1, params) + ZEND_ARG_VARIADIC_TYPE_INFO(1, params, IS_MIXED, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileObject_fwrite, 0, 0, 1)