Skip to content

Commit 5a0c800

Browse files
authored
fixes incorrect parameter type for count in php72 (#953)
1 parent b8051e9 commit 5a0c800

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/OAuth2/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function setRedirect($statusCode, $url, $state = null, $error = null, $er
366366
if (count($this->parameters) > 0) {
367367
// add parameters to URL redirection
368368
$parts = parse_url($url);
369-
$sep = isset($parts['query']) && count($parts['query']) > 0 ? '&' : '?';
369+
$sep = isset($parts['query']) && !empty($parts['query']) ? '&' : '?';
370370
$url .= $sep . http_build_query($this->parameters);
371371
}
372372

test/OAuth2/ResponseTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
namespace OAuth2;use PHPUnit\Framework\TestCase;
3+
namespace OAuth2;
4+
5+
use PHPUnit\Framework\TestCase;
46

57
class ResponseTest extends TestCase
68
{
@@ -14,4 +16,23 @@ public function testRenderAsXml()
1416
$string = $response->getResponseBody('xml');
1517
$this->assertContains('<response><foo>bar</foo><halland>oates</halland></response>', $string);
1618
}
19+
20+
public function testSetRedirect()
21+
{
22+
$response = new Response();
23+
$url = 'https://foo/bar';
24+
$state = 'stateparam';
25+
$response->setRedirect(301, $url, $state);
26+
$this->assertEquals(
27+
sprintf('%s?state=%s', $url, $state),
28+
$response->getHttpHeader('Location')
29+
);
30+
31+
$query = 'query=foo';
32+
$response->setRedirect(301, $url . '?' . $query, $state);
33+
$this->assertEquals(
34+
sprintf('%s?%s&state=%s', $url, $query, $state),
35+
$response->getHttpHeader('Location')
36+
);
37+
}
1738
}

0 commit comments

Comments
 (0)