Skip to content

Commit

Permalink
PHPStan and CI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyholm committed Dec 7, 2019
1 parent 8da1f11 commit 2ce6693
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"require-dev": {
"ext-curl": "*",
"ext-intl": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
"psr/log": "^1.1"
},
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@ parameters:
count: 1
path: src/Client.php

-
message: "#^PHPDoc tag @throws with type GuzzleHttp\\\\InvalidArgumentException is not subtype of Throwable$#"
count: 1
path: src/Client.php

-
message: "#^Method GuzzleHttp\\\\ClientInterface\\:\\:send\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -615,11 +610,6 @@ parameters:
count: 1
path: src/Handler/CurlMultiHandler.php

-
message: "#^Parameter \\#1 \\$mh of function curl_multi_setopt expects resource, resource\\|false given\\.$#"
count: 1
path: src/Handler/CurlMultiHandler.php

-
message: "#^Method GuzzleHttp\\\\Handler\\\\CurlMultiHandler\\:\\:__invoke\\(\\) has no return typehint specified\\.$#"
count: 1
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ parameters:
level: max
paths:
- src
bootstrap: tests/bootstrap-phpstan.php
26 changes: 16 additions & 10 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,23 +720,26 @@ public function testIdnSupportDefaultValue()
$config = $client->getConfig();

if (extension_loaded('intl')) {
$this->assertTrue($config['idn_conversion']);
self::assertTrue($config['idn_conversion']);
} else {
$this->assertFalse($config['idn_conversion']);
self::assertFalse($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]);

$client->request('GET', 'https://яндекс.рф/images', ['idn_conversion' => true]);

$request = $mockHandler->getLastRequest();

$this->assertSame('https://xn--d1acpjx3f.xn--p1ai/images', (string) $request->getUri());
$this->assertSame('xn--d1acpjx3f.xn--p1ai', (string) $request->getHeaderLine('Host'));
self::assertSame('https://xn--d1acpjx3f.xn--p1ai/images', (string) $request->getUri());
self::assertSame('xn--d1acpjx3f.xn--p1ai', (string) $request->getHeaderLine('Host'));
}

public function testIdnStaysTheSameWhenConversionIsDisabled()
Expand All @@ -748,8 +751,8 @@ public function testIdnStaysTheSameWhenConversionIsDisabled()

$request = $mockHandler->getLastRequest();

$this->assertSame('https://яндекс.рф/images', (string) $request->getUri());
$this->assertSame('яндекс.рф', (string) $request->getHeaderLine('Host'));
self::assertSame('https://яндекс.рф/images', (string) $request->getUri());
self::assertSame('яндекс.рф', (string) $request->getHeaderLine('Host'));
}

/**
Expand All @@ -758,6 +761,9 @@ 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 @@ -771,18 +777,18 @@ public function testExceptionOnInvalidIdn()
public function testIdnBaseUri()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('intl PHP extension is not loaded');
self::markTestSkipped('intl PHP extension is not loaded');
}

$mock = new MockHandler([new Response()]);
$client = new Client([
'handler' => $mock,
'base_uri' => 'http://яндекс.рф',
]);
$this->assertSame('http://яндекс.рф', (string) $client->getConfig('base_uri'));
self::assertSame('http://яндекс.рф', (string) $client->getConfig('base_uri'));
$request = new Request('GET', '/baz');
$client->send($request);
$this->assertSame('http://xn--d1acpjx3f.xn--p1ai/baz', (string) $mock->getLastRequest()->getUri());
$this->assertSame('xn--d1acpjx3f.xn--p1ai', (string) $mock->getLastRequest()->getHeaderLine('Host'));
self::assertSame('http://xn--d1acpjx3f.xn--p1ai/baz', (string) $mock->getLastRequest()->getUri());
self::assertSame('xn--d1acpjx3f.xn--p1ai', (string) $mock->getLastRequest()->getHeaderLine('Host'));
}
}
10 changes: 10 additions & 0 deletions tests/bootstrap-phpstan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

if (!defined('IDNA_DEFAULT')) {
define('IDNA_DEFAULT', 0);
}

if (!defined('INTL_IDNA_VARIANT_UTS46')) {
define('INTL_IDNA_VARIANT_UTS46', 1);
}

0 comments on commit 2ce6693

Please sign in to comment.