Skip to content

Commit

Permalink
Replaced get_resource_type with get_class (#279)
Browse files Browse the repository at this point in the history
Now using get_resource_type with get_class for checking valid gd image
instance. For PHP 8.0 and higher, get_resource_type with a GD image
argument, will throw a Fatal Error.
  • Loading branch information
RussellJapheth authored Apr 20, 2021
1 parent e2743aa commit 255d9e7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/claviska/SimpleImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ public function __construct($image = null) {
* Destroys the image resource.
*/
public function __destruct() {
if($this->image !== null && is_resource($this->image) && get_resource_type($this->image) === 'gd') {
//Check for a valid GDimage instance
$type_check = (gettype($this->image) == "object" && get_class($this->image) == "GdImage");

if($this->image !== null && is_resource($this->image) && $type_check) {
imagedestroy($this->image);
}
}
Expand Down

0 comments on commit 255d9e7

Please sign in to comment.