diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 9d1546807..0558d935f 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -17,6 +17,8 @@ jobs: - name: PHPStan uses: docker://oskarstark/phpstan-ga + env: + REQUIRE_DEV: true with: args: analyze --no-progress diff --git a/composer.json b/composer.json index bbf0ff20b..02ab73c0f 100644 --- a/composer.json +++ b/composer.json @@ -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" }, @@ -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 diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 012c5da5f..2d83c9846 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -5,4 +5,3 @@ parameters: level: max paths: - src - bootstrap: tests/bootstrap-phpstan.php \ No newline at end of file diff --git a/src/Client.php b/src/Client.php index 84b8a3b92..cd9a63574 100644 --- a/src/Client.php +++ b/src/Client.php @@ -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 diff --git a/tests/ClientTest.php b/tests/ClientTest.php index bc4ae33b1..cf4fcccde 100644 --- a/tests/ClientTest.php +++ b/tests/ClientTest.php @@ -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]); @@ -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]); @@ -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, @@ -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() diff --git a/tests/InternalUtilsTest.php b/tests/InternalUtilsTest.php index 133bee5ea..b465ff046 100644 --- a/tests/InternalUtilsTest.php +++ b/tests/InternalUtilsTest.php @@ -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()); diff --git a/tests/bootstrap-phpstan.php b/tests/bootstrap-phpstan.php deleted file mode 100644 index e91b7419c..000000000 --- a/tests/bootstrap-phpstan.php +++ /dev/null @@ -1,9 +0,0 @@ -