1
0
Fork 0

Check if inet_pton() exists

pull/9133/head
Lars Strojny 2020-08-18 16:00:44 +02:00
parent 4aaff4c4b4
commit 4e06aa051a
No known key found for this signature in database
GPG Key ID: 887416A2AD3B0CA9
2 changed files with 10 additions and 1 deletions

View File

@ -34,6 +34,15 @@ class Runtime
return constant(ltrim($class.'::'.$constant, ':')); return constant(ltrim($class.'::'.$constant, ':'));
} }
/**
* @param string $fn
* @return bool
*/
public function hasFunction($fn)
{
return function_exists($fn);
}
/** /**
* @param callable $callable * @param callable $callable
* @param array $arguments * @param array $arguments

View File

@ -125,7 +125,7 @@ class PlatformRepository extends ArrayRepository
// The AF_INET6 constant is only defined if ext-sockets is available but // The AF_INET6 constant is only defined if ext-sockets is available but
// IPv6 support might still be available. // IPv6 support might still be available.
if ($this->runtime->hasConstant('AF_INET6') || Silencer::call(array($this->runtime, 'invoke'), array('inet_pton', '::')) !== false) { if ($this->runtime->hasConstant('AF_INET6') || ($this->runtime->hasFunction('inet_pton') && Silencer::call(array($this->runtime, 'invoke'), array('inet_pton', '::')) !== false)) {
$phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion); $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
$phpIpv6->setDescription('The PHP interpreter, with IPv6 support'); $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
$this->addPackage($phpIpv6); $this->addPackage($phpIpv6);