mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
fileinfo: Deprecate finfo_close()
(#18396)
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_finfo_close
This commit is contained in:
parent
922c225fbf
commit
ccb716dcad
5 changed files with 18 additions and 4 deletions
|
@ -31,10 +31,11 @@
|
||||||
#include "php_ini.h"
|
#include "php_ini.h"
|
||||||
#include "ext/standard/info.h"
|
#include "ext/standard/info.h"
|
||||||
#include "ext/standard/file.h" /* needed for context stuff */
|
#include "ext/standard/file.h" /* needed for context stuff */
|
||||||
|
#include "Zend/zend_attributes.h"
|
||||||
|
#include "Zend/zend_exceptions.h"
|
||||||
#include "php_fileinfo.h"
|
#include "php_fileinfo.h"
|
||||||
#include "fileinfo_arginfo.h"
|
#include "fileinfo_arginfo.h"
|
||||||
#include "fopen_wrappers.h" /* needed for is_url */
|
#include "fopen_wrappers.h" /* needed for is_url */
|
||||||
#include "Zend/zend_exceptions.h"
|
|
||||||
|
|
||||||
static zend_object_handlers finfo_object_handlers;
|
static zend_object_handlers finfo_object_handlers;
|
||||||
zend_class_entry *finfo_class_entry;
|
zend_class_entry *finfo_class_entry;
|
||||||
|
|
|
@ -92,6 +92,7 @@ class finfo
|
||||||
/** @refcount 1 */
|
/** @refcount 1 */
|
||||||
function finfo_open(int $flags = FILEINFO_NONE, ?string $magic_database = null): finfo|false {}
|
function finfo_open(int $flags = FILEINFO_NONE, ?string $magic_database = null): finfo|false {}
|
||||||
|
|
||||||
|
#[\Deprecated(since: '8.5', message: 'as finfo objects are freed automatically')]
|
||||||
function finfo_close(finfo $finfo): true {}
|
function finfo_close(finfo $finfo): true {}
|
||||||
|
|
||||||
function finfo_set_flags(finfo $finfo, int $flags): true {}
|
function finfo_set_flags(finfo $finfo, int $flags): true {}
|
||||||
|
|
12
ext/fileinfo/fileinfo_arginfo.h
generated
12
ext/fileinfo/fileinfo_arginfo.h
generated
|
@ -1,5 +1,5 @@
|
||||||
/* This is a generated file, edit the .stub.php file instead.
|
/* This is a generated file, edit the .stub.php file instead.
|
||||||
* Stub hash: d5bc322159e4af87077c07ddaca0a77803b4743a */
|
* Stub hash: 311d1049e32af017b44e260a00f13830714b1e96 */
|
||||||
|
|
||||||
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_finfo_open, 0, 0, finfo, MAY_BE_FALSE)
|
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_finfo_open, 0, 0, finfo, MAY_BE_FALSE)
|
||||||
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "FILEINFO_NONE")
|
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 0, "FILEINFO_NONE")
|
||||||
|
@ -63,7 +63,7 @@ ZEND_FUNCTION(mime_content_type);
|
||||||
|
|
||||||
static const zend_function_entry ext_functions[] = {
|
static const zend_function_entry ext_functions[] = {
|
||||||
ZEND_FE(finfo_open, arginfo_finfo_open)
|
ZEND_FE(finfo_open, arginfo_finfo_open)
|
||||||
ZEND_FE(finfo_close, arginfo_finfo_close)
|
ZEND_RAW_FENTRY("finfo_close", zif_finfo_close, arginfo_finfo_close, ZEND_ACC_DEPRECATED, NULL, NULL)
|
||||||
ZEND_FE(finfo_set_flags, arginfo_finfo_set_flags)
|
ZEND_FE(finfo_set_flags, arginfo_finfo_set_flags)
|
||||||
ZEND_FE(finfo_file, arginfo_finfo_file)
|
ZEND_FE(finfo_file, arginfo_finfo_file)
|
||||||
ZEND_FE(finfo_buffer, arginfo_finfo_buffer)
|
ZEND_FE(finfo_buffer, arginfo_finfo_buffer)
|
||||||
|
@ -96,6 +96,14 @@ static void register_fileinfo_symbols(int module_number)
|
||||||
#endif
|
#endif
|
||||||
REGISTER_LONG_CONSTANT("FILEINFO_APPLE", MAGIC_APPLE, CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("FILEINFO_APPLE", MAGIC_APPLE, CONST_PERSISTENT);
|
||||||
REGISTER_LONG_CONSTANT("FILEINFO_EXTENSION", MAGIC_EXTENSION, CONST_PERSISTENT);
|
REGISTER_LONG_CONSTANT("FILEINFO_EXTENSION", MAGIC_EXTENSION, CONST_PERSISTENT);
|
||||||
|
|
||||||
|
|
||||||
|
zend_attribute *attribute_Deprecated_func_finfo_close_0 = zend_add_function_attribute(zend_hash_str_find_ptr(CG(function_table), "finfo_close", sizeof("finfo_close") - 1), ZSTR_KNOWN(ZEND_STR_DEPRECATED_CAPITALIZED), 2);
|
||||||
|
ZVAL_STR(&attribute_Deprecated_func_finfo_close_0->args[0].value, ZSTR_KNOWN(ZEND_STR_8_DOT_5));
|
||||||
|
attribute_Deprecated_func_finfo_close_0->args[0].name = ZSTR_KNOWN(ZEND_STR_SINCE);
|
||||||
|
zend_string *attribute_Deprecated_func_finfo_close_0_arg1_str = zend_string_init("as finfo objects are freed automatically", strlen("as finfo objects are freed automatically"), 1);
|
||||||
|
ZVAL_STR(&attribute_Deprecated_func_finfo_close_0->args[1].value, attribute_Deprecated_func_finfo_close_0_arg1_str);
|
||||||
|
attribute_Deprecated_func_finfo_close_0->args[1].name = ZSTR_KNOWN(ZEND_STR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static zend_class_entry *register_class_finfo(void)
|
static zend_class_entry *register_class_finfo(void)
|
||||||
|
|
|
@ -23,6 +23,8 @@ unset( $finfo );
|
||||||
*** Testing finfo_close() : basic functionality ***
|
*** Testing finfo_close() : basic functionality ***
|
||||||
object(finfo)#%d (0) {
|
object(finfo)#%d (0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Deprecated: Function finfo_close() is deprecated since 8.5, as finfo objects are freed automatically in %s on line %d
|
||||||
bool(true)
|
bool(true)
|
||||||
object(finfo)#%d (%d) {
|
object(finfo)#%d (%d) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,10 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
*** Testing finfo_close() : error conditions ***
|
*** Testing finfo_close() : error conditions ***
|
||||||
|
|
||||||
-- Testing finfo_close() function with wrong resource type --
|
-- Testing finfo_close() function with wrong resource type --
|
||||||
|
|
||||||
|
Deprecated: Function finfo_close() is deprecated since 8.5, as finfo objects are freed automatically in %s on line %d
|
||||||
finfo_close(): Argument #1 ($finfo) must be of type finfo, resource given
|
finfo_close(): Argument #1 ($finfo) must be of type finfo, resource given
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue