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
{{ message }}
Repository navigation
Hooks/Docs: load_image_to_edit filter — @param declares GdImage|resource but resource|false can be passed #21
The load_image_to_edit filter documents its first argument as @param resource|GdImage $image but PHPStan reports that resource|false can be passed. The filter is called inside an if ( is_gd_image( $image ) ) guard, but PHPStan does not recognize is_gd_image() as a type-narrowing assertion, so it still considers false a possible value.
$image is set by functions like imagecreatefromjpeg() which return GdImage|false (PHP 8+) or resource|false (PHP 7), so before the is_gd_image() guard, the type includes false.
Root cause
is_gd_image() is not annotated with a PHPStan type assertion (@phpstan-assert), so PHPStan cannot narrow the type inside the if block.
Possible fixes
Option A — Add a @phpstan-assert to is_gd_image() (ideal, fixes the root cause):
Activity
apermo commentedon Mar 8, 2026
option A