Merge pull request #9133 from lstrojny/dev/check-inet-pton
Fix regression when inet_pton() does not existpull/9138/head
commit
38f49acfdd
|
@ -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
|
||||||
|
|
|
@ -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') || Silencer::call(array($this->runtime, 'invoke'), 'inet_pton', array('::')) !== 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);
|
||||||
|
|
|
@ -95,8 +95,19 @@ class PlatformRepositoryTest extends TestCase
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('inet_pton', array('::'), ''),
|
array('inet_pton', array('::'), ''),
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'PHP_VERSION' => '7.2.31-1+ubuntu16.04.1+deb.sury.org+1',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'php' => '7.2.31',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array('inet_pton', array('::'), false),
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +144,39 @@ class PlatformRepositoryTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testInetPtonRegression()
|
||||||
|
{
|
||||||
|
$runtime = $this->getMockBuilder('Composer\Platform\Runtime')->getMock();
|
||||||
|
|
||||||
|
$runtime
|
||||||
|
->expects(self::once())
|
||||||
|
->method('invoke')
|
||||||
|
->with('inet_pton', array('::'))
|
||||||
|
->willReturn(false);
|
||||||
|
$runtime
|
||||||
|
->method('hasConstant')
|
||||||
|
->willReturnMap(
|
||||||
|
array(
|
||||||
|
array('PHP_ZTS', false),
|
||||||
|
array('AF_INET6', false),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$runtime
|
||||||
|
->method('getExtensions')
|
||||||
|
->willReturn(array());
|
||||||
|
$runtime
|
||||||
|
->method('getConstant')
|
||||||
|
->willReturnMap(
|
||||||
|
array(
|
||||||
|
array('PHP_VERSION', null, '7.0.0'),
|
||||||
|
array('PHP_DEBUG', null, false),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$repository = new PlatformRepository(array(), array(), $runtime);
|
||||||
|
$package = $repository->findPackage('php-ipv6', '*');
|
||||||
|
self::assertNull($package);
|
||||||
|
}
|
||||||
|
|
||||||
public static function getLibraryTestCases()
|
public static function getLibraryTestCases()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
|
Loading…
Reference in New Issue