From 4e06aa051a7d27966fe9b0bd548cc2fc0e6fa55f Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Tue, 18 Aug 2020 16:00:44 +0200 Subject: [PATCH] Check if inet_pton() exists --- src/Composer/Platform/Runtime.php | 9 +++++++++ src/Composer/Repository/PlatformRepository.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Composer/Platform/Runtime.php b/src/Composer/Platform/Runtime.php index 82211ec88..3c77a9250 100644 --- a/src/Composer/Platform/Runtime.php +++ b/src/Composer/Platform/Runtime.php @@ -34,6 +34,15 @@ class Runtime return constant(ltrim($class.'::'.$constant, ':')); } + /** + * @param string $fn + * @return bool + */ + public function hasFunction($fn) + { + return function_exists($fn); + } + /** * @param callable $callable * @param array $arguments diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 5a8f70627..c72c88f14 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -125,7 +125,7 @@ class PlatformRepository extends ArrayRepository // The AF_INET6 constant is only defined if ext-sockets is available but // 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->setDescription('The PHP interpreter, with IPv6 support'); $this->addPackage($phpIpv6);