Skip to content

ext/gd: Return type violation in imagefilter when an invalid filter is provided #20070

@Girgias

Description

@Girgias

Description

The following code:

<?php
$image = imagecreatetruecolor(180, 30);

try {
    var_dump(imagefilter($image, -1));
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), "\n";
}

Resulted in this output:

Fatal error: imagefilter(): Return value must be of type bool, null returned in Unknown on line 0

But I expected this output instead:

ValueError: imagefilter(): Argument #2 ($filter) must be a valid filter

Found by just staring at the code when double-checking #20066

PHP Version

latest

Operating System

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions