Skip to content

Fix type() method return type in Illuminate\Filesystem\Filesystem#59071

Merged
taylorotwell merged 1 commit into
laravel:12.xfrom
GNfsys:12.x
Mar 4, 2026
Merged

Fix type() method return type in Illuminate\Filesystem\Filesystem#59071
taylorotwell merged 1 commit into
laravel:12.xfrom
GNfsys:12.x

Conversation

@GNfsys

@GNfsys GNfsys commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

The phpdoc might be outdated according to the current description of the function, which reports string|false.

Quoting:

Return Values

Returns the type of the file. Possible values are fifo, char, dir, block, link, file, socket and unknown.

Returns false if an error occurs. filetype() will also produce an E_NOTICE message if the stat call fails or if the file type is unknown.

Errors/Exceptions

Upon failure, an E_WARNING is emitted.

When executing this simple test i find that depending on the error_reporting level it can either generate an ErrorException: filetype(): Lstat failed for /dasdasadfasdbfbadfabd or false

test('type can return false', function () {
    $default = error_reporting();
    error_reporting(~E_ALL);

    $type = \Illuminate\Support\Facades\File::type('/dasdasadfasdbfbadfabd');
    expect($type)->toBeFalse();

    $type = \Illuminate\Support\Facades\File::type(base_path() . '/artisan');
    expect($type)->toBeString();

    error_reporting($default);
});

The phpdoc might be outdated according to the current description of the function, which reports string|false: https://www.php.net/manual/en/function.filetype.php .
@taylorotwell taylorotwell merged commit 9da4f30 into laravel:12.x Mar 4, 2026
65 of 72 checks passed
jonagoldman pushed a commit to deplox/laravel-framework that referenced this pull request Apr 30, 2026
The phpdoc might be outdated according to the current description of the function, which reports string|false: https://www.php.net/manual/en/function.filetype.php .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants