The proper fix

main
Lars Strojny 4 years ago
parent 99fd5c7b49
commit a83588f568
No known key found for this signature in database
GPG Key ID: 887416A2AD3B0CA9

@ -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') || ($this->runtime->hasFunction('inet_pton') && 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->setDescription('The PHP interpreter, with IPv6 support');
$this->addPackage($phpIpv6);

@ -96,9 +96,6 @@ class PlatformRepositoryTest extends TestCase
array(
array('inet_pton', array('::'), ''),
),
array(
array('inet_pton', true),
)
),
array(
array(
@ -107,16 +104,15 @@ class PlatformRepositoryTest extends TestCase
array(
'php' => '7.2.31',
),
array(),
array(
'inet_pton' => false,
)
)
array('inet_pton', array('::'), false),
),
),
);
}
/** @dataProvider getPhpFlavorTestCases */
public function testPhpVersion(array $constants, array $packages, array $functionMap = array(), array $functionExists = array())
public function testPhpVersion(array $constants, array $packages, array $functions = array())
{
$runtime = $this->getMockBuilder('Composer\Platform\Runtime')->getMock();
$runtime
@ -138,11 +134,7 @@ class PlatformRepositoryTest extends TestCase
);
$runtime
->method('invoke')
->willReturnMap($functionMap);
$runtime
->method('hasFunction')
->willReturnMap($functionExists);
->willReturnMap($functions);
$repository = new PlatformRepository(array(), array(), $runtime);
foreach ($packages as $packageName => $version) {
@ -152,6 +144,39 @@ class PlatformRepositoryTest extends TestCase
}
}
public function testInetPtonRegressiom()
{
$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()
{
return array(

Loading…
Cancel
Save