I'd already looked into using the following which I think I'm right in saying is fundamentally the same as your code snippet suggestion (unless of course yours forces BIND in which case perfect!):
$hostname = gethostbyaddr( inet_aton($ip), AF_INET );
But unfortunately gethostbyaddr by design searches the sources listed in /etc/nsswitch.conf or similar.
For me this is undesirable as my single source of truth for the FQDN is not the client but DNS.
With /etc/nsswitch.conf set to local followed by bind the query is likely to resolve from /etc/hosts first which cannot be relied upon to be accurate.