Skip to content

finfo_file() fatal error message incorrect on empty filename argument. #15752

Closed
@danielmorell

Description

@danielmorell

Description

The following code:

<?php
$info = finfo_open(FILEINFO_MIME_TYPE);

if ($info) {
    echo finfo_file($info, '') . PHP_EOL;
}

Resulted in this output:

PHP Fatal error:  Uncaught ValueError: finfo_file(): Argument #1 ($finfo) cannot be empty in /some/dir/example.php:5

But I expected this output instead:

PHP Fatal error:  Uncaught ValueError: finfo_file(): Argument #2 ($filename) cannot be empty in /some/dir/example.php:5

The empty second argument is miss-attributed in the error message to the first argument.

If a non-empty string e.g. "foo" is passed as the second filename argument this error does not occur.

PHP Version

PHP 8.1-8.3

Operating System

Ubuntu 18.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions