Skip to content

Commit

Permalink
Fix some issues reported by scrutinizer
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed May 12, 2023
1 parent f1241e0 commit 29f7b69
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 41 deletions.
2 changes: 1 addition & 1 deletion modules/admin/src/Controller/Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function main(Request $request, string $as = null): Response
* @param \Symfony\Component\HttpFoundation\Request $request
* @return \SimpleSAML\XHTML\Template
*/
public function logout(Request $request): Template
public function logout(/** @scrutinizer-ignore-unused*/Request $request): Template
{
return new Template($this->config, 'admin:logout.twig');
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/Auth/Source/AbstractSourceSelector.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(array $info, array $config)
* save the state, and at a later stage, load the state, update it with the authentication
* information about the user, and call completeAuth with the state array.
*
* @param \Symfony\Component\HttpFoundation\Request The current request
* @param \Symfony\Component\HttpFoundation\Request $request The current request
* @param array &$state Information about the current authentication.
*/
public function authenticate(Request $request, array &$state): ?Response
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/Auth/UserPassBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function isRememberMeChecked(): bool
* This function saves the information about the login, and redirects to a
* login page.
*
* @param \Symfony\Component\HttpFoundation\Request The current request
* @param \Symfony\Component\HttpFoundation\Request $request The current request
* @param array &$state Information about the current authentication.
*/
public function authenticate(Request $request, array &$state): ?Response
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/Auth/UserPassOrgBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public function getRememberOrganizationChecked(): bool
* This function saves the information about the login, and redirects to a
* login page.
*
* @param \Symfony\Component\HttpFoundation\Request The current request
* @param \Symfony\Component\HttpFoundation\Request $request The current request
* @param array &$state Information about the current authentication.
*/
public function authenticate(Request $request, array &$state): ?Response
Expand Down
10 changes: 7 additions & 3 deletions modules/cron/src/Controller/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function setAuthUtils(Utils\Auth $authUtils): void
* @return \Symfony\Component\HttpFoundation\Response|\SimpleSAML\XHTML\Template
* An HTML template or a redirection if we are not authenticated.
*/
public function info(Request $request): Response|Template
public function info(/** @scrutinizer-ignore-unused */Request $request): Response|Template
{
$response = $this->authUtils->requireAdmin();
if ($response instanceof Response) {
Expand Down Expand Up @@ -127,8 +127,12 @@ public function info(Request $request): Response|Template
*
* @throws \SimpleSAML\Error\Exception
*/
public function run(Request $request, string $tag, string $key, string $output = 'xhtml'): Template
{
public function run(
/** @scrutinizer-ignore-unused */Request $request,
string $tag,
string $key,
string $output = 'xhtml',
): Template {
$configKey = $this->cronconfig->getOptionalString('key', 'secret');
if ($key !== $configKey) {
throw new Error\Exception('Cron - Wrong key provided. Cron will not run.');
Expand Down
2 changes: 1 addition & 1 deletion modules/exampleauth/src/Auth/Source/External.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private function getUser(): ?array
/**
* Log in using an external authentication helper.
*
* @param \Symfony\Component\HttpFoundation\Request The current request
* @param \Symfony\Component\HttpFoundation\Request $request The current request
* @param array &$state Information about the current authentication.
*/
public function authenticate(Request $request, array &$state): ?Response
Expand Down
3 changes: 2 additions & 1 deletion modules/multiauth/src/Auth/Source/MultiAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function __construct(array $info, array $config)
*
* The authentication process is finished in the delegateAuthentication method.
*
* @param \Symfony\Component\HttpFoundation\Request The current request
* @param \Symfony\Component\HttpFoundation\Request $request The current request
* @param array &$state Information about the current authentication.
*/
public function authenticate(Request $request, array &$state): Response
Expand Down Expand Up @@ -220,6 +220,7 @@ public function logout(array &$state): ?Response
if ($source === null) {
throw new Exception('Invalid authentication source during logout: ' . $authId);
}

// Then, do the logout on it
return $source->logout($state);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/saml/src/Auth/Source/SP.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ private function startDisco(array $state): RedirectResponse
*
* This function saves the information about the login, and redirects to the IdP.
*
* @param \Symfony\Component\HttpFoundation\Request The current request
* @param \Symfony\Component\HttpFoundation\Request $request The current request
* @param array &$state Information about the current authentication.
*/
public function authenticate(Request $request, array &$state): Response
Expand Down
2 changes: 1 addition & 1 deletion modules/saml/src/Error/NoAuthnContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace SimpleSAML\Module\saml\Error;

use SAML2\Constants as C;
use SimpleSAML\SAML2\Constants as C;
use Throwable;

/**
Expand Down
2 changes: 1 addition & 1 deletion modules/saml/src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ private static function processAssertion(
);
}
$validAudiences = $assertion->getValidAudiences();
if ($validAudiences !== null) {
if ($validAudiences !== []) {
$spEntityId = $spMetadata->getString('entityid');
if (!in_array($spEntityId, $validAudiences, true)) {
$candidates = '[' . implode('], [', $validAudiences) . ']';
Expand Down
1 change: 0 additions & 1 deletion src/SimpleSAML/Error/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ public function show(): void
&& $config->getOptionalString('technicalcontact_email', 'na@example.org') !== 'na@example.org'
) {
// enable error reporting
$httpUtils = new Utils\HTTP();
$data['errorReportAddress'] = Module::getModuleURL('core/errorReport');
}

Expand Down
1 change: 1 addition & 0 deletions src/SimpleSAML/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ private function registerModuleControllers(ContainerBuilder $container): void
$controllerDir . '/*'
);
} catch (FileLocatorFileNotFoundException $e) {
// fall through
}
}
}
23 changes: 0 additions & 23 deletions src/SimpleSAML/Metadata/MetaDataStorageSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,27 +325,4 @@ protected function lookupIndexFromEntityId(string $entityId, array $metadataSet)

return null;
}


/**
* @param string $set
* @throws \Exception
* @return string
*/
private function getDynamicHostedUrl(string $set): string
{
// get the configuration
$httpUtils = new Utils\HTTP();
$baseUrl = $httpUtils->getBaseURL();

if ($set === 'saml20-idp-hosted') {
return $baseUrl . 'saml2/idp/metadata.php';
} elseif ($set === 'saml20-sp-hosted') {
return $baseUrl . 'saml2/sp/metadata.php';
} elseif ($set === 'adfs-idp-hosted') {
return 'urn:federation:' . $httpUtils->getSelfHost() . ':idp';
} else {
throw new \Exception('Can not generate dynamic EntityID for metadata of this type: [' . $set . ']');
}
}
}
2 changes: 1 addition & 1 deletion src/SimpleSAML/Metadata/Sources/MDQ.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function getMetaData(string $entityId, string $set): ?array
if (isset($data)) {
if (array_key_exists('expire', $data) && $data['expire'] < time()) {
// metadata has expired
$data = null;
unset($data);
} else {
// metadata found in cache and not expired
Logger::debug(sprintf('%s: using cached metadata for: %s.', __CLASS__, $entityId));
Expand Down
6 changes: 2 additions & 4 deletions src/SimpleSAML/XHTML/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,10 @@ public function getContents(): string
/**
* Send this template as a response.
*
* @return $this This response.
* @return \Symfony\Component\HttpFoundation\Response This response.
* @throws \Exception if the template cannot be found.
*
* Note: No return type possible due to upstream limitations
*/
public function send(): static
public function send(): Response

Check failure on line 573 in src/SimpleSAML/XHTML/Template.php

View workflow job for this annotation

GitHub Actions / Unit tests, PHP 8.0, ubuntu-latest

Declaration of SimpleSAML\XHTML\Template::send(): Symfony\Component\HttpFoundation\Response must be compatible with Symfony\Component\HttpFoundation\Response::send(): static

Check failure on line 573 in src/SimpleSAML/XHTML/Template.php

View workflow job for this annotation

GitHub Actions / Unit tests, PHP 8.1, ubuntu-latest

Declaration of SimpleSAML\XHTML\Template::send(): Symfony\Component\HttpFoundation\Response must be compatible with Symfony\Component\HttpFoundation\Response::send(): static

Check failure on line 573 in src/SimpleSAML/XHTML/Template.php

View workflow job for this annotation

GitHub Actions / Unit tests, PHP 8.2, ubuntu-latest

Declaration of SimpleSAML\XHTML\Template::send(): Symfony\Component\HttpFoundation\Response must be compatible with Symfony\Component\HttpFoundation\Response::send(): static

Check failure on line 573 in src/SimpleSAML/XHTML/Template.php

View workflow job for this annotation

GitHub Actions / Unit tests, PHP 8.2, windows-latest

Declaration of SimpleSAML\XHTML\Template::send(): Symfony\Component\HttpFoundation\Response must be compatible with Symfony\Component\HttpFoundation\Response::send(): static
{
$this->content = $this->getContents();
return parent::send();
Expand Down

0 comments on commit 29f7b69

Please sign in to comment.