From b7e2bdf33e9ad929baceea986d0896188e9f6000 Mon Sep 17 00:00:00 2001 From: Witold Wasiczko Date: Wed, 11 May 2022 12:15:00 +0200 Subject: [PATCH] Fix PHP 8.1 deprecation error --- src/OAuth2/TokenType/Bearer.php | 2 +- test/OAuth2/TokenType/BearerTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/OAuth2/TokenType/Bearer.php b/src/OAuth2/TokenType/Bearer.php index 8ac8596ac..aa1094b1e 100644 --- a/src/OAuth2/TokenType/Bearer.php +++ b/src/OAuth2/TokenType/Bearer.php @@ -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); } diff --git a/test/OAuth2/TokenType/BearerTest.php b/test/OAuth2/TokenType/BearerTest.php index 71cca3bd9..021fc7f5a 100644 --- a/test/OAuth2/TokenType/BearerTest.php +++ b/test/OAuth2/TokenType/BearerTest.php @@ -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();