ext/finfo: Deprecate the parameter for finfo_buffer() (#19378)

RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_the_context_parameter_for_finfo_buffer
This commit is contained in:
Gina Peter Banyard 2025-08-09 17:42:19 +01:00 committed by GitHub
parent c064fc4fe8
commit ba21ab4ea0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 0 deletions

View file

@ -343,6 +343,13 @@ PHP_FUNCTION(finfo_buffer)
RETURN_THROWS(); RETURN_THROWS();
} }
if (ZEND_NUM_ARGS() == 4 || (hasThis() && ZEND_NUM_ARGS() == 3)) {
php_error_docref(NULL, E_DEPRECATED, "The $context parameter has no effect for finfo_buffer()");
if (UNEXPECTED(EG(exception))) {
RETURN_THROWS();
}
}
if (!Z_FINFO_P(self)->magic) { if (!Z_FINFO_P(self)->magic) {
zend_throw_error(NULL, "Invalid finfo object"); zend_throw_error(NULL, "Invalid finfo object");
RETURN_THROWS(); RETURN_THROWS();

View file

@ -0,0 +1,20 @@
--TEST--
finfo_buffer() deprecated $context param
--EXTENSIONS--
fileinfo
--FILE--
<?php
$finfo = finfo_open();
$buffer = "Regular string here";
var_dump(finfo_buffer($finfo, $buffer, FILEINFO_NONE, null));
var_dump($finfo->buffer($buffer, FILEINFO_NONE, null));
?>
--EXPECTF--
Deprecated: finfo_buffer(): The $context parameter has no effect for finfo_buffer() in %s on line %d
string(36) "ASCII text, with no line terminators"
Deprecated: finfo::buffer(): The $context parameter has no effect for finfo_buffer() in %s on line %d
string(36) "ASCII text, with no line terminators"