From d933a42591738eb32918d196ec8b1dcab5eae4ca Mon Sep 17 00:00:00 2001 From: Barnaby Walters Date: Thu, 24 Jun 2021 13:32:24 +0200 Subject: [PATCH] Minor changes to make tests compatible with PHP 8.0 --- .../AuthorizationFormInterface.php.html | 8 +-- .../DefaultAuthorizationForm.php.html | 40 +++++------ ...serPasswordAuthenticationCallback.php.html | 16 ++--- docs/coverage/Callback/dashboard.html | 2 +- docs/coverage/Callback/index.html | 6 +- docs/coverage/IndieAuthException.php.html | 6 +- .../Middleware/ClosureRequestHandler.php.html | 10 +-- .../DoubleSubmitCookieCsrfMiddleware.php.html | 26 +++---- .../Middleware/NoOpMiddleware.php.html | 12 ++-- .../ResponseRequestHandler.php.html | 10 +-- docs/coverage/Middleware/dashboard.html | 2 +- docs/coverage/Middleware/index.html | 2 +- docs/coverage/Server.php.html | 72 +++++++++---------- .../Storage/FilesystemJsonStorage.php.html | 14 ++-- docs/coverage/Storage/Sqlite3Storage.php.html | 4 +- .../Storage/TokenStorageInterface.php.html | 4 +- docs/coverage/Storage/dashboard.html | 2 +- docs/coverage/Storage/index.html | 2 +- docs/coverage/dashboard.html | 4 +- docs/coverage/functions.php.html | 34 ++++----- docs/coverage/index.html | 20 +++--- tests/ServerTest.php | 8 +-- 22 files changed, 152 insertions(+), 152 deletions(-) diff --git a/docs/coverage/Callback/AuthorizationFormInterface.php.html b/docs/coverage/Callback/AuthorizationFormInterface.php.html index 19b5cc3..abd1180 100644 --- a/docs/coverage/Callback/AuthorizationFormInterface.php.html +++ b/docs/coverage/Callback/AuthorizationFormInterface.php.html @@ -64,10 +64,10 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Callback; + 3namespace Taproot\IndieAuth\Callback; 4 - 5use Psr\Http\Message\ServerRequestInterface; - 6use Psr\Http\Message\ResponseInterface; + 5use Psr\Http\Message\ServerRequestInterface; + 6use Psr\Http\Message\ResponseInterface; 7 8/** 9 * Authorization Form Interface @@ -163,7 +163,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Callback/DefaultAuthorizationForm.php.html b/docs/coverage/Callback/DefaultAuthorizationForm.php.html index 9525829..3fcdca4 100644 --- a/docs/coverage/Callback/DefaultAuthorizationForm.php.html +++ b/docs/coverage/Callback/DefaultAuthorizationForm.php.html @@ -68,7 +68,7 @@
100.00%
-
26 / 26
+
27 / 27
@@ -97,7 +97,7 @@
100.00%
-
26 / 26
+
27 / 27
@@ -139,7 +139,7 @@
100.00%
-
17 / 17
+
18 / 18
@@ -192,17 +192,17 @@
1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Callback; + 3namespace Taproot\IndieAuth\Callback; 4 - 5use BarnabyWalters\Mf2 as M; - 6use Psr\Http\Message\ServerRequestInterface; - 7use Nyholm\Psr7\Response; - 8use Psr\Http\Message\ResponseInterface; - 9use Psr\Log\LoggerAwareInterface; - 10use Psr\Log\LoggerInterface; - 11use Psr\Log\NullLogger; + 5use BarnabyWalters\Mf2 as M; + 6use Psr\Http\Message\ServerRequestInterface; + 7use Nyholm\Psr7\Response; + 8use Psr\Http\Message\ResponseInterface; + 9use Psr\Log\LoggerAwareInterface; + 10use Psr\Log\LoggerInterface; + 11use Psr\Log\NullLogger; 12 - 13use function Taproot\IndieAuth\renderTemplate; + 13use function Taproot\IndieAuth\renderTemplate; 14 15/** 16 * Default Authorization Form @@ -243,7 +243,7 @@ 51     */ 52    public function __construct(?string $formTemplatePath=null, ?string $csrfKey=null, ?LoggerInterface $logger=null) { 53        $this->formTemplatePath = $formTemplatePath ?? __DIR__ . '/../../templates/default_authorization_page.html.php'; - 54        $this->csrfKey = $csrfKey ?? \Taproot\IndieAuth\Server::DEFAULT_CSRF_KEY; + 54        $this->csrfKey = $csrfKey ?? \Taproot\IndieAuth\Server::DEFAULT_CSRF_KEY; 55        $this->logger = $logger ?? new NullLogger; 56    } 57 @@ -256,16 +256,16 @@ 64        } 65 66        if (is_null($clientHApp)) { - 67            $clientHApp = [ - 68                'type' => ['h-app'], + 67            $clientHApp = [ + 68                'type' => ['h-app'], 69                'properties' => [] 70            ]; 71        } 72 - 73        $hApp = [ - 74            'name' => M\getProp($clientHApp, 'name'), - 75            'url' => M\getProp($clientHApp, 'url'), - 76            'photo' => M\getProp($clientHApp, 'photo') + 73        $hApp = [ + 74            'name' => M\getProp($clientHApp, 'name'), + 75            'url' => M\getProp($clientHApp, 'url'), + 76            'photo' => M\getProp($clientHApp, 'photo') 77        ]; 78 79        return new Response(200, ['content-type' => 'text/html'], renderTemplate($this->formTemplatePath, [ @@ -308,7 +308,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Callback/SingleUserPasswordAuthenticationCallback.php.html b/docs/coverage/Callback/SingleUserPasswordAuthenticationCallback.php.html index 5638397..bcf5503 100644 --- a/docs/coverage/Callback/SingleUserPasswordAuthenticationCallback.php.html +++ b/docs/coverage/Callback/SingleUserPasswordAuthenticationCallback.php.html @@ -150,14 +150,14 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Callback; + 3namespace Taproot\IndieAuth\Callback; 4 5use BadMethodCallException; - 6use Dflydev\FigCookies; - 7use Nyholm\Psr7\Response; - 8use Psr\Http\Message\ServerRequestInterface; + 6use Dflydev\FigCookies; + 7use Nyholm\Psr7\Response; + 8use Psr\Http\Message\ServerRequestInterface; 9 - 10use function Taproot\IndieAuth\renderTemplate; + 10use function Taproot\IndieAuth\renderTemplate; 11 12/** 13 * Single User Password Authentication Callback @@ -247,7 +247,7 @@ 97        $this->user = $user; 98        $this->hashedPassword = $hashedPassword; 99        $this->formTemplate = $formTemplate ?? __DIR__ . '/../../templates/single_user_password_authentication_form.html.php'; - 100        $this->csrfKey = $csrfKey ?? \Taproot\IndieAuth\Server::DEFAULT_CSRF_KEY; + 100        $this->csrfKey = $csrfKey ?? \Taproot\IndieAuth\Server::DEFAULT_CSRF_KEY; 101    } 102 103    public function __invoke(ServerRequestInterface $request, string $formAction, ?string $normalizedMeUrl=null) { @@ -266,7 +266,7 @@ 116            $response = new Response(302, ['Location' => $formAction]); 117 118            // Set the user data hash cookie. - 119            $response = FigCookies\FigResponseCookies::set($response, FigCookies\SetCookie::create(self::LOGIN_HASH_COOKIE) + 119            $response = FigCookies\FigResponseCookies::set($response, FigCookies\SetCookie::create(self::LOGIN_HASH_COOKIE) 120                    ->withValue(hash_hmac('SHA256', json_encode($this->user), $this->secret)) 121                    ->withMaxAge($this->ttl) 122                    ->withSecure($request->getUri()->getScheme() == 'https') @@ -294,7 +294,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Callback/dashboard.html b/docs/coverage/Callback/dashboard.html index c92597f..ac2d1fb 100644 --- a/docs/coverage/Callback/dashboard.html +++ b/docs/coverage/Callback/dashboard.html @@ -136,7 +136,7 @@ diff --git a/docs/coverage/Callback/index.html b/docs/coverage/Callback/index.html index 48b326b..71808af 100644 --- a/docs/coverage/Callback/index.html +++ b/docs/coverage/Callback/index.html @@ -51,7 +51,7 @@
100.00%
-
56 / 56
+
57 / 57
100.00% covered (success) @@ -92,7 +92,7 @@
100.00%
-
26 / 26
+
27 / 27
100.00% covered (success) @@ -152,7 +152,7 @@ High: 90% to 100%

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/IndieAuthException.php.html b/docs/coverage/IndieAuthException.php.html index 3c8fd3e..82946c9 100644 --- a/docs/coverage/IndieAuthException.php.html +++ b/docs/coverage/IndieAuthException.php.html @@ -233,10 +233,10 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth; + 3namespace Taproot\IndieAuth; 4 5use Exception; - 6use Psr\Http\Message\ServerRequestInterface; + 6use Psr\Http\Message\ServerRequestInterface; 7use Throwable; 8 9class IndieAuthException extends Exception { @@ -327,7 +327,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Middleware/ClosureRequestHandler.php.html b/docs/coverage/Middleware/ClosureRequestHandler.php.html index 0a1d5fc..8d44734 100644 --- a/docs/coverage/Middleware/ClosureRequestHandler.php.html +++ b/docs/coverage/Middleware/ClosureRequestHandler.php.html @@ -150,11 +150,11 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Middleware; + 3namespace Taproot\IndieAuth\Middleware; 4 - 5use Psr\Http\Message\ServerRequestInterface; - 6use Psr\Http\Message\ResponseInterface; - 7use Psr\Http\Server\RequestHandlerInterface; + 5use Psr\Http\Message\ServerRequestInterface; + 6use Psr\Http\Message\ResponseInterface; + 7use Psr\Http\Server\RequestHandlerInterface; 8 9class ClosureRequestHandler implements RequestHandlerInterface { 10    protected $callable; @@ -181,7 +181,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Middleware/DoubleSubmitCookieCsrfMiddleware.php.html b/docs/coverage/Middleware/DoubleSubmitCookieCsrfMiddleware.php.html index 58d9d7f..40cde5a 100644 --- a/docs/coverage/Middleware/DoubleSubmitCookieCsrfMiddleware.php.html +++ b/docs/coverage/Middleware/DoubleSubmitCookieCsrfMiddleware.php.html @@ -192,19 +192,19 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Middleware; + 3namespace Taproot\IndieAuth\Middleware; 4 - 5use Nyholm\Psr7\Response; - 6use Psr\Http\Message\ServerRequestInterface; - 7use Psr\Http\Message\ResponseInterface; - 8use Psr\Http\Server\MiddlewareInterface; - 9use Psr\Http\Server\RequestHandlerInterface; - 10use Dflydev\FigCookies; - 11use Psr\Log\LoggerAwareInterface; - 12use Psr\Log\LoggerInterface; - 13use Psr\Log\NullLogger; + 5use Nyholm\Psr7\Response; + 6use Psr\Http\Message\ServerRequestInterface; + 7use Psr\Http\Message\ResponseInterface; + 8use Psr\Http\Server\MiddlewareInterface; + 9use Psr\Http\Server\RequestHandlerInterface; + 10use Dflydev\FigCookies; + 11use Psr\Log\LoggerAwareInterface; + 12use Psr\Log\LoggerInterface; + 13use Psr\Log\NullLogger; 14 - 15use function Taproot\IndieAuth\generateRandomPrintableAsciiString; + 15use function Taproot\IndieAuth\generateRandomPrintableAsciiString; 16 17/** 18 * Double-Submit Cookie CSRF Middleware @@ -297,7 +297,7 @@ 105        } 106 107        // Add the new CSRF cookie, restricting its scope to match the current request. - 108        $response = FigCookies\FigResponseCookies::set($response, FigCookies\SetCookie::create($this->attribute) + 108        $response = FigCookies\FigResponseCookies::set($response, FigCookies\SetCookie::create($this->attribute) 109                ->withValue($csrfToken) 110                ->withMaxAge($this->ttl) 111                ->withSecure($request->getUri()->getScheme() == 'https') @@ -328,7 +328,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Middleware/NoOpMiddleware.php.html b/docs/coverage/Middleware/NoOpMiddleware.php.html index 05b8192..a341f99 100644 --- a/docs/coverage/Middleware/NoOpMiddleware.php.html +++ b/docs/coverage/Middleware/NoOpMiddleware.php.html @@ -129,12 +129,12 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Middleware; + 3namespace Taproot\IndieAuth\Middleware; 4 - 5use Psr\Http\Message\ServerRequestInterface; - 6use Psr\Http\Message\ResponseInterface; - 7use Psr\Http\Server\MiddlewareInterface; - 8use Psr\Http\Server\RequestHandlerInterface; + 5use Psr\Http\Message\ServerRequestInterface; + 6use Psr\Http\Message\ResponseInterface; + 7use Psr\Http\Server\MiddlewareInterface; + 8use Psr\Http\Server\RequestHandlerInterface; 9 10/** 11 * No-Op Middleware @@ -157,7 +157,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Middleware/ResponseRequestHandler.php.html b/docs/coverage/Middleware/ResponseRequestHandler.php.html index c0278f4..91746b3 100644 --- a/docs/coverage/Middleware/ResponseRequestHandler.php.html +++ b/docs/coverage/Middleware/ResponseRequestHandler.php.html @@ -150,11 +150,11 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Middleware; + 3namespace Taproot\IndieAuth\Middleware; 4 - 5use Psr\Http\Message\ServerRequestInterface; - 6use Psr\Http\Message\ResponseInterface; - 7use Psr\Http\Server\RequestHandlerInterface; + 5use Psr\Http\Message\ServerRequestInterface; + 6use Psr\Http\Message\ResponseInterface; + 7use Psr\Http\Server\RequestHandlerInterface; 8 9class ResponseRequestHandler implements RequestHandlerInterface { 10    /** @var ResponseInterface $response */ @@ -178,7 +178,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Middleware/dashboard.html b/docs/coverage/Middleware/dashboard.html index 05f173b..f952890 100644 --- a/docs/coverage/Middleware/dashboard.html +++ b/docs/coverage/Middleware/dashboard.html @@ -138,7 +138,7 @@
diff --git a/docs/coverage/Middleware/index.html b/docs/coverage/Middleware/index.html index 680be06..186dc77 100644 --- a/docs/coverage/Middleware/index.html +++ b/docs/coverage/Middleware/index.html @@ -195,7 +195,7 @@ High: 90% to 100%

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Server.php.html b/docs/coverage/Server.php.html index bff0d16..5cfba40 100644 --- a/docs/coverage/Server.php.html +++ b/docs/coverage/Server.php.html @@ -61,13 +61,13 @@
4 / 5
CRAP
-
- 96.70% covered (success) +
+ 96.72% covered (success)
-
96.70%
-
264 / 273
+
96.72%
+
265 / 274
@@ -90,13 +90,13 @@
4 / 5
105
-
- 96.70% covered (success) +
+ 96.72% covered (success)
-
96.70%
-
264 / 273
+
96.72%
+
265 / 274
@@ -201,7 +201,7 @@
100.00%
-
11 / 11
+
12 / 12
@@ -212,27 +212,27 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth; + 3namespace Taproot\IndieAuth; 4 5use BadMethodCallException; - 6use BarnabyWalters\Mf2 as M; + 6use BarnabyWalters\Mf2 as M; 7use Exception; - 8use GuzzleHttp\Psr7\Header as HeaderParser; - 9use IndieAuth\Client as IndieAuthClient; + 8use GuzzleHttp\Psr7\Header as HeaderParser; + 9use IndieAuth\Client as IndieAuthClient; 10use Mf2; - 11use Nyholm\Psr7\Response; + 11use Nyholm\Psr7\Response; 12use PDO; - 13use Psr\Http\Client\ClientExceptionInterface; - 14use Psr\Http\Client\NetworkExceptionInterface; - 15use Psr\Http\Client\RequestExceptionInterface; - 16use Psr\Http\Message\ResponseInterface; - 17use Psr\Http\Message\ServerRequestInterface; - 18use Psr\Http\Server\MiddlewareInterface; - 19use Psr\Log\LoggerInterface; - 20use Psr\Log\NullLogger; - 21use Taproot\IndieAuth\Callback\AuthorizationFormInterface; - 22use Taproot\IndieAuth\Callback\DefaultAuthorizationForm; - 23use Taproot\IndieAuth\Storage\TokenStorageInterface; + 13use Psr\Http\Client\ClientExceptionInterface; + 14use Psr\Http\Client\NetworkExceptionInterface; + 15use Psr\Http\Client\RequestExceptionInterface; + 16use Psr\Http\Message\ResponseInterface; + 17use Psr\Http\Message\ServerRequestInterface; + 18use Psr\Http\Server\MiddlewareInterface; + 19use Psr\Log\LoggerInterface; + 20use Psr\Log\NullLogger; + 21use Taproot\IndieAuth\Callback\AuthorizationFormInterface; + 22use Taproot\IndieAuth\Callback\DefaultAuthorizationForm; + 23use Taproot\IndieAuth\Storage\TokenStorageInterface; 24 25/** 26 * IndieAuth Server @@ -419,7 +419,7 @@ 207     */ 208    public function __construct(array $config) { 209        $config = array_merge([ - 210            'csrfMiddleware' => new Middleware\DoubleSubmitCookieCsrfMiddleware(self::DEFAULT_CSRF_KEY), + 210            'csrfMiddleware' => new Middleware\DoubleSubmitCookieCsrfMiddleware(self::DEFAULT_CSRF_KEY), 211            'logger' => null, 212            self::HANDLE_NON_INDIEAUTH_REQUEST => function (ServerRequestInterface $request) { return null; }, // Default to no-op. 213            'tokenStorage' => null, @@ -458,10 +458,10 @@ 246        $this->handleNonIndieAuthRequest = $config[self::HANDLE_NON_INDIEAUTH_REQUEST]; 247 248        $tokenStorage = $config['tokenStorage']; - 249        if (!$tokenStorage instanceof Storage\TokenStorageInterface) { + 249        if (!$tokenStorage instanceof Storage\TokenStorageInterface) { 250            if (is_string($tokenStorage)) { 251                // Create a default access token storage with a TTL of 7 days. - 252                $tokenStorage = new Storage\FilesystemJsonStorage($tokenStorage, $this->secret); + 252                $tokenStorage = new Storage\FilesystemJsonStorage($tokenStorage, $this->secret); 253            } else { 254                throw new BadMethodCallException("\$config['tokenStorage'] parameter must be either a string (path) or an instance of Taproot\IndieAuth\TokenStorageInterface."); 255            } @@ -482,8 +482,8 @@ 270                $httpGetWithEffectiveUrl = function (string $uri): array { 271                    // This code can’t be tested, ignore it for coverage purposes. 272                    // @codeCoverageIgnoreStart - 273                    $resp = (new \GuzzleHttp\Client([ - 274                        \GuzzleHttp\RequestOptions::ALLOW_REDIRECTS => [ + 273                    $resp = (new \GuzzleHttp\Client([ + 274                        \GuzzleHttp\RequestOptions::ALLOW_REDIRECTS => [ 275                            'max' => 10, 276                            'strict' => true, 277                            'referer' => true, @@ -650,7 +650,7 @@ 438 439        // Because the special case above isn’t allowed to be CSRF-protected, we have to do some rather silly 440        // closure gymnastics here to selectively-CSRF-protect requests which do need it. - 441        return $this->csrfMiddleware->process($request, new Middleware\ClosureRequestHandler(function (ServerRequestInterface $request) { + 441        return $this->csrfMiddleware->process($request, new Middleware\ClosureRequestHandler(function (ServerRequestInterface $request) { 442            // Wrap the entire user-facing handler in a try/catch block which catches any exception, converts it 443            // to IndieAuthException if necessary, then passes it to $this->handleException() to be turned into a 444            // response. @@ -693,7 +693,7 @@ 481                            // needs to parse client_id for h-app markup. 482                            try { 483                                list($clientIdResponse, $clientIdEffectiveUrl) = call_user_func($this->httpGetWithEffectiveUrl, $queryParams['client_id']); - 484                                $clientIdMf2 = Mf2\parse((string) $clientIdResponse->getBody(), $clientIdEffectiveUrl); + 484                                $clientIdMf2 = Mf2\parse((string) $clientIdResponse->getBody(), $clientIdEffectiveUrl); 485                            } catch (ClientExceptionInterface | RequestExceptionInterface | NetworkExceptionInterface $e) { 486                                $this->logger->error("Caught an HTTP exception while trying to fetch the client_id. Returning an error response.", [ 487                                    'client_id' => $queryParams['client_id'], @@ -869,7 +869,7 @@ 657                            try { 658                                /** @var ResponseInterface $clientIdResponse */ 659                                list($clientIdResponse, $clientIdEffectiveUrl) = call_user_func($this->httpGetWithEffectiveUrl, $queryParams['client_id']); - 660                                $clientIdMf2 = Mf2\parse((string) $clientIdResponse->getBody(), $clientIdEffectiveUrl); + 660                                $clientIdMf2 = Mf2\parse((string) $clientIdResponse->getBody(), $clientIdEffectiveUrl); 661                            } catch (ClientExceptionInterface | RequestExceptionInterface | NetworkExceptionInterface $e) { 662                                $this->logger->error("Caught an HTTP exception while trying to fetch the client_id. Returning an error response.", [ 663                                    'client_id' => $queryParams['client_id'], @@ -889,7 +889,7 @@ 677                        } 678                         679                        // Search for an h-app with u-url matching the client_id. - 680                        $clientHApps = M\findMicroformatsByProperty(M\findMicroformatsByType($clientIdMf2, 'h-app'), 'url', $queryParams['client_id']); + 680                        $clientHApps = M\findMicroformatsByProperty(M\findMicroformatsByType($clientIdMf2, 'h-app'), 'url', $queryParams['client_id']); 681                        $clientHApp = empty($clientHApps) ? null : $clientHApps[0]; 682 683                        // Present the authorization UI. @@ -1046,7 +1046,7 @@ 834 835        if ($exceptionData['statusCode'] == 302) { 836            // This exception is handled by redirecting to the redirect_uri with error parameters. - 837            $redirectQueryParams = [ + 837            $redirectQueryParams = [ 838                'error' => $exceptionData['error'] ?? 'invalid_request', 839                'error_description' => (string) $exception 840            ]; @@ -1078,7 +1078,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Storage/FilesystemJsonStorage.php.html b/docs/coverage/Storage/FilesystemJsonStorage.php.html index cc7e7c4..33cd0ed 100644 --- a/docs/coverage/Storage/FilesystemJsonStorage.php.html +++ b/docs/coverage/Storage/FilesystemJsonStorage.php.html @@ -381,16 +381,16 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Storage; + 3namespace Taproot\IndieAuth\Storage; 4 5use DirectoryIterator; 6use Exception; - 7use Psr\Log\LoggerAwareInterface; - 8use Psr\Log\LoggerInterface; - 9use Psr\Log\NullLogger; - 10use Taproot\IndieAuth\IndieAuthException; + 7use Psr\Log\LoggerAwareInterface; + 8use Psr\Log\LoggerInterface; + 9use Psr\Log\NullLogger; + 10use Taproot\IndieAuth\IndieAuthException; 11 - 12use function Taproot\IndieAuth\generateRandomString; + 12use function Taproot\IndieAuth\generateRandomString; 13 14/** 15 * Filesystem JSON Token Storage @@ -694,7 +694,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Storage/Sqlite3Storage.php.html b/docs/coverage/Storage/Sqlite3Storage.php.html index 4c55e42..082c046 100644 --- a/docs/coverage/Storage/Sqlite3Storage.php.html +++ b/docs/coverage/Storage/Sqlite3Storage.php.html @@ -64,7 +64,7 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Storage; + 3namespace Taproot\IndieAuth\Storage; 4 5/*class Sqlite3Storage implements TokenStorageInterface { 6     @@ -79,7 +79,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Storage/TokenStorageInterface.php.html b/docs/coverage/Storage/TokenStorageInterface.php.html index acc9d0b..2202ece 100644 --- a/docs/coverage/Storage/TokenStorageInterface.php.html +++ b/docs/coverage/Storage/TokenStorageInterface.php.html @@ -64,7 +64,7 @@ 1<?php declare(strict_types=1); 2 - 3namespace Taproot\IndieAuth\Storage; + 3namespace Taproot\IndieAuth\Storage; 4 5/** 6 * Token Storage Interface @@ -235,7 +235,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/Storage/dashboard.html b/docs/coverage/Storage/dashboard.html index 2fb5c19..b063d15 100644 --- a/docs/coverage/Storage/dashboard.html +++ b/docs/coverage/Storage/dashboard.html @@ -148,7 +148,7 @@
diff --git a/docs/coverage/Storage/index.html b/docs/coverage/Storage/index.html index af38b87..5985af9 100644 --- a/docs/coverage/Storage/index.html +++ b/docs/coverage/Storage/index.html @@ -137,7 +137,7 @@ High: 90% to 100%

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/dashboard.html b/docs/coverage/dashboard.html index e02386b..a902470 100644 --- a/docs/coverage/dashboard.html +++ b/docs/coverage/dashboard.html @@ -156,7 +156,7 @@ @@ -243,7 +243,7 @@ $(document).ready(function() { chart.yAxis.axisLabel('Cyclomatic Complexity'); d3.select('#classComplexity svg') - .datum(getComplexityData([[100,6,"Taproot\\IndieAuth\\Callback\\DefaultAuthorizationForm<\/a>"],[100,10,"Taproot\\IndieAuth\\Callback\\SingleUserPasswordAuthenticationCallback<\/a>"],[66.66666666666666,8,"Taproot\\IndieAuth\\IndieAuthException<\/a>"],[100,2,"Taproot\\IndieAuth\\Middleware\\ClosureRequestHandler<\/a>"],[96.875,12,"Taproot\\IndieAuth\\Middleware\\DoubleSubmitCookieCsrfMiddleware<\/a>"],[0,1,"Taproot\\IndieAuth\\Middleware\\NoOpMiddleware<\/a>"],[100,2,"Taproot\\IndieAuth\\Middleware\\ResponseRequestHandler<\/a>"],[96.7032967032967,105,"Taproot\\IndieAuth\\Server<\/a>"],[84.87394957983193,46,"Taproot\\IndieAuth\\Storage\\FilesystemJsonStorage<\/a>"]], 'Class Complexity')) + .datum(getComplexityData([[100,6,"Taproot\\IndieAuth\\Callback\\DefaultAuthorizationForm<\/a>"],[100,10,"Taproot\\IndieAuth\\Callback\\SingleUserPasswordAuthenticationCallback<\/a>"],[66.66666666666666,8,"Taproot\\IndieAuth\\IndieAuthException<\/a>"],[100,2,"Taproot\\IndieAuth\\Middleware\\ClosureRequestHandler<\/a>"],[96.875,12,"Taproot\\IndieAuth\\Middleware\\DoubleSubmitCookieCsrfMiddleware<\/a>"],[0,1,"Taproot\\IndieAuth\\Middleware\\NoOpMiddleware<\/a>"],[100,2,"Taproot\\IndieAuth\\Middleware\\ResponseRequestHandler<\/a>"],[96.71532846715328,105,"Taproot\\IndieAuth\\Server<\/a>"],[84.87394957983193,46,"Taproot\\IndieAuth\\Storage\\FilesystemJsonStorage<\/a>"]], 'Class Complexity')) .transition() .duration(500) .call(chart); diff --git a/docs/coverage/functions.php.html b/docs/coverage/functions.php.html index a58447c..838fd64 100644 --- a/docs/coverage/functions.php.html +++ b/docs/coverage/functions.php.html @@ -56,13 +56,13 @@
16 / 18
CRAP
-
- 97.62% covered (success) +
+ 97.56% covered (success)
-
97.62%
-
82 / 84
+
97.56%
+
80 / 82
@@ -328,14 +328,14 @@
0.00%
0 / 1
1.00 -
-
- 90.91% covered (success) +
+
+ 88.89% covered (warning)
-
90.91%
-
10 / 11
+
88.89%
+
8 / 9
@@ -451,12 +451,12 @@
1<?php 2 - 3namespace Taproot\IndieAuth; + 3namespace Taproot\IndieAuth; 4 5use Exception; - 6use Psr\Http\Message\ServerRequestInterface; - 7use Psr\Log\LoggerAwareInterface; - 8use Psr\Log\LoggerInterface; + 6use Psr\Http\Message\ServerRequestInterface; + 7use Psr\Log\LoggerAwareInterface; + 8use Psr\Log\LoggerInterface; 9 10// From https://github.com/indieweb/indieauth-client-php/blob/main/src/IndieAuth/Client.php, thanks aaronpk. 11function generateRandomString(int $numBytes): string { @@ -568,7 +568,7 @@ 117    } 118     119    $queryString = buildQueryString($queryParams); - 120    $separator = parse_url($uri, \PHP_URL_QUERY) ? '&' : '?'; + 120    $separator = parse_url($uri, \PHP_URL_QUERY) ? '&' : '?'; 121    $uri = rtrim($uri, '?&'); 122    return "{$uri}{$separator}{$queryString}"; 123} @@ -593,13 +593,13 @@ 142    $render = function ($__template, $__templateData) { 143        $render = function ($template, $data){ 144            return renderTemplate($template, $data); - 145        }; + 145        }; 146        ob_start(); 147        extract($__templateData); 148        unset($__templateData); 149        include $__template; 150        return ob_get_clean(); - 151    }; + 151    }; 152    return $render($template, $context); 153} 154 @@ -687,7 +687,7 @@

Legend

ExecutedNot ExecutedDead Code

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/docs/coverage/index.html b/docs/coverage/index.html index 0e6dae1..f0c8d9d 100644 --- a/docs/coverage/index.html +++ b/docs/coverage/index.html @@ -78,7 +78,7 @@
100.00%
-
56 / 56
+
57 / 57
100.00% covered (success) @@ -184,13 +184,13 @@ Server.php
-
- 96.70% covered (success) +
+ 96.72% covered (success)
-
96.70%
-
264 / 273
+
96.72%
+
265 / 274
80.00% covered (warning) @@ -212,13 +212,13 @@ functions.php
-
- 97.62% covered (success) +
+ 97.56% covered (success)
-
97.62%
-
82 / 84
+
97.56%
+
80 / 82
88.89% covered (warning) @@ -245,7 +245,7 @@ High: 90% to 100%

- Generated by php-code-coverage 9.2.6 using PHP 7.3.28 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:29:20 UTC 2021. + Generated by php-code-coverage 9.2.6 using PHP 8.0.7 with Xdebug 3.0.4 and PHPUnit 9.5.5 at Thu Jun 24 11:32:05 UTC 2021.

diff --git a/tests/ServerTest.php b/tests/ServerTest.php index 9f7e6c7..20848fa 100644 --- a/tests/ServerTest.php +++ b/tests/ServerTest.php @@ -320,7 +320,7 @@ class ServerTest extends TestCase { 'httpGetWithEffectiveUrl' => function (string $url): array { // An empty response suffices for this test. return [ - new Response(200, ['content-type' => 'text/html'], '' ), + new Response(200, ['content-type' => 'text/html'], '' ), $url ]; } @@ -378,7 +378,7 @@ EOT }, 'httpGetWithEffectiveUrl' => function ($url): array { return [ - new Response(200, ['content-type' => 'text/html'], ''), // An empty response suffices for this test. + new Response(200, ['content-type' => 'text/html'], ''), // An empty response suffices for this test. $url ]; } @@ -406,7 +406,7 @@ EOT 'content-type' => 'text/html', 'link' => '; rel="another_rel redirect_uri"' ], - '' + '' ), $url ]; @@ -594,7 +594,7 @@ EOT }, 'httpGetWithEffectiveUrl' => function ($url): array { return [ - new Response(200, ['content-type' => 'text/html'], ''), + new Response(200, ['content-type' => 'text/html'], ''), $url ]; }