metaregistrar / php-epp-client

Object-oriented PHP EPP Client
https://www.metaregistrar.com/docs/
MIT License
210 stars 153 forks source link

Fatal Error in eppInfoHostResponse.php #342

Closed DECEiFER closed 7 months ago

DECEiFER commented 1 year ago

Hi,

Just letting you know that PHP 8 is throwing an E_ERROR in eppInfoHostResponse.php when array_keys() is run in get_host() due to the return value from getHostAddresses() being null. In PHP <=7 it was just an E_WARNING.

public function getHost() {
        $hostname = $this->getHostName();
        $address = $this->getHostAddresses();
        $address = array_keys($address);
        $host = new eppHost($hostname, $address);
        return $host;
    }

public function getHostAddresses() {
        $ip = null;
        $xpath = $this->xPath();
        $result = $xpath->query('/epp:epp/epp:response/epp:resData/host:infData/host:addr');
        foreach ($result as $address) {
            /* @var $address \DOMElement */
            $ip[$address->nodeValue] = $address->getAttribute('ip');
        }
        return $ip;
    }

I'm modifying it to:

public function getHostAddresses() {
        $ip = array();
        $xpath = $this->xPath();
        $result = $xpath->query('/epp:epp/epp:response/epp:resData/host:infData/host:addr');
        foreach ($result as $address) {
            /* @var $address \DOMElement */
            $ip[$address->nodeValue] = $address->getAttribute('ip');
        }
        return $ip;
    }

Thanks for the excellent work!