Skip to content

Commit 0b06571

Browse files
committed
Move $method to the end of the constructor and give it the default of HTTP_GET
1 parent 049223d commit 0b06571

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/DohExecutor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ class DohExecutor implements ExecutorInterface {
3030
const METHOD_POST = 'post';
3131

3232
/**
33-
* @param string $nameserver
33+
* @param string $nameserver
3434
* @param ?LoopInterface $loop
35+
* @param string $method
3536
*/
36-
public function __construct($nameserver, $method, LoopInterface $loop = null)
37+
public function __construct(string $nameserver, LoopInterface $loop = null, string $method = self::METHOD_GET)
3738
{
3839
if (!class_exists('\React\Http\Browser')) {
3940
throw new RuntimeException('DNS over HTTPS support requires reactphp/http library'); //@codeCoverageIgnore

tests/FunctionalTests.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class FunctionalTests extends TestCase
1515
{
1616
public function testResolveGoogleViaPostResolves()
1717
{
18-
$executor = new DohExecutor('https://1.1.1.1/dns-query', DohExecutor::METHOD_POST);
18+
$executor = new DohExecutor('https://1.1.1.1/dns-query', null,DohExecutor::METHOD_POST);
1919
$query = new Query('one.one.one.one', Message::TYPE_A, Message::CLASS_IN);
2020
$promise = $executor->query($query);
2121

@@ -32,7 +32,7 @@ public function testResolveGoogleViaPostResolves()
3232

3333
public function testResolveGoogleViaGetResolves()
3434
{
35-
$executor = new DohExecutor('https://1.1.1.1/dns-query', DohExecutor::METHOD_GET);
35+
$executor = new DohExecutor('https://1.1.1.1/dns-query', null,DohExecutor::METHOD_GET);
3636
$query = new Query('one.one.one.one', Message::TYPE_A, Message::CLASS_IN);
3737
$promise = $executor->query($query);
3838

@@ -49,7 +49,7 @@ public function testResolveGoogleViaGetResolves()
4949

5050
public function testResolveInvalidRejects()
5151
{
52-
$executor = new DohExecutor('https://1.1.1.1/dns-query', DohExecutor::METHOD_POST);
52+
$executor = new DohExecutor('https://1.1.1.1/dns-query');
5353
$query = new Query('example.invalid', Message::TYPE_A, Message::CLASS_IN);
5454
$promise = $executor->query($query);
5555

@@ -66,7 +66,7 @@ public function testResolveInvalidRejects()
6666

6767
public function testResolveToInvalidServerRejects()
6868
{
69-
$executor = new DohExecutor('https://127.0.0.1:0/dns-query', DohExecutor::METHOD_POST);
69+
$executor = new DohExecutor('https://127.0.0.1:0/dns-query');
7070
$query = new Query('google.com', Message::TYPE_A, Message::CLASS_IN);
7171
$promise = $executor->query($query);
7272

@@ -84,7 +84,7 @@ public function testResolveToInvalidServerRejects()
8484

8585
public function testQueryRejectsIfMessageExceedsMaximumMessageSize()
8686
{
87-
$executor = $executor = new DohExecutor('https://127.0.0.1:0/dns-query', DohExecutor::METHOD_POST);
87+
$executor = $executor = new DohExecutor('https://127.0.0.1:0/dns-query');
8888

8989
$query = new Query('google.' . str_repeat('.com', 60000), Message::TYPE_A, Message::CLASS_IN);
9090
$promise = $executor->query($query);
@@ -103,6 +103,6 @@ public function testResolveViaInvalidHttpMethodThrows()
103103
{
104104
$this->expectException(\InvalidArgumentException::class);
105105

106-
new DohExecutor('https://1.1.1.1/dns-query', 'put');
106+
new DohExecutor('https://1.1.1.1/dns-query', null, 'put');
107107
}
108108
}

0 commit comments

Comments
 (0)