LKDevelopment / hetzner-cloud-php-sdk

A PHP SDK for the Hetzner Cloud API
MIT License
104 stars 51 forks source link

Type error when searching not-existing image by name #50

Closed mehr-it closed 4 years ago

mehr-it commented 4 years ago

The last line of the getByName() method returns null if the image does not exist. But null is not allowed by the method's return type.

Images.php:

public function getByName(string $name): Image
{
    $images = $this->list(new ImageRequestOpts($name));

    return (count($images->images) > 0) ? $images->images[0] : null;
}
LKaemmerling commented 4 years ago

Hey @mehr-it, thank you for the reporting! Could you please submit a PR to fix the issue? I'm a bit busy at the moment so i don't have direct time to fix the issue.

LKaemmerling commented 4 years ago

@mehr-it i just released v2.2.1 which includes a fix for this.