Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[6.5] Install symfony's intl-idn polyfill #2550

Merged
merged 4 commits into from Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/static.yml
Expand Up @@ -17,6 +17,8 @@ jobs:

- name: PHPStan
uses: docker://oskarstark/phpstan-ga
env:
REQUIRE_DEV: true
with:
args: analyze --no-progress

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -23,6 +23,7 @@
"require": {
"php": ">=5.5",
"ext-json": "*",
"symfony/polyfill-intl-idn": "^1.11",
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.6.1"
},
Expand All @@ -32,8 +33,7 @@
"psr/log": "^1.1"
},
"suggest": {
"psr/log": "Required for using the Log middleware",
"ext-intl": "Required for Internationalized Domain Name (IDN) support"
"psr/log": "Required for using the Log middleware"
},
"config": {
"sort-packages": true
Expand Down
1 change: 0 additions & 1 deletion phpstan.neon.dist
Expand Up @@ -5,4 +5,3 @@ parameters:
level: max
paths:
- src
bootstrap: tests/bootstrap-phpstan.php
13 changes: 2 additions & 11 deletions src/Client.php
Expand Up @@ -236,19 +236,10 @@ private function configureDefaults(array $config)
'http_errors' => true,
'decode_content' => true,
'verify' => true,
'cookies' => false
'cookies' => false,
'idn_conversion' => true,
];

// idn_to_ascii() is a part of ext-intl and might be not available
$defaults['idn_conversion'] = function_exists('idn_to_ascii')
// Old ICU versions don't have this constant, so we are basically stuck (see https://github.com/guzzle/guzzle/pull/2424
// and https://github.com/guzzle/guzzle/issues/2448 for details)
&& (
defined('INTL_IDNA_VARIANT_UTS46')
||
PHP_VERSION_ID < 70200
);

// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.

// We can only trust the HTTP_PROXY environment variable in a CLI
Expand Down
19 changes: 1 addition & 18 deletions tests/ClientTest.php
Expand Up @@ -721,18 +721,11 @@ public function testIdnSupportDefaultValue()

$config = $client->getConfig();

if (extension_loaded('intl')) {
self::assertTrue($config['idn_conversion']);
} else {
self::assertFalse($config['idn_conversion']);
}
self::assertTrue($config['idn_conversion']);
}

public function testIdnIsTranslatedToAsciiWhenConversionIsEnabled()
{
if (!extension_loaded('intl')) {
self::markTestSkipped('intl PHP extension is not loaded');
}
$mockHandler = new MockHandler([new Response()]);
$client = new Client(['handler' => $mockHandler]);

Expand Down Expand Up @@ -763,9 +756,6 @@ public function testIdnStaysTheSameWhenConversionIsDisabled()
*/
public function testExceptionOnInvalidIdn()
{
if (!extension_loaded('intl')) {
self::markTestSkipped('intl PHP extension is not loaded');
}
$mockHandler = new MockHandler([new Response()]);
$client = new Client(['handler' => $mockHandler]);

Expand All @@ -778,10 +768,6 @@ public function testExceptionOnInvalidIdn()
*/
public function testIdnBaseUri()
{
if (!extension_loaded('intl')) {
self::markTestSkipped('intl PHP extension is not loaded');
}

$mock = new MockHandler([new Response()]);
$client = new Client([
'handler' => $mock,
Expand All @@ -796,9 +782,6 @@ public function testIdnBaseUri()

public function testIdnWithRedirect()
{
if (!extension_loaded('intl')) {
self::markTestSkipped('intl PHP extension is not loaded');
}
$mockHandler = new MockHandler([
new Response(302, ['Location' => 'http://www.tést.com/whatever']),
new Response()
Expand Down
4 changes: 0 additions & 4 deletions tests/InternalUtilsTest.php
Expand Up @@ -14,10 +14,6 @@ public function testCurrentTime()

public function testIdnConvert()
{
if (!extension_loaded('intl')) {
self::markTestSkipped('intl PHP extension is not loaded');
}

$uri = Psr7\uri_for('https://яндекс.рф/images');
$uri = Utils::idnUriConvert($uri);
self::assertSame('xn--d1acpjx3f.xn--p1ai', $uri->getHost());
Expand Down
9 changes: 0 additions & 9 deletions tests/bootstrap-phpstan.php

This file was deleted.