Skip to content

Commit e104115

Browse files
committed
Fix failure on PHP 8.
GD extension uses \GdImage class objects instead of resource in PHP 8. Signed-off-by: ADmad <[email protected]>
1 parent 219d9fe commit e104115

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Stream.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,14 @@ private function setStream($stream, string $mode = 'r') : void
370370
*/
371371
private function isValidStreamResourceType($resource): bool
372372
{
373-
return (
374-
is_resource($resource) &&
375-
in_array(get_resource_type($resource), self::ALLOWED_STREAM_RESOURCE_TYPES, true)
376-
);
373+
if (is_resource($resource)) {
374+
return in_array(get_resource_type($resource), self::ALLOWED_STREAM_RESOURCE_TYPES, true);
375+
}
376+
377+
if (PHP_VERSION_ID >= 80000 && $resource instanceof \GdImage) {
378+
return true;
379+
}
380+
381+
return false;
377382
}
378383
}

0 commit comments

Comments
 (0)