From b038bec8d1f91346a2feac7c17a965a8a968864a Mon Sep 17 00:00:00 2001 From: Arno van der Vegt <arnovandervegt@startmail.com> Date: Wed, 17 Oct 2018 08:39:37 +0200 Subject: [PATCH] Added return statements, updated return types (#958) * Updated the phpDoc comments to match the code * Added return statements * Added return values --- lib/SimpleSAML/Auth/LDAP.php | 1 + lib/SimpleSAML/Auth/ProcessingChain.php | 2 +- lib/SimpleSAML/Metadata/SAMLParser.php | 4 ++-- lib/SimpleSAML/XHTML/Template.php | 2 +- modules/authYubiKey/lib/Auth/Source/YubiKey.php | 4 +++- modules/authfacebook/extlibinc/base_facebook.php | 5 ++++- modules/cas/lib/Auth/Source/CAS.php | 1 - modules/cdc/lib/Server.php | 2 ++ modules/consent/lib/Consent/Store/Database.php | 16 ++++++++-------- modules/core/lib/ACL.php | 1 + modules/statistics/lib/Graph/GoogleCharts.php | 1 + 11 files changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php index 9f57a7eb2..5eedc264c 100644 --- a/lib/SimpleSAML/Auth/LDAP.php +++ b/lib/SimpleSAML/Auth/LDAP.php @@ -205,6 +205,7 @@ class LDAP return new Error\AuthSource('ldap', $description); } } + return new \Exception('Unknown LDAP error.'); } diff --git a/lib/SimpleSAML/Auth/ProcessingChain.php b/lib/SimpleSAML/Auth/ProcessingChain.php index 9ccda2cea..55766967c 100644 --- a/lib/SimpleSAML/Auth/ProcessingChain.php +++ b/lib/SimpleSAML/Auth/ProcessingChain.php @@ -316,7 +316,7 @@ class ProcessingChain * * @param string $id The state identifier. * @see State::parseStateID() - * @return Array The state referenced by the $id parameter. + * @return array The state referenced by the $id parameter. */ public static function fetchProcessedState($id) { diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index e1acd3cfc..b59d285f6 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -1340,7 +1340,7 @@ class SAMLParser * * @param $protocols Array with the protocols we accept. * - * @return Array with SP descriptors which supports one of the given protocols. + * @return array with SP descriptors which supports one of the given protocols. */ private function getSPDescriptors($protocols) { @@ -1364,7 +1364,7 @@ class SAMLParser * * @param $protocols Array with the protocols we accept. * - * @return Array with IdP descriptors which supports one of the given protocols. + * @return array with IdP descriptors which supports one of the given protocols. */ private function getIdPDescriptors($protocols) { diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index b20cac571..554fa77b6 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -155,7 +155,7 @@ class Template /** * Set up the places where twig can look for templates. * - * @return \Twig_Loader_Filesystem The twig template loader or false if the template does not exist. + * @return TemplateLoader The twig template loader or false if the template does not exist. * @throws \Twig_Error_Loader In case a failure occurs. */ private function setupTwigTemplatepaths() diff --git a/modules/authYubiKey/lib/Auth/Source/YubiKey.php b/modules/authYubiKey/lib/Auth/Source/YubiKey.php index 23ace3a39..0c2a7bb15 100644 --- a/modules/authYubiKey/lib/Auth/Source/YubiKey.php +++ b/modules/authYubiKey/lib/Auth/Source/YubiKey.php @@ -121,7 +121,7 @@ class YubiKey extends \SimpleSAML\Auth\Source * * @param string $authStateId The identifier of the authentication state. * @param string $otp The one time password entered- - * @return string Error code in the case of an error. + * @return string|null Error code in the case of an error. */ public static function handleLogin($authStateId, $otp) { @@ -158,6 +158,8 @@ class YubiKey extends \SimpleSAML\Auth\Source $state['Attributes'] = $attributes; \SimpleSAML\Auth\Source::completeAuth($state); + + return null; } /** diff --git a/modules/authfacebook/extlibinc/base_facebook.php b/modules/authfacebook/extlibinc/base_facebook.php index 1df472e45..afb1ce9c5 100644 --- a/modules/authfacebook/extlibinc/base_facebook.php +++ b/modules/authfacebook/extlibinc/base_facebook.php @@ -352,6 +352,8 @@ abstract class BaseFacebook * Extend an access token, while removing the short-lived token that might * have been generated via client-side flow. Thanks to http://bit.ly/b0Pt0H * for the workaround. + * + * @return boolean Return true is the access token is set. */ public function setExtendedAccessToken() { @@ -390,6 +392,7 @@ abstract class BaseFacebook 'access_token', $response_params['access_token'] ); + return true; } /** @@ -492,7 +495,7 @@ abstract class BaseFacebook * Retrieve the signed request, either from a request parameter or, * if not present, from a cookie. * - * @return string the signed request, if available, or null otherwise. + * @return array the signed request, if available, or null otherwise. */ public function getSignedRequest() { diff --git a/modules/cas/lib/Auth/Source/CAS.php b/modules/cas/lib/Auth/Source/CAS.php index 3ab8cfd7a..f0afe8501 100644 --- a/modules/cas/lib/Auth/Source/CAS.php +++ b/modules/cas/lib/Auth/Source/CAS.php @@ -178,7 +178,6 @@ class CAS extends \SimpleSAML\Auth\Source /** * Called by linkback, to finish validate/ finish logging in. * @param array $state - * @return array username, casattributes/ldap attributes */ public function finalStep(&$state) { diff --git a/modules/cdc/lib/Server.php b/modules/cdc/lib/Server.php index 7414004b0..a82deb43a 100644 --- a/modules/cdc/lib/Server.php +++ b/modules/cdc/lib/Server.php @@ -420,5 +420,7 @@ class Server ); \SimpleSAML\Utils\HTTP::setCookie('_saml_idp', $cookie, $params, false); + + return '_saml_idp'; } } diff --git a/modules/consent/lib/Consent/Store/Database.php b/modules/consent/lib/Consent/Store/Database.php index 5f5f3b126..74035d028 100644 --- a/modules/consent/lib/Consent/Store/Database.php +++ b/modules/consent/lib/Consent/Store/Database.php @@ -263,17 +263,16 @@ class Database extends \SimpleSAML\Module\consent\Store ); if ($st === false) { - return; + return 0; } if ($st->rowCount() > 0) { \SimpleSAML\Logger::debug('consent:Database - Deleted consent.'); return $st->rowCount(); - } else { - \SimpleSAML\Logger::warning( - 'consent:Database - Attempted to delete nonexistent consent' - ); } + + \SimpleSAML\Logger::warning('consent:Database - Attempted to delete nonexistent consent'); + return 0; } @@ -294,15 +293,16 @@ class Database extends \SimpleSAML\Module\consent\Store ); if ($st === false) { - return; + return 0; } if ($st->rowCount() > 0) { \SimpleSAML\Logger::debug('consent:Database - Deleted ('.$st->rowCount().') consent(s).'); return $st->rowCount(); - } else { - \SimpleSAML\Logger::warning('consent:Database - Attempted to delete nonexistent consent'); } + + \SimpleSAML\Logger::warning('consent:Database - Attempted to delete nonexistent consent'); + return 0; } diff --git a/modules/core/lib/ACL.php b/modules/core/lib/ACL.php index 558bf9479..9339077aa 100644 --- a/modules/core/lib/ACL.php +++ b/modules/core/lib/ACL.php @@ -87,6 +87,7 @@ class ACL return false; } } + return false; } /** diff --git a/modules/statistics/lib/Graph/GoogleCharts.php b/modules/statistics/lib/Graph/GoogleCharts.php index 087dffcb2..9e7e32377 100644 --- a/modules/statistics/lib/Graph/GoogleCharts.php +++ b/modules/statistics/lib/Graph/GoogleCharts.php @@ -171,5 +171,6 @@ class GoogleCharts return $target_top; } } + return 1; } } -- GitLab