Strict PHP Return types not correct for DNS getRecordID()
In DNS.php, the function getRecordID is declared with return type string, but returns false.
Can we change this to either empty string, or throw and exception instead of having conflicting return types?
public function getRecordID(string $zoneID, string $type = '', string $name = ''): string
{
$records = $this->listRecords($zoneID, $type, $name);
if (isset($records->result[0]->id)) {
return $records->result[0]->id;
}
return false;
}
could change final lines to:
return $records->result[0]->id ?? : '';
Hello @paulgoodchild The type error is not a fatal if not in strict mode. However, I agree there should be an exception instead, so I created pull request: https://github.com/cloudflare/cloudflare-php/pull/146
I would like consistency on the SDK since this method seems to not follow the pattern.
Hi @phily245 Can you please check https://github.com/cloudflare/cloudflare-php/pull/146
The Cloudflare\API\Endpoints\DNS class has serval return type issues.
For example getRecordDetails should return an stdClass but if the $recordID is a empty string it returns an array.
It should perform a GET request on https://api.cloudflare.com/client/v4/zones/{zone_identifier}/dns_records/{identifier} to get the DNS Record Details.
Without the recordID the request goes to https://api.cloudflare.com/client/v4/zones/{zone_identifier}/dns_records/ (List DNS Records) which returns an array.