Skip to content

Commit

Permalink
Fix PHP 8.1 deprecation error
Browse files Browse the repository at this point in the history
  • Loading branch information
snapshotpl committed May 31, 2022
1 parent 60254fc commit b7e2bdf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/OAuth2/TokenType/Bearer.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getAccessTokenParameter(RequestInterface $request, ResponseInter
}

$contentType = $request->server('CONTENT_TYPE');
if (false !== $pos = strpos($contentType, ';')) {
if (false !== $pos = strpos((string) $contentType, ';')) {
$contentType = substr($contentType, 0, $pos);
}

Expand Down
11 changes: 11 additions & 0 deletions test/OAuth2/TokenType/BearerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ public function testInvalidContentType()
$this->assertEquals($response->getParameter('error_description'), 'The content type for POST requests must be "application/x-www-form-urlencoded"');
}

public function testMissingContentTypeExpectsToBeCorrectContent()
{
$bearer = new Bearer();
$request = TestRequest::createPost(array(
'access_token' => 'ThisIsMyAccessToken'
));

$param = $bearer->getAccessTokenParameter($request, $response = new Response());
$this->assertEquals($param, 'ThisIsMyAccessToken');
}

public function testValidRequestUsingAuthorizationHeader()
{
$bearer = new Bearer();
Expand Down

0 comments on commit b7e2bdf

Please sign in to comment.