diff options
author | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-09-04 14:01:09 +0200 |
---|---|---|
committer | Máté Kocsis <kocsismate@woohoolabs.com> | 2020-09-07 19:02:02 +0200 |
commit | 628db3f3b5b28190997b3cb2f711b6853c074660 (patch) | |
tree | 0973924054a14ef956847db6e86a16aa438c7560 | |
parent | 2c96780e1c10c3c851608835411e21879a069199 (diff) | |
download | php-git-628db3f3b5b28190997b3cb2f711b6853c074660.tar.gz |
Fix UNKNOWN default values in various extensions
Closes GH-6075
26 files changed, 188 insertions, 187 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 48dd6ecf45..d425b83109 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -86,7 +86,7 @@ static int le_gd_font; #endif #ifdef HAVE_GD_FREETYPE -static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int, int); +static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int); #endif #include "gd_arginfo.h" @@ -3099,33 +3099,19 @@ PHP_FUNCTION(imagegetclip) /* {{{ Give the bounding box of a text using fonts via freetype2 */ PHP_FUNCTION(imageftbbox) { - php_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_BBOX, 1); + php_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_BBOX); } /* }}} */ /* {{{ Write text to the image using fonts via freetype2 */ PHP_FUNCTION(imagefttext) { - php_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_DRAW, 1); -} -/* }}} */ - -/* {{{ Give the bounding box of a text using TrueType fonts */ -PHP_FUNCTION(imagettfbbox) -{ - php_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_BBOX, 0); -} -/* }}} */ - -/* {{{ Write text to the image using a TrueType font */ -PHP_FUNCTION(imagettftext) -{ - php_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_DRAW, 0); + php_imagettftext_common(INTERNAL_FUNCTION_PARAM_PASSTHRU, TTFTEXT_DRAW); } /* }}} */ /* {{{ php_imagettftext_common */ -static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int extended) +static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode) { zval *IM, *EXT = NULL; gdImagePtr im=NULL; @@ -3135,19 +3121,14 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int double ptsize, angle; char *str = NULL, *fontname = NULL; char *error = NULL; - int argc = ZEND_NUM_ARGS(); gdFTStringExtra strex = {0}; if (mode == TTFTEXT_BBOX) { - if (argc < 4 || argc > ((extended) ? 5 : 4)) { - ZEND_WRONG_PARAM_COUNT(); - } else if (zend_parse_parameters(argc, "ddss|a", &ptsize, &angle, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ddss|a", &ptsize, &angle, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) { RETURN_THROWS(); } } else { - if (argc < 8 || argc > ((extended) ? 9 : 8)) { - ZEND_WRONG_PARAM_COUNT(); - } else if (zend_parse_parameters(argc, "Oddlllss|a", &IM, gd_image_ce, &ptsize, &angle, &x, &y, &col, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oddlllss|a", &IM, gd_image_ce, &ptsize, &angle, &x, &y, &col, &fontname, &fontname_len, &str, &str_len, &EXT) == FAILURE) { RETURN_THROWS(); } im = php_gd_libgdimageptr_from_zval_p(IM); @@ -3156,7 +3137,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int /* convert angle to radians */ angle = angle * (M_PI/180); - if (extended && EXT) { /* parse extended info */ + if (EXT) { /* parse extended info */ zval *item; zend_string *key; @@ -3184,7 +3165,7 @@ static void php_imagettftext_common(INTERNAL_FUNCTION_PARAMETERS, int mode, int PHP_GD_CHECK_OPEN_BASEDIR(fontname, "Invalid font filename"); - if (extended) { + if (EXT) { error = gdImageStringFTEx(im, brect, col, fontname, ptsize, angle, x, y, str, &strex); } else { error = gdImageStringFT(im, brect, col, fontname, ptsize, angle, x, y, str); @@ -3819,7 +3800,7 @@ PHP_FUNCTION(imageaffinematrixget) zval *tmp; int res = GD_FALSE, i; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|z", &type, &options) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &type, &options) == FAILURE) { RETURN_THROWS(); } @@ -3827,7 +3808,7 @@ PHP_FUNCTION(imageaffinematrixget) case GD_AFFINE_TRANSLATE: case GD_AFFINE_SCALE: { double x, y; - if (!options || Z_TYPE_P(options) != IS_ARRAY) { + if (Z_TYPE_P(options) != IS_ARRAY) { zend_argument_type_error(1, "must be of type array when using translate or scale"); RETURN_THROWS(); } @@ -3859,11 +3840,6 @@ PHP_FUNCTION(imageaffinematrixget) case GD_AFFINE_SHEAR_VERTICAL: { double angle; - if (!options) { - zend_argument_type_error(2, "must be of type int|float when using rotate or shear"); - RETURN_THROWS(); - } - angle = zval_get_double(options); if (type == GD_AFFINE_SHEAR_HORIZONTAL) { diff --git a/ext/gd/gd.stub.php b/ext/gd/gd.stub.php index 7b2e754bad..26c8db9b12 100644 --- a/ext/gd/gd.stub.php +++ b/ext/gd/gd.stub.php @@ -215,13 +215,15 @@ function imagesetclip(GdImage $im, int $x1, int $x2, int $y1, int $y2): bool {} function imagegetclip(GdImage $im): array {} #ifdef HAVE_GD_FREETYPE -function imageftbbox(float $size, float $angle, string $font_file, string $text, array $extrainfo = UNKNOWN): array|false {} +function imageftbbox(float $size, float $angle, string $font_file, string $text, array $extrainfo = []): array|false {} -function imagefttext(GdImage $im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text, array $extrainfo = UNKNOWN): array|false {} +function imagefttext(GdImage $im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text, array $extrainfo = []): array|false {} -function imagettfbbox(float $size, float $angle, string $font_file, string $text): array|false {} +/** @alias imageftbbox */ +function imagettfbbox(float $size, float $angle, string $font_file, string $text, array $extrainfo = []): array|false {} -function imagettftext(GdImage $im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text): array|false {} +/** @alias imagefttext */ +function imagettftext(GdImage $im, float $size, float $angle, int $x, int $y, int $col, string $font_file, string $text, array $extrainfo = []): array|false {} #endif /** @param array|int|float|bool $filter_args */ @@ -241,8 +243,8 @@ function imagescale(GdImage $im, int $new_width, int $new_height = -1, int $mode function imageaffine(GdImage $im, array $affine, ?array $clip = null): GdImage|false {} -/** @param array|int|float $options */ -function imageaffinematrixget(int $type, $options = UNKNOWN): array|false {} +/** @param array|float $options */ +function imageaffinematrixget(int $type, $options): array|false {} function imageaffinematrixconcat(array $m1, array $m2): array|false {} diff --git a/ext/gd/gd_arginfo.h b/ext/gd/gd_arginfo.h index ca9ee89426..bd6255b083 100644 --- a/ext/gd/gd_arginfo.h +++ b/ext/gd/gd_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 540beb37f18b81102e7977447399757e865285c2 */ + * Stub hash: 20849891a4907e348f1a509388ab08b0b7f6633d */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gd_info, 0, 0, IS_ARRAY, 0) ZEND_END_ARG_INFO() @@ -459,7 +459,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imageftbbox, 0, 4, MAY_BE_ARRAY| ZEND_ARG_TYPE_INFO(0, angle, IS_DOUBLE, 0) ZEND_ARG_TYPE_INFO(0, font_file, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, text, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, extrainfo, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, extrainfo, IS_ARRAY, 0, "[]") ZEND_END_ARG_INFO() #endif @@ -473,30 +473,16 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imagefttext, 0, 8, MAY_BE_ARRAY| ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, font_file, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, text, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, extrainfo, IS_ARRAY, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, extrainfo, IS_ARRAY, 0, "[]") ZEND_END_ARG_INFO() #endif #if defined(HAVE_GD_FREETYPE) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imagettfbbox, 0, 4, MAY_BE_ARRAY|MAY_BE_FALSE) - ZEND_ARG_TYPE_INFO(0, size, IS_DOUBLE, 0) - ZEND_ARG_TYPE_INFO(0, angle, IS_DOUBLE, 0) - ZEND_ARG_TYPE_INFO(0, font_file, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, text, IS_STRING, 0) -ZEND_END_ARG_INFO() +#define arginfo_imagettfbbox arginfo_imageftbbox #endif #if defined(HAVE_GD_FREETYPE) -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imagettftext, 0, 8, MAY_BE_ARRAY|MAY_BE_FALSE) - ZEND_ARG_OBJ_INFO(0, im, GdImage, 0) - ZEND_ARG_TYPE_INFO(0, size, IS_DOUBLE, 0) - ZEND_ARG_TYPE_INFO(0, angle, IS_DOUBLE, 0) - ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, font_file, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, text, IS_STRING, 0) -ZEND_END_ARG_INFO() +#define arginfo_imagettftext arginfo_imagefttext #endif ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagefilter, 0, 2, _IS_BOOL, 0) @@ -547,7 +533,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_imageaffine, 0, 2, GdImage, ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, clip, IS_ARRAY, 1, "null") ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imageaffinematrixget, 0, 1, MAY_BE_ARRAY|MAY_BE_FALSE) +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_imageaffinematrixget, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, type, IS_LONG, 0) ZEND_ARG_INFO(0, options) ZEND_END_ARG_INFO() @@ -690,12 +676,6 @@ ZEND_FUNCTION(imageftbbox); #if defined(HAVE_GD_FREETYPE) ZEND_FUNCTION(imagefttext); #endif -#if defined(HAVE_GD_FREETYPE) -ZEND_FUNCTION(imagettfbbox); -#endif -#if defined(HAVE_GD_FREETYPE) -ZEND_FUNCTION(imagettftext); -#endif ZEND_FUNCTION(imagefilter); ZEND_FUNCTION(imageconvolution); ZEND_FUNCTION(imageflip); @@ -832,10 +812,10 @@ static const zend_function_entry ext_functions[] = { ZEND_FE(imagefttext, arginfo_imagefttext) #endif #if defined(HAVE_GD_FREETYPE) - ZEND_FE(imagettfbbox, arginfo_imagettfbbox) + ZEND_FALIAS(imagettfbbox, imageftbbox, arginfo_imagettfbbox) #endif #if defined(HAVE_GD_FREETYPE) - ZEND_FE(imagettftext, arginfo_imagettftext) + ZEND_FALIAS(imagettftext, imagefttext, arginfo_imagettftext) #endif ZEND_FE(imagefilter, arginfo_imagefilter) ZEND_FE(imageconvolution, arginfo_imageconvolution) diff --git a/ext/gd/tests/bug67248.phpt b/ext/gd/tests/bug67248.phpt index 054ba52861..5b5e0e8bae 100644 --- a/ext/gd/tests/bug67248.phpt +++ b/ext/gd/tests/bug67248.phpt @@ -11,15 +11,60 @@ require __DIR__ . '/func.inc'; for($i=0;$i<7;$i++) { trycatch_dump( - fn() => imageaffinematrixget($i) + fn() => imageaffinematrixget($i, new stdClass()) ); } ?> ---EXPECT-- +--EXPECTF-- !! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale !! [TypeError] imageaffinematrixget(): Argument #1 ($type) must be of type array when using translate or scale -!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|float when using rotate or shear -!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|float when using rotate or shear -!! [TypeError] imageaffinematrixget(): Argument #2 ($options) must be of type int|float when using rotate or shear + +Notice: Object of class stdClass could not be converted to float in %s on line %d +array(6) { + [0]=> + float(%f) + [1]=> + float(%f) + [2]=> + float(%f) + [3]=> + float(%f) + [4]=> + float(0) + [5]=> + float(0) +} + +Notice: Object of class stdClass could not be converted to float in %s on line %d +array(6) { + [0]=> + float(1) + [1]=> + float(0) + [2]=> + float(%f) + [3]=> + float(1) + [4]=> + float(0) + [5]=> + float(0) +} + +Notice: Object of class stdClass could not be converted to float in %s on line %d +array(6) { + [0]=> + float(1) + [1]=> + float(%f) + [2]=> + float(0) + [3]=> + float(1) + [4]=> + float(0) + [5]=> + float(0) +} !! [ValueError] imageaffinematrixget(): Argument #1 ($type) must be a valid element type !! [ValueError] imageaffinematrixget(): Argument #1 ($type) must be a valid element type diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index efb7048cf6..69b9d3206d 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -928,7 +928,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|p!p!", &index, &index_len, &webindex, &webindex_len) == FAILURE) { RETURN_THROWS(); } @@ -1833,7 +1833,7 @@ 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) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s!", &obj, zend_ce_traversable, &base, &base_len) == FAILURE) { RETURN_THROWS(); } @@ -2339,7 +2339,7 @@ PHP_METHOD(Phar, convertToExecutable) /* a number that is not 0, 1 or 2 (Which is also Greg's birthday, so there) */ zend_long format = 9021976, method = 9021976; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls", &format, &method, &ext, &ext_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls!", &format, &method, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); } @@ -2443,7 +2443,7 @@ PHP_METHOD(Phar, convertToData) /* a number that is not 0, 1 or 2 (Which is also Greg's birthday so there) */ zend_long format = 9021976, method = 9021976; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls", &format, &method, &ext, &ext_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lls!", &format, &method, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); } @@ -2992,7 +2992,7 @@ 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) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|s!", &algo, &key, &key_len) != SUCCESS) { RETURN_THROWS(); } @@ -3155,7 +3155,7 @@ PHP_METHOD(Phar, compress) uint32_t flags; zend_object *ret; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|s", &method, &ext, &ext_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|s!", &method, &ext, &ext_len) == FAILURE) { RETURN_THROWS(); } @@ -3221,7 +3221,7 @@ PHP_METHOD(Phar, decompress) size_t ext_len = 0; zend_object *ret; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &ext, &ext_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!", &ext, &ext_len) == FAILURE) { RETURN_THROWS(); } @@ -3804,7 +3804,7 @@ PHP_METHOD(Phar, addFile) php_stream *resource; zval zresource; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &localname, &localname_len) == FAILURE) { RETURN_THROWS(); } diff --git a/ext/phar/phar_object.stub.php b/ext/phar/phar_object.stub.php index da6ab987ed..e62a95c038 100644 --- a/ext/phar/phar_object.stub.php +++ b/ext/phar/phar_object.stub.php @@ -16,16 +16,16 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess public function addEmptyDir(string $dirname) {} /** @return void */ - public function addFile(string $filename, string $localname = UNKNOWN) {} + public function addFile(string $filename, ?string $localname = null) {} /** @return void */ public function addFromString(string $localname, string $contents) {} /** @return array|false */ - public function buildFromDirectory(string $base_dir, string $regex = UNKNOWN) {} + public function buildFromDirectory(string $base_dir, string $regex = "") {} /** @return array|false */ - public function buildFromIterator(Traversable $iterator, string $base_directory = UNKNOWN) {} + public function buildFromIterator(Traversable $iterator, ?string $base_directory = null) {} /** @return void */ public function compressFiles(int $compression_type) {} @@ -34,22 +34,22 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess public function decompressFiles() {} /** @return Phar|null */ - public function compress(int $compression_type, string $file_ext = UNKNOWN) {} + public function compress(int $compression_type, ?string $file_ext = null) {} /** @return Phar|null */ - public function decompress(string $file_ext = UNKNOWN) {} + public function decompress(?string $file_ext = null) {} /** @return Phar|null */ - public function convertToExecutable(int $format = 9021976, int $compression_type = 9021976, string $file_ext = UNKNOWN) {} + public function convertToExecutable(int $format = 9021976, int $compression_type = 9021976, ?string $file_ext = null) {} /** @return Phar|null */ - public function convertToData(int $format = 9021976, int $compression_type = 9021976, string $file_ext = UNKNOWN) {} + public function convertToData(int $format = 9021976, int $compression_type = 9021976, ?string $file_ext = null) {} /** @return bool */ public function copy(string $newfile, string $oldfile) {} /** @return int */ - public function count(int $mode = UNKNOWN) {} + public function count(int $mode = COUNT_NORMAL) {} /** @return bool */ public function delete(string $entry) {} @@ -131,7 +131,7 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess public function setMetadata(mixed $metadata) {} /** @return void */ - public function setSignatureAlgorithm(int $algorithm, string $privatekey = UNKNOWN) {} + public function setSignatureAlgorithm(int $algorithm, ?string $privatekey = null) {} /** * @param resource $newstub @@ -151,8 +151,7 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess final public static function canWrite(): bool {} - final public static function createDefaultStub( - string $index = UNKNOWN, string $webindex = UNKNOWN): string {} + final public static function createDefaultStub(?string $index = null, ?string $webindex = null): string {} final public static function getSupportedCompression(): array {} @@ -176,7 +175,7 @@ class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess final public static function unlinkArchive(string $archive): bool {} final public static function webPhar( - ?string $alias = null, ?string $index = null, string $f404 = UNKNOWN, + ?string $alias = null, ?string $index = null, string $f404 = "", array $mimetypes = [], ?callable $rewrites = null): void {} } @@ -198,7 +197,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc * @return void * @alias Phar::addFile */ - public function addFile(string $filename, string $localname = UNKNOWN) {} + public function addFile(string $filename, ?string $localname = null) {} /** * @return void @@ -210,13 +209,13 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc * @return array|false * @alias Phar::buildFromDirectory */ - public function buildFromDirectory(string $base_dir, string $regex = UNKNOWN) {} + public function buildFromDirectory(string $base_dir, string $regex = "") {} /** * @return array|false * @alias Phar::buildFromIterator */ - public function buildFromIterator(Traversable $iterator, string $base_directory = UNKNOWN) {} + public function buildFromIterator(Traversable $iterator, ?string $base_directory = null) {} /** * @return void @@ -234,25 +233,25 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc * @return Phar|null * @alias Phar::compress */ - public function compress(int $compression_type, string $file_ext = UNKNOWN) {} + public function compress(int $compression_type, ?string $file_ext = null) {} /** * @return Phar|null * @alias Phar::decompress */ - public function decompress(string $file_ext = UNKNOWN) {} + public function decompress(?string $file_ext = null) {} /** * @return Phar|null * @alias Phar::convertToExecutable */ - public function convertToExecutable(int $format = 9021976, int $compression_type = 9021976, string $file_ext = UNKNOWN) {} + public function convertToExecutable(int $format = 9021976, int $compression_type = 9021976, ?string $file_ext = null) {} /** * @return Phar|null * @alias Phar::convertToData */ - public function convertToData(int $format = 9021976, int $compression_type = 9021976, string $file_ext = UNKNOWN) {} + public function convertToData(int $format = 9021976, int $compression_type = 9021976, ?string $file_ext = null) {} /** * @return bool @@ -264,7 +263,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc * @return int * @alias Phar::count */ - public function count(int $mode = UNKNOWN) {} + public function count(int $mode = COUNT_NORMAL) {} /** * @return bool @@ -407,7 +406,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc * @return void * @alias Phar::setSignatureAlgorithm */ - public function setSignatureAlgorithm(int $algorithm, string $privatekey = UNKNOWN) {} + public function setSignatureAlgorithm(int $algorithm, ?string $privatekey = null) {} /** * @param resource $newstub @@ -438,8 +437,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc final public static function canWrite(): bool {} /** @alias Phar::createDefaultStub */ - final public static function createDefaultStub( - string $index = UNKNOWN, string $webindex = UNKNOWN): string {} + final public static function createDefaultStub(?string $index = null, ?string $webindex = null): string {} /** @alias Phar::getSupportedCompression */ final public static function getSupportedCompression(): array {} @@ -474,7 +472,7 @@ class PharData extends RecursiveDirectoryIterator implements Countable, ArrayAcc /** @alias Phar::webPhar */ final public static function webPhar( - ?string $alias = null, ?string $index = null, string $f404 = UNKNOWN, + ?string $alias = null, ?string $index = null, string $f404 = "", array $mimetypes = [], ?callable $rewrites = null): void {} } diff --git a/ext/phar/phar_object_arginfo.h b/ext/phar/phar_object_arginfo.h index e3963fe1a9..d6c6d5690e 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: d735d786b6804e336f45ac99c80276f5c67d4258 */ + * Stub hash: 8f92d8a7b1266cdec193336b36b2319235fbc40c */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -16,7 +16,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_addFile, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, localname, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, localname, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_addFromString, 0, 0, 2) @@ -26,12 +26,12 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_buildFromDirectory, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, base_dir, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, regex, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, regex, IS_STRING, 0, "\"\"") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_buildFromIterator, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0) - ZEND_ARG_TYPE_INFO(0, base_directory, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, base_directory, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_compressFiles, 0, 0, 1) @@ -42,17 +42,17 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_compress, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, compression_type, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, file_ext, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, file_ext, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_decompress, 0, 0, 0) - ZEND_ARG_TYPE_INFO(0, file_ext, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, file_ext, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_convertToExecutable, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, format, IS_LONG, 0, "9021976") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, compression_type, IS_LONG, 0, "9021976") - ZEND_ARG_TYPE_INFO(0, file_ext, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, file_ext, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_class_Phar_convertToData arginfo_class_Phar_convertToExecutable @@ -63,7 +63,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_copy, 0, 0, 2) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_count, 0, 0, 0) - ZEND_ARG_TYPE_INFO(0, mode, IS_LONG, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "COUNT_NORMAL") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_delete, 0, 0, 1) @@ -134,7 +134,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setSignatureAlgorithm, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, algorithm, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, privatekey, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, privatekey, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_Phar_setStub, 0, 0, 1) @@ -157,8 +157,8 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_canWrite, 0, 0, _IS_B ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_createDefaultStub, 0, 0, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, index, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, webindex, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, index, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, webindex, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_getSupportedCompression, 0, 0, IS_ARRAY, 0) @@ -204,7 +204,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_Phar_webPhar, 0, 0, IS_VOID, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, alias, IS_STRING, 1, "null") 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, f404, IS_STRING, 0, "\"\"") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mimetypes, IS_ARRAY, 0, "[]") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, rewrites, IS_CALLABLE, 1, "null") ZEND_END_ARG_INFO() diff --git a/ext/phar/tests/badparameters.phpt b/ext/phar/tests/badparameters.phpt index 2ad994385c..47c5d9edfb 100644 --- a/ext/phar/tests/badparameters.phpt +++ b/ext/phar/tests/badparameters.phpt @@ -229,7 +229,7 @@ try { ?> --EXPECTF-- Phar::mungServer(): Argument #1 ($munglist) must be of type array, string given -Phar::createDefaultStub(): Argument #1 ($index) must be a valid path, array given +Phar::createDefaultStub(): Argument #1 ($index) must be a valid path or null, array given Phar::loadPhar(): Argument #1 ($filename) must be a valid path, array given Phar::canCompress(): Argument #1 ($method) must be of type int, string given Phar::__construct(): Argument #1 ($filename) must be a valid path, array given diff --git a/ext/pspell/pspell.c b/ext/pspell/pspell.c index ce3242007e..63732b77b0 100644 --- a/ext/pspell/pspell.c +++ b/ext/pspell/pspell.c @@ -109,7 +109,7 @@ PHP_FUNCTION(pspell_new) { char *language, *spelling = NULL, *jargon = NULL, *encoding = NULL; size_t language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0; - zend_long mode = Z_L(0), speed = Z_L(0); + zend_long mode = Z_L(0), speed = Z_L(0); int argc = ZEND_NUM_ARGS(); zval *ind; @@ -167,7 +167,7 @@ PHP_FUNCTION(pspell_new) pspell_config_replace(config, "encoding", encoding); } - if (argc > 4) { + if (mode) { speed = mode & PSPELL_SPEED_MASK_INTERNAL; /* First check what mode we want (how many suggestions) */ @@ -205,7 +205,7 @@ PHP_FUNCTION(pspell_new_personal) { char *personal, *language, *spelling = NULL, *jargon = NULL, *encoding = NULL; size_t personal_len, language_len, spelling_len = 0, jargon_len = 0, encoding_len = 0; - zend_long mode = Z_L(0), speed = Z_L(0); + zend_long mode = Z_L(0), speed = Z_L(0); int argc = ZEND_NUM_ARGS(); zval *ind; @@ -271,7 +271,7 @@ PHP_FUNCTION(pspell_new_personal) pspell_config_replace(config, "encoding", encoding); } - if (argc > 5) { + if (mode) { speed = mode & PSPELL_SPEED_MASK_INTERNAL; /* First check what mode we want (how many suggestions) */ diff --git a/ext/pspell/pspell.stub.php b/ext/pspell/pspell.stub.php index 8c549786f2..03363f46b8 100644 --- a/ext/pspell/pspell.stub.php +++ b/ext/pspell/pspell.stub.php @@ -2,9 +2,9 @@ /** @generate-function-entries */ -function pspell_new(string $language, string $spelling = UNKNOWN, string $jargon = UNKNOWN, string $encoding = UNKNOWN, int $mode = 0): int|false {} +function pspell_new(string $language, string $spelling = "", string $jargon = "", string $encoding = "", int $mode = 0): int|false {} -function pspell_new_personal(string $personal, string $language, string $spelling = UNKNOWN, string $jargon = UNKNOWN, string $encoding = UNKNOWN, int $mode = 0): int|false {} +function pspell_new_personal(string $personal, string $language, string $spelling = "", string $jargon = "", string $encoding = "", int $mode = 0): int|false {} function pspell_new_config(int $config): int|false {} @@ -22,7 +22,7 @@ function pspell_clear_session(int $pspell): bool {} function pspell_save_wordlist(int $pspell): bool {} -function pspell_config_create(string $language, string $spelling = UNKNOWN, string $jargon = UNKNOWN, string $encoding = UNKNOWN): int {} +function pspell_config_create(string $language, string $spelling = "", string $jargon = "", string $encoding = ""): int {} function pspell_config_runtogether(int $conf, bool $runtogether): bool {} diff --git a/ext/pspell/pspell_arginfo.h b/ext/pspell/pspell_arginfo.h index 9f9bf447d6..4a009dec12 100644 --- a/ext/pspell/pspell_arginfo.h +++ b/ext/pspell/pspell_arginfo.h @@ -1,20 +1,20 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 9103420bb4162cad03e7ee06efa0d1c16820a099 */ + * Stub hash: 77f9effa6d246cf2b8da121d219462cce8a99918 */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pspell_new, 0, 1, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, language, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, spelling, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, jargon, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, spelling, IS_STRING, 0, "\"\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, jargon, IS_STRING, 0, "\"\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 0, "\"\"") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_pspell_new_personal, 0, 2, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, personal, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, language, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, spelling, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, jargon, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, spelling, IS_STRING, 0, "\"\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, jargon, IS_STRING, 0, "\"\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 0, "\"\"") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, mode, IS_LONG, 0, "0") ZEND_END_ARG_INFO() @@ -50,9 +50,9 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_config_create, 0, 1, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, language, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, spelling, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, jargon, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, spelling, IS_STRING, 0, "\"\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, jargon, IS_STRING, 0, "\"\"") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 0, "\"\"") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_pspell_config_runtogether, 0, 2, _IS_BOOL, 0) diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 1944ecf797..c941e43ad3 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1392,7 +1392,7 @@ SXE_METHOD(asXML) char *filename = NULL; size_t filename_len; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|p", &filename, &filename_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|p!", &filename, &filename_len) == FAILURE) { RETURN_THROWS(); } diff --git a/ext/simplexml/simplexml.stub.php b/ext/simplexml/simplexml.stub.php index 18cddf2886..d068cb2d71 100644 --- a/ext/simplexml/simplexml.stub.php +++ b/ext/simplexml/simplexml.stub.php @@ -17,13 +17,13 @@ class SimpleXMLElement implements Stringable, Countable, RecursiveIterator public function registerXPathNamespace(string $prefix, string $namespace) {} /** @return string|bool */ - public function asXML(string $filename = UNKNOWN) {} + public function asXML(?string $filename = null) {} /** * @return string|bool * @alias SimpleXMLElement::asXML */ - public function saveXML(string $filename = UNKNOWN) {} + public function saveXML(?string $filename = null) {} /** @return array */ public function getNamespaces(bool $recursive = false) {} diff --git a/ext/simplexml/simplexml_arginfo.h b/ext/simplexml/simplexml_arginfo.h index 5aa6d50ba1..1462487032 100644 --- a/ext/simplexml/simplexml_arginfo.h +++ b/ext/simplexml/simplexml_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 953089f230247acf18b9ac48c0a4c516d144a987 */ + * Stub hash: 38b23ba107bcd8a519a2aa70bacbbc6ace9aaa77 */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_simplexml_load_file, 0, 1, SimpleXMLElement, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) @@ -32,7 +32,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SimpleXMLElement_registerXPathNamespace, 0, ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SimpleXMLElement_asXML, 0, 0, 0) - ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filename, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_class_SimpleXMLElement_saveXML arginfo_class_SimpleXMLElement_asXML diff --git a/ext/sockets/sockets.stub.php b/ext/sockets/sockets.stub.php index 7d524dd51c..547374fe97 100644 --- a/ext/sockets/sockets.stub.php +++ b/ext/sockets/sockets.stub.php @@ -32,13 +32,13 @@ function socket_read(Socket $socket, int $length, int $type = PHP_BINARY_READ): * @param string $addr * @param int $port */ -function socket_getsockname(Socket $socket, &$addr, &$port = UNKNOWN): bool {} +function socket_getsockname(Socket $socket, &$addr, &$port = null): bool {} /** * @param string $addr * @param int $port */ -function socket_getpeername(Socket $socket, &$addr, &$port = UNKNOWN): bool {} +function socket_getpeername(Socket $socket, &$addr, &$port = null): bool {} function socket_create(int $domain, int $type, int $protocol): Socket|false {} @@ -58,7 +58,7 @@ function socket_send(Socket $socket, string $buf, int $len, int $flags): int|fal * @param string $name * @param int $port */ -function socket_recvfrom(Socket $socket, &$buf, int $len, int $flags, &$name, &$port = UNKNOWN): int|false {} +function socket_recvfrom(Socket $socket, &$buf, int $len, int $flags, &$name, &$port = null): int|false {} function socket_sendto(Socket $socket, string $buf, int $len, int $flags, string $addr, ?int $port = null): int|false {} diff --git a/ext/sockets/sockets_arginfo.h b/ext/sockets/sockets_arginfo.h index f02533324b..e7f4c04799 100644 --- a/ext/sockets/sockets_arginfo.h +++ b/ext/sockets/sockets_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 8d03ee514902490691aa4a9b8801fbc10b5b9c26 */ + * Stub hash: f2d1b412bf2e07c3e607aa6ebad25b19d882b98e */ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_select, 0, 4, MAY_BE_LONG|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(1, read_fds, IS_ARRAY, 1) @@ -48,7 +48,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_socket_getsockname, 0, 2, _IS_BOOL, 0) ZEND_ARG_OBJ_INFO(0, socket, Socket, 0) ZEND_ARG_INFO(1, addr) - ZEND_ARG_INFO(1, port) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, port, "null") ZEND_END_ARG_INFO() #define arginfo_socket_getpeername arginfo_socket_getsockname @@ -95,7 +95,7 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_recvfrom, 0, 5, MAY_BE_LO ZEND_ARG_TYPE_INFO(0, len, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 0) ZEND_ARG_INFO(1, name) - ZEND_ARG_INFO(1, port) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(1, port, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_socket_sendto, 0, 5, MAY_BE_LONG|MAY_BE_FALSE) diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 3f3391334a..72fb1cbe8f 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -532,7 +532,7 @@ static spl_filesystem_object *spl_filesystem_object_create_type(int num_args, sp size_t open_mode_len = 1; zval *resource = NULL; - if (zend_parse_parameters(num_args, "|sbr", + if (zend_parse_parameters(num_args, "|sbr!", &open_mode, &open_mode_len, &use_include_path, &resource) == FAILURE ) { return NULL; @@ -1350,7 +1350,7 @@ PHP_METHOD(SplFileInfo, getFileInfo) spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS); zend_class_entry *ce = intern->info_class; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C!", &ce) == FAILURE) { RETURN_THROWS(); } @@ -1366,7 +1366,7 @@ PHP_METHOD(SplFileInfo, getPathInfo) size_t path_len; char *path; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C", &ce) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|C!", &ce) == FAILURE) { RETURN_THROWS(); } diff --git a/ext/spl/spl_directory.stub.php b/ext/spl/spl_directory.stub.php index 3d4f396922..4691378ca9 100755 --- a/ext/spl/spl_directory.stub.php +++ b/ext/spl/spl_directory.stub.php @@ -73,16 +73,16 @@ class SplFileInfo public function getRealPath() {} /** @return SplFileInfo */ - public function getFileInfo(string $class_name = UNKNOWN) {} + public function getFileInfo(?string $class_name = null) {} /** @return SplFileInfo|null */ - public function getPathInfo(string $class_name = UNKNOWN) {} + public function getPathInfo(?string $class_name = null) {} /** - * @param resource $context + * @param resource|null $context * @return SplFileObject */ - public function openFile(string $open_mode = 'r', bool $use_include_path = false, $context = UNKNOWN) {} + public function openFile(string $open_mode = 'r', bool $use_include_path = false, $context = null) {} /** @return void */ public function setFileClass(string $class_name = SplFileObject::class) {} diff --git a/ext/spl/spl_directory_arginfo.h b/ext/spl/spl_directory_arginfo.h index 0208156759..7442c9c0e8 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: 444071056e55fdc44d76db009c92b4d06eba81fb */ + * Stub hash: 9127cb70a84f3e75ed16a17b15940b8a6b5f3937 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo___construct, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, file_name, IS_STRING, 0) @@ -53,7 +53,7 @@ ZEND_END_ARG_INFO() #define arginfo_class_SplFileInfo_getRealPath arginfo_class_SplFileInfo_getPath ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo_getFileInfo, 0, 0, 0) - ZEND_ARG_TYPE_INFO(0, class_name, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, class_name, IS_STRING, 1, "null") ZEND_END_ARG_INFO() #define arginfo_class_SplFileInfo_getPathInfo arginfo_class_SplFileInfo_getFileInfo @@ -61,7 +61,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo_openFile, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, open_mode, IS_STRING, 0, "\'r\'") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") - ZEND_ARG_INFO(0, context) + ZEND_ARG_INFO_WITH_DEFAULT_VALUE(0, context, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_SplFileInfo_setFileClass, 0, 0, 0) diff --git a/ext/spl/tests/bug46051.phpt b/ext/spl/tests/bug46051.phpt index 0b3c422905..cebe8a52d7 100644 --- a/ext/spl/tests/bug46051.phpt +++ b/ext/spl/tests/bug46051.phpt @@ -6,7 +6,7 @@ Bug #46051 (SplFileInfo::openFile - memory overlap) $x = new splfileinfo(__FILE__); try { - $x->openFile(NULL, NULL, NULL); + $x->openFile(NULL, NULL, []); } catch (TypeError $e) { } var_dump($x->getPathName()); diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 0adb122ff5..37f9230aad 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -998,7 +998,7 @@ PHP_FUNCTION(tidy_parse_string) Z_PARAM_STR(input) Z_PARAM_OPTIONAL Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) - Z_PARAM_STRING(enc, enc_len) + Z_PARAM_STRING_OR_NULL(enc, enc_len) ZEND_PARSE_PARAMETERS_END(); if (ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(input))) { @@ -1060,7 +1060,7 @@ PHP_FUNCTION(tidy_parse_file) Z_PARAM_PATH_STR(inputfile) Z_PARAM_OPTIONAL Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) - Z_PARAM_STRING(enc, enc_len) + Z_PARAM_STRING_OR_NULL(enc, enc_len) Z_PARAM_BOOL(use_include_path) ZEND_PARSE_PARAMETERS_END(); @@ -1353,7 +1353,7 @@ PHP_METHOD(tidy, __construct) Z_PARAM_OPTIONAL Z_PARAM_PATH_STR_OR_NULL(inputfile) Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) - Z_PARAM_STRING(enc, enc_len) + Z_PARAM_STRING_OR_NULL(enc, enc_len) Z_PARAM_BOOL(use_include_path) ZEND_PARSE_PARAMETERS_END(); @@ -1392,7 +1392,7 @@ PHP_METHOD(tidy, parseFile) Z_PARAM_PATH_STR(inputfile) Z_PARAM_OPTIONAL Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) - Z_PARAM_STRING(enc, enc_len) + Z_PARAM_STRING_OR_NULL(enc, enc_len) Z_PARAM_BOOL(use_include_path) ZEND_PARSE_PARAMETERS_END(); @@ -1432,7 +1432,7 @@ PHP_METHOD(tidy, parseString) Z_PARAM_STR(input) Z_PARAM_OPTIONAL Z_PARAM_STR_OR_ARRAY_HT_OR_NULL(options_str, options_ht) - Z_PARAM_STRING(enc, enc_len) + Z_PARAM_STRING_OR_NULL(enc, enc_len) ZEND_PARSE_PARAMETERS_END(); if (ZEND_SIZE_T_UINT_OVFL(ZSTR_LEN(input))) { diff --git a/ext/tidy/tidy.stub.php b/ext/tidy/tidy.stub.php index 76f4525132..4ae1b5e000 100644 --- a/ext/tidy/tidy.stub.php +++ b/ext/tidy/tidy.stub.php @@ -2,19 +2,19 @@ /** @generate-function-entries */ -function tidy_parse_string(string $input, array|string|null $config_options = null, string $encoding = UNKNOWN): tidy|false {} +function tidy_parse_string(string $input, array|string|null $config_options = null, ?string $encoding = null): tidy|false {} function tidy_get_error_buffer(tidy $object): string|false {} function tidy_get_output(tidy $object): string {} -function tidy_parse_file(string $file, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false): tidy|false {} +function tidy_parse_file(string $file, array|string|null $config_options = null, ?string $encoding = null, bool $use_include_path = false): tidy|false {} function tidy_clean_repair(tidy $object): bool {} -function tidy_repair_string(string $data, array|string|null $config_options = null, string $encoding = UNKNOWN): string|false {} +function tidy_repair_string(string $data, array|string|null $config_options = null, ?string $encoding = null): string|false {} -function tidy_repair_file(string $filename, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false): string|false {} +function tidy_repair_file(string $filename, array|string|null $config_options = null, ?string $encoding = null, bool $use_include_path = false): string|false {} function tidy_diagnose(tidy $object): bool {} @@ -54,7 +54,7 @@ function tidy_get_body(tidy $tidy): ?tidyNode {} class tidy { - public function __construct(?string $filename = null, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false) {} + public function __construct(?string $filename = null, array|string|null $config_options = null, ?string $encoding = null, bool $use_include_path = false) {} /** * @return string|int|bool @@ -69,22 +69,22 @@ class tidy public function cleanRepair() {} /** @return bool */ - public function parseFile(string $file, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false) {} + public function parseFile(string $file, array|string|null $config_options = null, ?string $encoding = null, bool $use_include_path = false) {} /** @return bool */ - public function parseString(string $input, array|string|null $config_options = null, string $encoding = UNKNOWN) {} + public function parseString(string $input, array|string|null $config_options = null, ?string $encoding = null) {} /** * @return bool * @alias tidy_repair_string */ - public function repairString(string $data, array|string|null $config_options = null, string $encoding = UNKNOWN) {} + public function repairString(string $data, array|string|null $config_options = null, ?string $encoding = null) {} /** * @return bool * @alias tidy_repair_file */ - public function repairFile(string $filename, array|string|null $config_options = null, string $encoding = UNKNOWN, bool $use_include_path = false) {} + public function repairFile(string $filename, array|string|null $config_options = null, ?string $encoding = null, bool $use_include_path = false) {} /** * @return bool diff --git a/ext/tidy/tidy_arginfo.h b/ext/tidy/tidy_arginfo.h index 30ca646812..ae3617a88f 100644 --- a/ext/tidy/tidy_arginfo.h +++ b/ext/tidy/tidy_arginfo.h @@ -1,10 +1,10 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: cc7cee7934007aa4b195fb1be0626496937e9d38 */ + * Stub hash: 62b1cdb7f9b9a5641d3bd9248f5a73c30266d02e */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_tidy_parse_string, 0, 1, tidy, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_tidy_get_error_buffer, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) @@ -18,7 +18,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_tidy_parse_file, 0, 1, tidy, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, file, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -29,13 +29,13 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_tidy_repair_string, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_tidy_repair_file, 0, 1, MAY_BE_STRING|MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -93,7 +93,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy___construct, 0, 0, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, filename, IS_STRING, 1, "null") ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() @@ -107,26 +107,26 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_parseFile, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, file, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_parseString, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, input, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_repairString, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_class_tidy_repairFile, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0) ZEND_ARG_TYPE_MASK(0, config_options, MAY_BE_ARRAY|MAY_BE_STRING|MAY_BE_NULL, "null") - ZEND_ARG_TYPE_INFO(0, encoding, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, encoding, IS_STRING, 1, "null") ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, use_include_path, _IS_BOOL, 0, "false") ZEND_END_ARG_INFO() diff --git a/ext/xmlwriter/php_xmlwriter.c b/ext/xmlwriter/php_xmlwriter.c index 3dfaab97ee..6ccd23b37e 100644 --- a/ext/xmlwriter/php_xmlwriter.c +++ b/ext/xmlwriter/php_xmlwriter.c @@ -855,7 +855,7 @@ PHP_FUNCTION(xmlwriter_write_dtd_entity) size_t pubid_len, sysid_len, ndataid_len; zval *self; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oss|bsss", &self, xmlwriter_class_entry_ce, + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oss|bs!s!s!", &self, xmlwriter_class_entry_ce, &name, &name_len, &content, &content_len, &pe, &pubid, &pubid_len, &sysid, &sysid_len, &ndataid, &ndataid_len) == FAILURE) { RETURN_THROWS(); diff --git a/ext/xmlwriter/php_xmlwriter.stub.php b/ext/xmlwriter/php_xmlwriter.stub.php index 54cdd4ff56..5b3b4f512b 100644 --- a/ext/xmlwriter/php_xmlwriter.stub.php +++ b/ext/xmlwriter/php_xmlwriter.stub.php @@ -206,7 +206,7 @@ class XMLWriter public function endDtdEntity(): bool {} /** @alias xmlwriter_write_dtd_entity */ - public function writeDtdEntity(string $name, string $content, bool $isparam = false, string $publicId = UNKNOWN, string $systemId = UNKNOWN, string $ndataid = UNKNOWN): bool {} + public function writeDtdEntity(string $name, string $content, bool $isparam = false, ?string $publicId = null, ?string $systemId = null, ?string $ndataid = null): bool {} /** @alias xmlwriter_output_memory */ public function outputMemory(bool $flush = true): string {} diff --git a/ext/xmlwriter/php_xmlwriter_arginfo.h b/ext/xmlwriter/php_xmlwriter_arginfo.h index cebddf6372..31eeb140aa 100644 --- a/ext/xmlwriter/php_xmlwriter_arginfo.h +++ b/ext/xmlwriter/php_xmlwriter_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 9323f768ddea26f104b699a9c0ce54e3560b3b32 */ + * Stub hash: 46bde559f165fc53d75690bfb4d86389202bb19e */ ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_xmlwriter_open_uri, 0, 1, XMLWriter, MAY_BE_FALSE) ZEND_ARG_TYPE_INFO(0, uri, IS_STRING, 0) @@ -314,9 +314,9 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_XMLWriter_writeDtdEntity, ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, content, IS_STRING, 0) ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, isparam, _IS_BOOL, 0, "false") - ZEND_ARG_TYPE_INFO(0, publicId, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, systemId, IS_STRING, 0) - ZEND_ARG_TYPE_INFO(0, ndataid, IS_STRING, 0) + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, publicId, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, systemId, IS_STRING, 1, "null") + ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, ndataid, IS_STRING, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_XMLWriter_outputMemory, 0, 0, IS_STRING, 0) |