remotelyliving / php-dns

A DNS abstraction for PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DNSRecord toArray missing data array

xorinzor opened this issue · comments

It seems that the toArray function of DNSRecord doesn't call toArray on the data field (if it exists). Instead turning it into a string of text.

https://github.com/remotelyliving/php-dns/blob/711697608616931c9ec94624cb8984355b73102e/src/Entities/DNSRecord.php#L108C58-L108C58

Is this intended?

same seems to also happen for the IpAddress field

Hi there! Thanks for reporting this. Could you please provide a sample domain and query this is happening for or is it all of them?

Oh, nvm. I misunderstood what you are saying. You want the original IPAddress or Data object in the array for toArray(). I do see that as a flaw come to think of it. It's premature formatting. I would suggest using the getIPAddress() or getData() methods instead or feel free to apply the decorator pattern the DNSRecord object with your own and format toArray() as you like it. I can update this in a breaking change release sometime in the future. I'll leave this open until then.

Sure no worries, it's easy to work around too. There's something to say for both ways the toArray() method could work, so I'm not really sure what would be the "proper" way of handling this either.