Skip to content

Commit

Permalink
Use FQCN in DocBlocks (#223)
Browse files Browse the repository at this point in the history
* Replace use-statements with fqdn phpdocs (src)

* Replace use-statements with fqdn phpdocs (tests)

* Remove duplicate sniffs - already part of SSP test-framework
  • Loading branch information
tvdijen authored May 29, 2024
1 parent 7c001c5 commit 909c0a1
Show file tree
Hide file tree
Showing 166 changed files with 1,025 additions and 1,280 deletions.
17 changes: 7 additions & 10 deletions hooks/hook_cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
* file that was distributed with this source code.
*/

use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use SimpleSAML\Logger;
use SimpleSAML\Module\oidc\ModuleConfig;
use SimpleSAML\Module\oidc\Repositories\AccessTokenRepository;
Expand All @@ -25,11 +23,10 @@
use SimpleSAML\Module\oidc\Services\Container;

/**
* @param array $croninfo
* @throws OidcServerException
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
* @throws Exception
* @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Exception
*/
function oidc_hook_cron(array &$croninfo): void
{
Expand All @@ -55,15 +52,15 @@ function oidc_hook_cron(array &$croninfo): void
$container = new Container();

try {
/** @var AccessTokenRepository $accessTokenRepository */
/** @var \SimpleSAML\Module\oidc\Repositories\AccessTokenRepository $accessTokenRepository */
$accessTokenRepository = $container->get(AccessTokenRepository::class);
$accessTokenRepository->removeExpired();

/** @var AuthCodeRepository $authTokenRepository */
/** @var \SimpleSAML\Module\oidc\Repositories\AuthCodeRepository $authTokenRepository */
$authTokenRepository = $container->get(AuthCodeRepository::class);
$authTokenRepository->removeExpired();

/** @var RefreshTokenRepository $refreshTokenRepository */
/** @var \SimpleSAML\Module\oidc\Repositories\RefreshTokenRepository $refreshTokenRepository */
$refreshTokenRepository = $container->get(RefreshTokenRepository::class);
$refreshTokenRepository->removeExpired();

Expand Down
5 changes: 4 additions & 1 deletion hooks/hook_federationpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
* file that was distributed with this source code.
*/

use SimpleSAML\Locale\Translate;
use SimpleSAML\Module;
use SimpleSAML\Module\oidc\Services\DatabaseMigration;
use SimpleSAML\XHTML\Template;
use SimpleSAML\Locale\Translate;

/**
* @param \SimpleSAML\XHTML\Template $template
*/
function oidc_hook_federationpage(Template $template): void
{
$href = Module::getModuleURL('oidc/admin-clients/index.php');
Expand Down
2 changes: 2 additions & 0 deletions hooks/hook_frontpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
use SimpleSAML\Module;
use SimpleSAML\Module\oidc\Services\DatabaseMigration;

/**
*/
function oidc_hook_frontpage(array &$links): void
{
if (!is_array($links['federation'])) {
Expand Down
8 changes: 1 addition & 7 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@

<!-- This is the rule we inherit from. If you want to exlude some specific rules, see the docs on how to do that -->
<rule ref="PSR12"/>
<!-- <rule ref="vendor/simplesamlphp/simplesamlphp-test-framework/phpcs-simplesamlphp.xml"/> -->

<!-- Enforce the use of trailing commas -->
<rule ref="SlevomatCodingStandard.Arrays.TrailingArrayComma" />
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInCall" />
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInClosureUse" />
<rule ref="SlevomatCodingStandard.Functions.RequireTrailingCommaInDeclaration" />
<rule ref="vendor/simplesamlphp/simplesamlphp-test-framework/phpcs-simplesamlphp.xml"/>

<rule ref="Generic.WhiteSpace.ScopeIndent">
<properties>
Expand Down
4 changes: 3 additions & 1 deletion src/Bridges/SspBridge/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

namespace SimpleSAML\Module\oidc\Bridges\SspBridge;

use SimpleSAML\Module as SspModule;

class Module
{
public function getModuleUrl(string $resource, array $parameters = []): string
{
return \SimpleSAML\Module::getModuleURL($resource, $parameters);
return SspModule::getModuleURL($resource, $parameters);
}
}
3 changes: 1 addition & 2 deletions src/Controller/AccessTokenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

use Laminas\Diactoros\Response;
use Laminas\Diactoros\ServerRequest;
use League\OAuth2\Server\Exception\OAuthServerException;
use Psr\Http\Message\ResponseInterface;
use SimpleSAML\Module\oidc\Controller\Traits\RequestTrait;
use SimpleSAML\Module\oidc\Repositories\AllowedOriginRepository;
Expand All @@ -34,7 +33,7 @@ public function __construct(
}

/**
* @throws OAuthServerException
* @throws \League\OAuth2\Server\Exception\OAuthServerException
*/
public function __invoke(ServerRequest $request): ResponseInterface
{
Expand Down
22 changes: 10 additions & 12 deletions src/Controller/AuthorizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,15 @@

namespace SimpleSAML\Module\oidc\Controller;

use Exception;
use Laminas\Diactoros\Response;
use Laminas\Diactoros\ServerRequest;
use League\OAuth2\Server\Exception\OAuthServerException;
use Psr\Http\Message\ResponseInterface;
use SimpleSAML\Error;
use SimpleSAML\Module\oidc\ModuleConfig;
use SimpleSAML\Module\oidc\Server\AuthorizationServer;
use SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException;
use SimpleSAML\Module\oidc\Server\RequestTypes\AuthorizationRequest;
use SimpleSAML\Module\oidc\Services\AuthenticationService;
use SimpleSAML\Module\oidc\Services\LoggerService;
use Throwable;

class AuthorizationController
{
Expand All @@ -41,12 +37,13 @@ public function __construct(
}

/**
* @throws Error\AuthSource
* @throws Error\BadRequest
* @throws Error\NotFound
* @throws Error\Exception
* @throws OAuthServerException
* @throws Exception|Throwable
* @throws \Exception
* @throws \SimpleSAML\Error\AuthSource
* @throws \SimpleSAML\Error\BadRequest
* @throws \SimpleSAML\Error\NotFound
* @throws \SimpleSAML\Error\Exception
* @throws \League\OAuth2\Server\Exception\OAuthServerException
* @throws \Throwable
*/
public function __invoke(ServerRequest $request): ResponseInterface
{
Expand All @@ -71,15 +68,16 @@ public function __invoke(ServerRequest $request): ResponseInterface
/**
* Validate authorization request after the authn has been performed. For example, check if the
* ACR claim has been requested and that authn performed satisfies it.
* @throws Exception
*
* @throws \Exception
*/
protected function validatePostAuthnAuthorizationRequest(AuthorizationRequest $authorizationRequest): void
{
$this->validateAcr($authorizationRequest);
}

/**
* @throws Exception
* @throws \Exception
*/
protected function validateAcr(AuthorizationRequest $authorizationRequest): void
{
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Client/CreateController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace SimpleSAML\Module\oidc\Controller\Client;

use Laminas\Diactoros\Response\RedirectResponse;
use SimpleSAML\Error\Exception;
use SimpleSAML\Module\oidc\Entities\ClientEntity;
use SimpleSAML\Module\oidc\Factories\FormFactory;
use SimpleSAML\Module\oidc\Factories\TemplateFactory;
Expand All @@ -44,8 +43,9 @@ public function __construct(
}

/**
* @return RedirectResponse|Template
* @throws Exception
* @return \Laminas\Diactoros\Response\RedirectResponse|\SimpleSAML\XHTML\Template
* @throws \SimpleSAML\Error\Exception
* @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
* @throws \Exception
*/
public function __invoke(): Template|RedirectResponse
Expand Down
18 changes: 9 additions & 9 deletions src/Controller/Client/DeleteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,12 @@

namespace SimpleSAML\Module\oidc\Controller\Client;

use JsonException;
use Laminas\Diactoros\Response\RedirectResponse;
use Laminas\Diactoros\ServerRequest;
use SimpleSAML\Error\BadRequest;
use SimpleSAML\Error\ConfigurationError;
use SimpleSAML\Error\Exception;
use SimpleSAML\Error\NotFound;
use SimpleSAML\Error;
use SimpleSAML\Module\oidc\Controller\Traits\AuthenticatedGetClientFromRequestTrait;
use SimpleSAML\Module\oidc\Factories\TemplateFactory;
use SimpleSAML\Module\oidc\Repositories\ClientRepository;
use SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException;
use SimpleSAML\Module\oidc\Services\AuthContextService;
use SimpleSAML\Module\oidc\Services\SessionMessagesService;
use SimpleSAML\Utils\HTTP;
Expand All @@ -47,8 +42,13 @@ public function __construct(
}

/**
* @throws ConfigurationError|BadRequest|NotFound|Exception|OidcServerException|JsonException
* @throws \Exception
* @throws \JsonException
* @throws \SimpleSAML\Error\BadRequest
* @throws \SimpleSAML\Error\ConfigurationError
* @throws \SimpleSAML\Error\Exception
* @throws \SimpleSAML\Error\NotFound
* @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
*/
public function __invoke(ServerRequest $request): Template|RedirectResponse
{
Expand All @@ -58,11 +58,11 @@ public function __invoke(ServerRequest $request): Template|RedirectResponse
$authedUser = $this->authContextService->isSspAdmin() ? null : $this->authContextService->getAuthUserId();
if ('POST' === mb_strtoupper($request->getMethod())) {
if (!$clientSecret) {
throw new BadRequest('Client secret is missing.');
throw new Error\BadRequest('Client secret is missing.');
}

if ($clientSecret !== $client->getSecret()) {
throw new BadRequest('Client secret is invalid.');
throw new Error\BadRequest('Client secret is invalid.');
}

$this->clientRepository->delete($client, $authedUser);
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/Client/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

use Laminas\Diactoros\Response\RedirectResponse;
use Laminas\Diactoros\ServerRequest;
use SimpleSAML\Error\BadRequest;
use SimpleSAML\Error\Exception;
use SimpleSAML\Error\NotFound;
use SimpleSAML\Module\oidc\Controller\Traits\AuthenticatedGetClientFromRequestTrait;
use SimpleSAML\Module\oidc\Entities\ClientEntity;
use SimpleSAML\Module\oidc\Factories\FormFactory;
Expand Down Expand Up @@ -51,7 +48,10 @@ public function __construct(
}

/**
* @throws BadRequest|Exception|NotFound|\Exception
* @throws \Exception
* @throws \SimpleSAML\Error\BadRequest
* @throws \SimpleSAML\Error\Exception
* @throws \SimpleSAML\Error\NotFound
*/
public function __invoke(ServerRequest $request): Template|RedirectResponse
{
Expand Down
3 changes: 1 addition & 2 deletions src/Controller/Client/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
namespace SimpleSAML\Module\oidc\Controller\Client;

use Laminas\Diactoros\ServerRequest;
use SimpleSAML\Error\Exception;
use SimpleSAML\Module\oidc\Factories\TemplateFactory;
use SimpleSAML\Module\oidc\Repositories\ClientRepository;
use SimpleSAML\Module\oidc\Services\AuthContextService;
Expand All @@ -33,8 +32,8 @@ public function __construct(
}

/**
* @throws Exception
* @throws \Exception
* @throws \SimpleSAML\Error\Exception
*/
public function __invoke(ServerRequest $request): Template
{
Expand Down
14 changes: 6 additions & 8 deletions src/Controller/Client/ResetSecretController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

use Laminas\Diactoros\Response\RedirectResponse;
use Laminas\Diactoros\ServerRequest;
use SimpleSAML\Error\BadRequest;
use SimpleSAML\Error\Exception;
use SimpleSAML\Error\NotFound;
use SimpleSAML\Error;
use SimpleSAML\Module\oidc\Controller\Traits\AuthenticatedGetClientFromRequestTrait;
use SimpleSAML\Module\oidc\Repositories\ClientRepository;
use SimpleSAML\Module\oidc\Services\AuthContextService;
Expand All @@ -42,10 +40,10 @@ public function __construct(
}

/**
* @throws BadRequest
* @throws NotFound
* @throws Exception
* @throws \Exception
* @throws \SimpleSAML\Error\Exception
* @throws \SimpleSAML\Error\BadRequest
* @throws \SimpleSAML\Error\NotFound
*/
public function __invoke(ServerRequest $request): RedirectResponse
{
Expand All @@ -55,11 +53,11 @@ public function __invoke(ServerRequest $request): RedirectResponse

if ('POST' === mb_strtoupper($request->getMethod())) {
if (!$clientSecret) {
throw new BadRequest('Client secret is missing.');
throw new Error\BadRequest('Client secret is missing.');
}

if ($clientSecret !== $client->getSecret()) {
throw new BadRequest('Client secret is invalid.');
throw new Error\BadRequest('Client secret is invalid.');
}

$client->restoreSecret((new Random())->generateID());
Expand Down
11 changes: 5 additions & 6 deletions src/Controller/Client/ShowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@
*/
namespace SimpleSAML\Module\oidc\Controller\Client;

use JsonException;
use Laminas\Diactoros\ServerRequest;
use SimpleSAML\Error\BadRequest;
use SimpleSAML\Error\Exception;
use SimpleSAML\Error\NotFound;
use SimpleSAML\Module\oidc\Controller\Traits\AuthenticatedGetClientFromRequestTrait;
use SimpleSAML\Module\oidc\Factories\TemplateFactory;
use SimpleSAML\Module\oidc\Repositories\AllowedOriginRepository;
use SimpleSAML\Module\oidc\Repositories\ClientRepository;
use SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException;
use SimpleSAML\Module\oidc\Services\AuthContextService;
use SimpleSAML\XHTML\Template;

Expand All @@ -43,7 +38,11 @@ public function __construct(
}

/**
* @throws BadRequest|Exception|NotFound|OidcServerException|JsonException
* @throws \JsonException
* @throws \SimpleSAML\Error\BadRequest
* @throws \SimpleSAML\Error\Exception
* @throws \SimpleSAML\Error\NotFound
* @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
*/
public function __invoke(ServerRequest $request): Template
{
Expand Down
5 changes: 2 additions & 3 deletions src/Controller/Federation/EntityStatementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use SimpleSAML\Module\oidc\Codebooks\ClaimValues\TypeEnum;
use SimpleSAML\Module\oidc\Codebooks\EntityTypeEnum;
use SimpleSAML\Module\oidc\ModuleConfig;
use SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException;
use SimpleSAML\Module\oidc\Services\JsonWebKeySetService;
use SimpleSAML\Module\oidc\Services\JsonWebTokenBuilderService;
use SimpleSAML\Module\oidc\Services\OpMetadataService;
Expand All @@ -27,8 +26,8 @@ public function __construct(

/**
* Return the JWS with the OP configuration statement.
* @return Response
* @throws OidcServerException
* @return \Symfony\Component\HttpFoundation\Response
* @throws \SimpleSAML\Module\oidc\Server\Exceptions\OidcServerException
*/
public function configuration(): Response
{
Expand Down
9 changes: 4 additions & 5 deletions src/Controller/InstallerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
*/
namespace SimpleSAML\Module\oidc\Controller;

use Exception;
use SimpleSAML\XHTML\Template;
use Laminas\Diactoros\Response\RedirectResponse;
use Laminas\Diactoros\ServerRequest;
use SimpleSAML\Module;
use SimpleSAML\Module\oidc\Factories\TemplateFactory;
use SimpleSAML\Module\oidc\Services\DatabaseLegacyOAuth2Import;
use SimpleSAML\Module\oidc\Services\DatabaseMigration;
use SimpleSAML\Module\oidc\Services\SessionMessagesService;
use SimpleSAML\Utils\HTTP;
use Laminas\Diactoros\Response\RedirectResponse;
use Laminas\Diactoros\ServerRequest;
use SimpleSAML\XHTML\Template;

use function in_array;

Expand All @@ -39,7 +38,7 @@ public function __construct(
}

/**
* @throws Exception
* @throws \Exception
*/
public function __invoke(ServerRequest $request): Template|RedirectResponse
{
Expand Down
Loading

0 comments on commit 909c0a1

Please sign in to comment.