-
-
Notifications
You must be signed in to change notification settings - Fork 72
Closed
Description
The base class for an RR record seems to implement the magic method __get but not __isset as seen here:
Lines 211 to 219 in df04947
| public function __get(string $_name): mixed | |
| { | |
| if (property_exists(get_called_class(), $_name) == false) | |
| { | |
| throw new \NetDNS2\Exception(sprintf('undefined property: %s', $_name), \NetDNS2\ENUM\Error::INT_PARSE_ERROR); | |
| } | |
| return $this->$_name; | |
| } |
This caused some compatibility issues with Laravel Collections due to helper methods (used internally in collections) checking if the value was set before retrieveing it as below.
https://github.com/illuminate/collections/blob/e161ebd436f8d1f40c6468f7be2536280044eec5/helpers.php#L88-L89
I have found a workaround by using a callback and invoking the property directly but the following code does not work due to the missing function:
$resolver = new Resolver([
'nameservers' => [
'1.1.1.1',
'8.8.8.8',
],
]);
$response = $resolver->query('github.com', 'MX');
// This does not work
return collect($response->answer)
->sortBy('preference');
// Using a callback works
return collect($response->answer)
->sortBy(fn ($item) => $item->preference)I know it's not specifically a NetDNS issue however I don't see a reason we couldn't implement the __isset magic method.
Metadata
Metadata
Assignees
Labels
No labels