Commit 19a50604f9d for php

commit 19a50604f9d23c17e2ec26b6caaada777d79fa4d
Author: lazerg <lazerg2@gmail.com>
Date:   Tue Oct 13 14:47:20 2026 +0500

    Fix GH-24289: finfo::file() reports the wrong argument number

    Closes GH-24290.

diff --git a/NEWS b/NEWS
index 4b34324de64..98d3853e0b7 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,10 @@ PHP                                                                        NEWS
   . Fixed bug GH-24229 (fcgi_close() passes shutdown() a literal 1, which is
     SHUT_RD in WASI). (Ryosuke Ishibashi)

+- Fileinfo:
+  . Fixed bug GH-24289 (finfo::file() reports the wrong argument number for
+    an invalid $filename). (Lazizbek Ergashev)
+
 - MBString:
   . Fixed bug GH-23958 (truncated encoding names resolving to full names). (Kamil Tekiela)

diff --git a/ext/fileinfo/fileinfo.c b/ext/fileinfo/fileinfo.c
index 52172dfbd69..e935fb1489f 100644
--- a/ext/fileinfo/fileinfo.c
+++ b/ext/fileinfo/fileinfo.c
@@ -373,8 +373,8 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
 			php_stream_wrapper *wrap;
 			php_stream_statbuf ssb;

-			// Implementation is used for both finfo_file() and mimetype_emu()
-			int buffer_param_num = (mimetype_emu ? 1 : 2);
+			// Implementation is used for finfo_file(), finfo::file() and mimetype_emu()
+			int buffer_param_num = (mimetype_emu || hasThis() ? 1 : 2);
 			if (buffer == NULL || buffer_len == 0) {
 				zend_argument_must_not_be_empty_error(buffer_param_num);
 				goto clean;
diff --git a/ext/fileinfo/tests/gh24289.phpt b/ext/fileinfo/tests/gh24289.phpt
new file mode 100644
index 00000000000..f33eb0f2372
--- /dev/null
+++ b/ext/fileinfo/tests/gh24289.phpt
@@ -0,0 +1,23 @@
+--TEST--
+GH-24289 (finfo::file() reports the wrong argument number for an invalid $filename)
+--EXTENSIONS--
+fileinfo
+--FILE--
+<?php
+
+$finfo = new finfo();
+try {
+    var_dump($finfo->file(''));
+} catch (\ValueError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+try {
+    var_dump($finfo->file("\0"));
+} catch (\TypeError $e) {
+    echo $e->getMessage() . \PHP_EOL;
+}
+
+?>
+--EXPECT--
+finfo::file(): Argument #1 ($filename) must not be empty
+finfo::file(): Argument #1 ($filename) must not contain any null bytes