com php-src: Convert fileinfo functions arginfo to php stubs: ext/fileinfo/fileinfo.c ext/fileinfo/fileinfo.stub.php ext/fileinfo/fileinfo_arginfo.h

From: Date: Mon, 26 Aug 2019 16:13:58 +0000
Subject: com php-src: Convert fileinfo functions arginfo to php stubs: ext/fileinfo/fileinfo.c ext/fileinfo/fileinfo.stub.php ext/fileinfo/fileinfo_arginfo.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-108075@lists.php.net to get a copy of this message
Commit: 4836660b9070b9eef0d30b8ba43f8c82dbbded1f Author: Craig Duncan <git@duncanc.co.uk> Mon, 26 Aug 2019 17:21:38 +0200 Committer: Christoph M. Becker <cmbecker69@gmx.de> Mon, 26 Aug 2019 18:13:58 +0200 Parents: 38c2230d079eb1f1b13750e0629c3e5217333cb7 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4836660b9070b9eef0d30b8ba43f8c82dbbded1f Log: Convert fileinfo functions arginfo to php stubs We also allow the context for finfo to be null. Changed paths: M ext/fileinfo/fileinfo.c A ext/fileinfo/fileinfo.stub.php A ext/fileinfo/fileinfo_arginfo.h Diff: diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c index 621e82c...2c5e420 100644 --- a/ext/fileinfo/fileinfo.c +++ b/ext/fileinfo/fileinfo.c @@ -34,6 +34,7 @@ #include "ext/standard/info.h" #include "ext/standard/file.h" /* needed for context stuff */ #include "php_fileinfo..h" +#include "fileinfo_arginfo.h" #include "fopen_wrappers.h" /* needed for is_url */ #include "Zend/zend_exceptions.h" @@ -108,63 +109,13 @@ PHP_FILEINFO_API zend_object *finfo_objects_new(zend_class_entry *class_type) } /* }}} */ -/* {{{ arginfo */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_open, 0, 0, 0) - ZEND_ARG_INFO(0, options) - ZEND_ARG_INFO(0, arg) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_close, 0, 0, 1) - ZEND_ARG_INFO(0, finfo) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_set_flags, 0, 0, 2) - ZEND_ARG_INFO(0, finfo) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_method_set_flags, 0, 0, 1) - ZEND_ARG_INFO(0, options) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_file, 0, 0, 2) - ZEND_ARG_INFO(0, finfo) - ZEND_ARG_INFO(0, filename) - ZEND_ARG_INFO(0, options) - ZEND_ARG_INFO(0, context) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_method_file, 0, 0, 1) - ZEND_ARG_INFO(0, filename) - ZEND_ARG_INFO(0, options) - ZEND_ARG_INFO(0, context) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_buffer, 0, 0, 2) - ZEND_ARG_INFO(0, finfo) - ZEND_ARG_INFO(0, string) - ZEND_ARG_INFO(0, options) - ZEND_ARG_INFO(0, context) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_method_buffer, 0, 0, 1) - ZEND_ARG_INFO(0, string) - ZEND_ARG_INFO(0, options) - ZEND_ARG_INFO(0, context) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_mime_content_type, 0, 0, 1) - ZEND_ARG_INFO(0, string) -ZEND_END_ARG_INFO() -/* }}} */ - /* {{{ finfo_class_functions */ static const zend_function_entry finfo_class_functions[] = { - ZEND_ME_MAPPING(__construct, finfo_open, arginfo_finfo_open, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(set_flags, finfo_set_flags,arginfo_finfo_method_set_flags, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(file, finfo_file, arginfo_finfo_method_file, ZEND_ACC_PUBLIC) - ZEND_ME_MAPPING(buffer, finfo_buffer, arginfo_finfo_method_buffer, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(__construct, finfo_open, arginfo_class_finfo___construct, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(set_flags, finfo_set_flags,arginfo_class_finfo_set_flags, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(file, finfo_file, arginfo_class_finfo_file, ZEND_ACC_PUBLIC) + ZEND_ME_MAPPING(buffer, finfo_buffer, arginfo_class_finfo_buffer, ZEND_ACC_PUBLIC) PHP_FE_END }; /* }}} */ @@ -470,13 +421,13 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime goto common; } } else if (object) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lr", &buffer, &buffer_len, &options, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|lr!", &buffer, &buffer_len, &options, &zcontext) == FAILURE) { return; } FILEINFO_FROM_OBJECT(finfo, object); magic = finfo->magic; } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|lr", &zfinfo, &buffer, &buffer_len, &options, &zcontext) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs|lr!", &zfinfo, &buffer, &buffer_len, &options, &zcontext) == FAILURE) { return; } if ((finfo = (php_fileinfo *)zend_fetch_resource(Z_RES_P(zfinfo), "file_info", le_fileinfo)) == NULL) { diff --git a/ext/fileinfo/fileinfo.stub.php b/ext/fileinfo/fileinfo.stub.php new file mode 100644 index 0000000..1b7a3b7 --- /dev/null +++ b/ext/fileinfo/fileinfo.stub.php @@ -0,0 +1,54 @@ +<?php + +class finfo +{ + function __construct(int $options = FILEINFO_NONE, string $arg = "") {} + + /** + * @param ?resource $context + * @return string|false + */ + function file(string $file_name, int $options = FILEINFO_NONE, $context = null) {} + + /** + * @param ?resource $context + * @return string|false + */ + function buffer(string $string, int $options = FILEINFO_NONE, $context = null) {} + + /** @return bool */ + function set_flags(int $options) {} +} + +/** @return resource|false */ +function finfo_open(int $options = FILEINFO_NONE, string $arg = "") {} + +/** + * @param resource $finfo + */ +function finfo_close($finfo): bool {} + +/** + * @param resource $finfo + */ +function finfo_set_flags($finfo, int $options): bool {} + +/** + * @param resource $finfo + * @param ?resource $context + * @return string|false + */ +function finfo_file($finfo, string $file_name, int $options = FILEINFO_NONE, $context = null) {} + +/** + * @param resource $finfo + * @param ?resource $context + * @return string|false + */ +function finfo_buffer($finfo, string $string, int $options = FILEINFO_NONE, $context = null) {} + +/** + * @param resource|string $filename + * @return string|false + */ +function mime_content_type($filename) {} diff --git a/ext/fileinfo/fileinfo_arginfo.h b/ext/fileinfo/fileinfo_arginfo.h new file mode 100644 index 0000000..b987d8a --- /dev/null +++ b/ext/fileinfo/fileinfo_arginfo.h @@ -0,0 +1,51 @@ +/* This is a generated file, edit the .stub.php file instead. */ + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_finfo___construct, 0, 0, 0) + ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, arg, IS_STRING, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_finfo_file, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, file_name, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0) + ZEND_ARG_INFO(0, context) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_finfo_buffer, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0) + ZEND_ARG_INFO(0, context) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_class_finfo_set_flags, 0, 0, 1) + ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0) +ZEND_END_ARG_INFO() + +#define arginfo_finfo_open arginfo_class_finfo___construct + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_finfo_close, 0, 1, _IS_BOOL, 0) + ZEND_ARG_INFO(0, finfo) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_finfo_set_flags, 0, 2, _IS_BOOL, 0) + ZEND_ARG_INFO(0, finfo) + ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_file, 0, 0, 2) + ZEND_ARG_INFO(0, finfo) + ZEND_ARG_TYPE_INFO(0, file_name, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0) + ZEND_ARG_INFO(0, context) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_finfo_buffer, 0, 0, 2) + ZEND_ARG_INFO(0, finfo) + ZEND_ARG_TYPE_INFO(0, string, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0) + ZEND_ARG_INFO(0, context) +ZEND_END_ARG_INFO() + +ZEND_BEGIN_ARG_INFO_EX(arginfo_mime_content_type, 0, 0, 1) + ZEND_ARG_INFO(0, filename) +ZEND_END_ARG_INFO()

« previous php.cvs (#108075) next »