You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
procedural: ValueError: finfo_file(): Argument #2 ($filename) must not be empty
method: ValueError: finfo::file(): Argument #2 ($flags) must not be empty
(8.3 prints the same with "cannot be empty".)
Expected for the method: finfo::file(): Argument #1 ($filename) must not be empty.
The same C function serves both finfo_file($finfo, $filename, ...) and finfo::file($filename, $flags, ...), and the argument number is hardcoded:
master and PHP-8.5, ext/fileinfo/fileinfo.c, PHP_FUNCTION(finfo_file): zend_argument_must_not_be_empty_error(2);
PHP-8.4, php_finfo_get_type(): buffer_param_num = (mimetype_emu ? 1 : 2) is used for both the empty check and the null byte check, so on 8.4 the null byte TypeError of the method names $flags too.
A possible fix is to pass getThis() ? 1 : 2 (the null byte check on master and 8.5 is already correct, as it goes through zend_parse_method_parameters()). finfo_file_001.phpt only covers the procedural form.
Activity
Fix phpGH-24289: finfo::file() reports the wrong argument number
Merge branch 'PHP-8.4' into PHP-8.5
Merge branch 'PHP-8.5' into PHP-8.6
Merge branch 'PHP-8.6'
Merge remote-tracking branch 'up/PHP-8.4' into fix-phpgh-20503