diff --git a/lib/SimpleSAML/AuthMemCookie.php b/lib/SimpleSAML/AuthMemCookie.php index 6b4455400c4a1709638da0f9747f1ed696c97362..77ddf83b1e3435b218a0f6ba70a59820c13a66ef 100644 --- a/lib/SimpleSAML/AuthMemCookie.php +++ b/lib/SimpleSAML/AuthMemCookie.php @@ -110,7 +110,7 @@ class AuthMemCookie /** * This function creates and initializes a Memcache object from our configuration. * - * @return \Memcache A Memcache object initialized from our configuration. + * @return \Memcache|\Memcached A Memcache object initialized from our configuration. * @throws \Exception If the servers configuration is invalid. */ public function getMemcache() @@ -138,6 +138,7 @@ class AuthMemCookie /** * This function logs the user out by deleting the session information from memcache. + * @return void */ private function doLogout() { @@ -161,6 +162,7 @@ class AuthMemCookie /** * This function implements the logout handler. It deletes the information from Memcache. + * @return void */ public static function logoutHandler() { diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index 4e885f6ea98073df50b95bffb536f7b8f1d697fe..b7150dd894c5c9fba5b7034e4f8560af97767241 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -188,6 +188,7 @@ class Configuration implements Utils\ClearableState * * @param string $path The directory which contains the configuration files. * @param string $configSet The configuration set. Defaults to 'simplesaml'. + * @return void */ public static function setConfigDir($path, $configSet = 'simplesaml') { @@ -206,6 +207,8 @@ class Configuration implements Utils\ClearableState * @param \SimpleSAML\Configuration $config The configuration object to store * @param string $filename The name of the configuration file. * @param string $configSet The configuration set. Optional, defaults to 'simplesaml'. + * @return void + * @throws \Exception */ public static function setPreLoadedConfig( Configuration $config, @@ -358,6 +361,7 @@ class Configuration implements Utils\ClearableState * @param string $path * @param string $instancename * @param string $configfilename + * @return \SimpleSAML\Configuration * * @see setConfigDir() * @deprecated This function is superseeded by the setConfigDir function. @@ -390,6 +394,7 @@ class Configuration implements Utils\ClearableState * * @param string $instancename * @param string $filename + * @return \SimpleSAML\Configuration * * @see getConfig() * @deprecated This function is superseeded by the getConfig() function. @@ -1387,6 +1392,8 @@ class Configuration implements Utils\ClearableState * Clear any configuration information cached. * Allows for configuration files to be changed and reloaded during a given request. Most useful * when running phpunit tests and needing to alter config.php between test cases + * + * @return void */ public static function clearInternalState() { diff --git a/lib/SimpleSAML/Database.php b/lib/SimpleSAML/Database.php index 94c9b788f14ec3e53f0162cf8f5c0e210cfb3929..33c760098c81ce785a254e52c2f03569c854d128 100644 --- a/lib/SimpleSAML/Database.php +++ b/lib/SimpleSAML/Database.php @@ -250,7 +250,7 @@ class Database * @param string $stmt Prepared SQL statement * @param array $params Parameters * - * @return int The number of rows affected by the query. + * @return int|false The number of rows affected by the query or false on error. */ public function write($stmt, $params = []) { @@ -258,7 +258,7 @@ class Database if (is_array($params)) { $obj = $this->query($db, $stmt, $params); - return $obj->rowCount(); + return ($obj === false) ? $obj : $obj->rowCount(); } else { return $this->exec($db, $stmt); } diff --git a/lib/SimpleSAML/Memcache.php b/lib/SimpleSAML/Memcache.php index 227022c201de7e5c42803353c83d12eb5e7f71e8..bccf7be723c92830caf03eb93697b543d5390f55 100644 --- a/lib/SimpleSAML/Memcache.php +++ b/lib/SimpleSAML/Memcache.php @@ -69,6 +69,7 @@ class Memcache $allDown = false; // unserialize the object + /** @var string $serializedInfo */ $info = unserialize($serializedInfo); /* @@ -146,6 +147,7 @@ class Memcache * @param string $key The key of the data. * @param mixed $value The value of the data. * @param integer|null $expire The expiration timestamp of the data. + * @return void */ public static function set($key, $value, $expire = null) { @@ -176,6 +178,7 @@ class Memcache * Delete a key-value pair from the memcache servers. * * @param string $key The key we should delete. + * @return void */ public static function delete($key) { @@ -209,6 +212,7 @@ class Memcache * * @param \Memcache $memcache The Memcache object we should add this server to. * @param array $server An associative array with the configuration options for the server to add. + * @return void * * @throws \Exception If any configuration option for the server is invalid. */ diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php index 4cbd416576a9c34f465d976a7ad62fd59a1344ff..40c664d55d20ac9b7d703dedd3338530db9cabfa 100644 --- a/lib/SimpleSAML/Module.php +++ b/lib/SimpleSAML/Module.php @@ -273,6 +273,11 @@ class Module } + /** + * @param string $module + * @param array $mod_config + * @return bool + */ private static function isModuleEnabledWithConf($module, $mod_config) { if (isset(self::$module_info[$module]['enabled'])) { @@ -485,6 +490,7 @@ class Module * * @param string $hook The name of the hook. * @param mixed &$data The data which should be passed to each hook. Will be passed as a reference. + * @return void * * @throws \SimpleSAML\Error\Exception If an invalid hook is found in a module. */ diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index cd158b3fe6b35cd0dd8d58b11c3b440a61d55863..f03544dd0ddb4afc32928fb2e71124d8545417a8 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -197,6 +197,7 @@ class Session implements \Serializable, Utils\ClearableState * Set the configuration we should use. * * @param Configuration $config + * @return void */ public function setConfiguration(Configuration $config) { @@ -413,6 +414,8 @@ class Session implements \Serializable, Utils\ClearableState * * Create a session that should not be saved at the end of the request. * Subsequent calls to getInstance() will return this transient session. + * + * @return void */ public static function useTransientSession() { @@ -428,6 +431,7 @@ class Session implements \Serializable, Utils\ClearableState * Create a new session and cache it. * * @param string $sessionId The new session we should create. + * @return void */ public static function createSession($sessionId) { @@ -442,6 +446,8 @@ class Session implements \Serializable, Utils\ClearableState * * WARNING: please do not use this method directly unless you really need to and know what you are doing. Use * markDirty() instead. + * + * @return void */ public function save() { @@ -471,6 +477,8 @@ class Session implements \Serializable, Utils\ClearableState * * Use this method if you are using PHP sessions in your application *and* in SimpleSAMLphp, *after* you are done * using SimpleSAMLphp and before trying to access your application's session again. + * + * @return void */ public function cleanup() { @@ -485,6 +493,8 @@ class Session implements \Serializable, Utils\ClearableState * Mark this session as dirty. * * This method will register a callback to save the session right before any output is sent to the browser. + * + * @return void */ public function markDirty() { @@ -506,6 +516,8 @@ class Session implements \Serializable, Utils\ClearableState * * Destructor for this class. It will save the session to the session handler * in case the session has been marked as dirty. Do nothing otherwise. + * + * @return void */ public function __destruct() { @@ -578,6 +590,7 @@ class Session implements \Serializable, Utils\ClearableState * * @param string $authority The authority the user logged in with. * @param array|null $data The authentication data for this authority. + * @return void * * @throws Error\CannotSetCookie If the authentication token cannot be set for some reason. */ @@ -670,6 +683,7 @@ class Session implements \Serializable, Utils\ClearableState * This function will call any registered logout handlers before marking the user as logged out. * * @param string $authority The authentication source we are logging out of. + * @return void */ public function doLogout($authority) { @@ -695,6 +709,7 @@ class Session implements \Serializable, Utils\ClearableState * This function calls all registered logout handlers. * * @param string $authority The authentication source we are logging out from. + * @return void * * @throws \Exception If the handler is not a valid function or method. */ @@ -760,6 +775,7 @@ class Session implements \Serializable, Utils\ClearableState * Update session cookies. * * @param array $params The parameters for the cookies. + * @return void */ public function updateSessionCookies($params = null) { @@ -787,6 +803,7 @@ class Session implements \Serializable, Utils\ClearableState * * @param string $authority The authentication source we are setting expire time for. * @param int $expire The number of seconds authentication source is valid. + * @return void */ public function setAuthorityExpire($authority, $expire = null) { @@ -808,6 +825,7 @@ class Session implements \Serializable, Utils\ClearableState * @param string $authority The authority for which register the handler. * @param string $classname The class which contains the logout handler. * @param string $functionname The logout handler function. + * @return void * * @throws \Exception If the handler is not a valid function or method. */ @@ -835,6 +853,7 @@ class Session implements \Serializable, Utils\ClearableState * * @param string $type The type of the data. * @param string $id The identifier of the data. + * @return void */ public function deleteData($type, $id) { @@ -861,6 +880,7 @@ class Session implements \Serializable, Utils\ClearableState * @param int|string|null $timeout The number of seconds this data should be stored after its last access. * This parameter is optional. The default value is set in 'session.datastore.timeout', * and the default is 4 hours. + * @return void * * @throws \Exception If the data couldn't be stored. * @@ -914,6 +934,7 @@ class Session implements \Serializable, Utils\ClearableState * Note that this function doesn't mark the session object as dirty. This means that * if the only change to the session object is that some data has expired, it will not be * written back to the session store. + * @return void */ private function expireData() { @@ -1000,7 +1021,7 @@ class Session implements \Serializable, Utils\ClearableState * * @param string $authority The authority to retrieve the data from. * - * @return array The current persistent authentication state, or null if not authenticated. + * @return array|null The current persistent authentication state, or null if not authenticated. */ public function getAuthState($authority) { @@ -1033,6 +1054,7 @@ class Session implements \Serializable, Utils\ClearableState * * @param string $idp The IdP id. * @param array $association The association we should add. + * @return void */ public function addAssociation($idp, array $association) { @@ -1095,6 +1117,7 @@ class Session implements \Serializable, Utils\ClearableState * * @param string $idp The IdP id. * @param string $associationId The id of the association. + * @return void */ public function terminateAssociation($idp, $associationId) { @@ -1153,6 +1176,7 @@ class Session implements \Serializable, Utils\ClearableState /** * Clear any configuration information cached + * @return void */ public static function clearInternalState() { diff --git a/lib/SimpleSAML/SessionHandler.php b/lib/SimpleSAML/SessionHandler.php index f8e0236f5b887a13970fccb338aab6a716e21b7b..e82df8ae08385c0f5db769d288650a62290b3db0 100644 --- a/lib/SimpleSAML/SessionHandler.php +++ b/lib/SimpleSAML/SessionHandler.php @@ -16,14 +16,12 @@ namespace SimpleSAML; abstract class SessionHandler { - - /** * This static variable contains a reference to the current * instance of the session handler. This variable will be NULL if * we haven't instantiated a session handler yet. * - * @var \SimpleSAML\SessionHandler + * @var \SimpleSAML\SessionHandler|null */ protected static $sessionHandler = null; @@ -126,6 +124,8 @@ abstract class SessionHandler * selected in the 'store.type' configuration directive. If no * session handler is selected, then we will fall back to the default * PHP session handler. + * + * @return void */ private static function createSessionHandler() { diff --git a/lib/SimpleSAML/SessionHandlerCookie.php b/lib/SimpleSAML/SessionHandlerCookie.php index 7eea4656d94cafb5b760fde23b29136054826d49..04ff7c0bb0142f4e2d6031af1848c45b60b0dca3 100644 --- a/lib/SimpleSAML/SessionHandlerCookie.php +++ b/lib/SimpleSAML/SessionHandlerCookie.php @@ -1,6 +1,5 @@ <?php - /** * This file is part of SimpleSAMLphp. See the file COPYING in the root of the distribution for licence information. * @@ -18,7 +17,6 @@ use SimpleSAML\Utils\HTTP; abstract class SessionHandlerCookie extends SessionHandler { - /** * This variable contains the current session id. * @@ -154,6 +152,7 @@ abstract class SessionHandlerCookie extends SessionHandler * @param string $sessionName The name of the session. * @param string|null $sessionID The session ID to use. Set to null to delete the cookie. * @param array|null $cookieParams Additional parameters to use for the session cookie. + * @return void * * @throws \SimpleSAML\Error\CannotSetCookie If we can't set the cookie. */ diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php index 5420490aa8ccffb98035b6cb4641967d30659c66..a67e032428836f3982f5cb68d33771b1fe370a8d 100644 --- a/lib/SimpleSAML/SessionHandlerPHP.php +++ b/lib/SimpleSAML/SessionHandlerPHP.php @@ -16,7 +16,6 @@ use SimpleSAML\Utils\HTTP; class SessionHandlerPHP extends SessionHandler { - /** * This variable contains the session cookie name. * @@ -102,6 +101,8 @@ class SessionHandlerPHP extends SessionHandler * outside of \SimpleSAML\Session, could cause SimpleSAMLphp's session to be lost or mess the application's one. The * session must always be saved properly before calling this method. If you don't understand what this is about, * don't use this method. + * + * @return void */ public function restorePrevious() { @@ -198,6 +199,7 @@ class SessionHandlerPHP extends SessionHandler * Save the current session to the PHP session array. * * @param \SimpleSAML\Session $session The session object we should save. + * @return void */ public function saveSession(\SimpleSAML\Session $session) { @@ -302,6 +304,7 @@ class SessionHandlerPHP extends SessionHandler * @param string $sessionName The name of the session. * @param string|null $sessionID The session ID to use. Set to null to delete the cookie. * @param array|null $cookieParams Additional parameters to use for the session cookie. + * @return void * * @throws \SimpleSAML\Error\CannotSetCookie If we can't set the cookie. */ diff --git a/lib/SimpleSAML/SessionHandlerStore.php b/lib/SimpleSAML/SessionHandlerStore.php index f40b9eb958c6c1871c4fbbc2629412876c30a006..669a4c58f0b3db122613aa8720cce98481912021 100644 --- a/lib/SimpleSAML/SessionHandlerStore.php +++ b/lib/SimpleSAML/SessionHandlerStore.php @@ -11,7 +11,6 @@ namespace SimpleSAML; class SessionHandlerStore extends SessionHandlerCookie { - /** * The data store we save the session to. * @@ -66,6 +65,7 @@ class SessionHandlerStore extends SessionHandlerCookie * Save a session to the data store. * * @param \SimpleSAML\Session $session The session object we should save. + * @return void */ public function saveSession(Session $session) { diff --git a/lib/SimpleSAML/Stats.php b/lib/SimpleSAML/Stats.php index 56d07c3022fc25ad79940198e87595254009808b..8c77b0da8eba6a2a9611af698e67a6b04a6f153a 100644 --- a/lib/SimpleSAML/Stats.php +++ b/lib/SimpleSAML/Stats.php @@ -47,6 +47,8 @@ class Stats /** * Initialize the outputs. + * + * @return void */ private static function initOutputs() { @@ -83,7 +85,7 @@ class Stats if (empty(self::$outputs)) { // not enabled - return; + return false; } $data['op'] = $event; diff --git a/lib/SimpleSAML/Store.php b/lib/SimpleSAML/Store.php index 74e761e4944760206672ab532688c1a05f25dd48..3447a9bc0ca8ee8bbede29d130c097f48c36455c 100644 --- a/lib/SimpleSAML/Store.php +++ b/lib/SimpleSAML/Store.php @@ -104,6 +104,7 @@ abstract class Store implements Utils\ClearableState /** * Clear any SSP specific state, such as SSP environmental variables or cached internals. + * @return void */ public static function clearInternalState() { diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index c6e04223e9baf472b6a5909d01bce4043ca676ce..22592096035fc26fd976d91b1fcf2d230249718c 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -15,12 +15,14 @@ class Utilities { /** * @deprecated This property will be removed in SSP 2.0. Please use SimpleSAML\Logger::isErrorMasked() instead. + * @var int */ public static $logMask = 0; /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfHost() instead. + * @return string */ public static function getSelfHost() { @@ -30,6 +32,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfURLHost() instead. + * @return string */ public static function selfURLhost() { @@ -39,6 +42,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::isHTTPS() instead. + * @return bool */ public static function isHTTPS() { @@ -49,6 +53,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfURLNoQuery() * instead. + * @return string */ public static function selfURLNoQuery() { @@ -59,6 +64,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfHostWithPath() * instead. + * @return string */ public static function getSelfHostWithPath() { @@ -69,6 +75,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getFirstPathElement() * instead. + * @param bool $trailingslash + * @return string */ public static function getFirstPathElement($trailingslash = true) { @@ -78,6 +86,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getSelfURL() instead. + * @return string */ public static function selfURL() { @@ -87,6 +96,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getBaseURL() instead. + * @return string */ public static function getBaseURL() { @@ -96,6 +106,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::addURLParameters() instead. + * @param string $url + * @param array $parameters + * @return string */ public static function addURLparameter($url, $parameters) { @@ -105,6 +118,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Utils\HTTP::checkURLAllowed() instead. + * @param string $url + * @param array|null $trustedSites + * @return bool */ public static function checkURLAllowed($url, array $trustedSites = null) { @@ -114,6 +130,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Auth\State::parseStateID() instead. + * @param string $stateId + * @return array */ public static function parseStateID($stateId) { @@ -123,6 +141,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. + * @param int|null $start + * @param int|null $end + * @return bool */ public static function checkDateConditions($start = null, $end = null) { @@ -147,6 +168,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Random::generateID() instead. + * @return string */ public static function generateID() { @@ -157,6 +179,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Utils\Time::generateTimestamp() * instead. + * @param int|null $instant + * @return string */ public static function generateTimestamp($instant = null) { @@ -166,6 +190,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Utils\Time::parseDuration() instead. + * @param string $duration + * @param int|null $timestamp + * @return int */ public static function parseDuration($duration, $timestamp = null) { @@ -175,6 +202,11 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please raise a SimpleSAML\Error\Error exception instead. + * @param string $trackId + * @param int|null $errorCode + * @param \Exception|null $e + * @throws \SimpleSAML\Error\Error + * @return void */ public static function fatalError($trackId = 'na', $errorCode = null, \Exception $e = null) { @@ -184,6 +216,9 @@ class Utilities /** * @deprecated This method will be removed in version 2.0. Use SimpleSAML\Utils\Net::ipCIDRcheck() instead. + * @param string $cidr + * @param string|null $ip + * @return bool */ public static function ipCIDRcheck($cidr, $ip = null) { @@ -191,6 +226,11 @@ class Utilities } + /** + * @param string $url + * @param array $parameters + * @return void + */ private static function doRedirect($url, $parameters = []) { assert(is_string($url)); @@ -252,6 +292,10 @@ class Utilities /** * @deprecated 1.12.0 This method will be removed from the API. Instead, use the redirectTrustedURL() or * redirectUntrustedURL() functions accordingly. + * @param string $url + * @param array $parameters + * @param array|null $allowed_redirect_hosts + * @return void */ public static function redirect($url, $parameters = [], $allowed_redirect_hosts = null) { @@ -271,6 +315,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::redirectTrustedURL() * instead. + * @param string $url + * @param array $parameters + * @return void */ public static function redirectTrustedURL($url, $parameters = []) { @@ -281,6 +328,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::redirectUntrustedURL() * instead. + * @param string $url + * @param array $parameters + * @return void */ public static function redirectUntrustedURL($url, $parameters = []) { @@ -290,6 +340,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Arrays::transpose() instead. + * @param array $in + * @return mixed */ public static function transposeArray($in) { @@ -300,6 +352,10 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::isDOMNodeOfType() * instead. + * @param \DOMNode $element + * @param string $name + * @param string $nsURI + * @return bool */ public static function isDOMElementOfType(\DOMNode $element, $name, $nsURI) { @@ -309,6 +365,10 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::getDOMChildren() instead. + * @param \DOMNode $element + * @param string $localName + * @param string $namespaceURI + * @return array */ public static function getDOMChildren(\DOMElement $element, $localName, $namespaceURI) { @@ -318,6 +378,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::getDOMText() instead. + * @param \DOMNode $element + * @return string */ public static function getDOMText($element) { @@ -328,6 +390,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getAcceptLanguage() * instead. + * @return string */ public static function getAcceptLanguage() { @@ -337,6 +400,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::isValid() instead. + * @param string $xml + * @param string $schema + * @return bool */ public static function validateXML($xml, $schema) { @@ -347,6 +413,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::checkSAMLMessage() instead. + * @param string $message + * @param string $type + * @return bool */ public static function validateXMLDocument($message, $type) { @@ -356,6 +425,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use openssl_random_pseudo_bytes() instead. + * @param int $length + * @return string */ public static function generateRandomBytes($length) { @@ -367,6 +438,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use bin2hex() instead. + * @param string $bytes + * @return string */ public static function stringToHex($bytes) { @@ -380,6 +453,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\System::resolvePath() instead. + * @param string $path + * @param string|null $base + * @return string */ public static function resolvePath($path, $base = null) { @@ -389,6 +465,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::resolveURL() instead. + * @param string $path + * @param string|null $base + * @return string */ public static function resolveURL($url, $base = null) { @@ -398,6 +477,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::normalizeURL() instead. + * @param string $url + * @return string */ public static function normalizeURL($url) { @@ -407,6 +488,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::parseQueryString() instead. + * @param string $query_string + * @return string */ public static function parseQueryString($query_string) { @@ -417,6 +500,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use * SimpleSAML\Utils\Attributes::normalizeAttributesArray() instead. + * @param array $attributes + * @return array */ public static function parseAttributes($attributes) { @@ -426,6 +511,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Config::getSecretSalt() instead. + * @return string */ public static function getSecretSalt() { @@ -435,6 +521,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please call error_get_last() directly. + * @return string */ public static function getLastError() { @@ -454,6 +541,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Config::getCertPath() instead. + * @param string $path + * @return string */ public static function resolveCert($path) { @@ -463,6 +552,10 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Crypto::loadPublicKey() instead. + * @param \SimpleSAML\Configuration $metadata + * @param bool $required + * @param string $prefix + * @return array|null */ public static function loadPublicKey(\SimpleSAML\Configuration $metadata, $required = false, $prefix = '') { @@ -472,6 +565,10 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Crypto::loadPrivateKey() instead. + * @param \SimpleSAML\Configuration $metadata + * @param bool $required + * @param string $prefix + * @return array|null */ public static function loadPrivateKey(\SimpleSAML\Configuration $metadata, $required = false, $prefix = '') { @@ -481,6 +578,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::formatDOMElement() instead. + * @param \DOMElement $root + * @param string $indentBase + * @return void */ public static function formatDOMElement(\DOMElement $root, $indentBase = '') { @@ -490,6 +590,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::formatXMLString() instead. + * @param \DOMElement $root + * @param string $indentBase + * @return string */ public static function formatXMLString($xml, $indentBase = '') { @@ -499,6 +602,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Arrays::arrayize() instead. + * @param mixed $data + * @param int $index + * @return array */ public static function arrayize($data, $index = 0) { @@ -508,6 +614,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Auth::isAdmin() instead. + * @return bool */ public static function isAdmin() { @@ -517,6 +624,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Auth::getAdminLoginURL instead(); + * @param string|null $returnTo + * @return string */ public static function getAdminLoginURL($returnTo = null) { @@ -526,6 +635,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Auth::requireAdmin() instead. + * @return void */ public static function requireAdmin() { @@ -535,6 +645,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::submitPOSTData() instead. + * @param string $destination + * @param array $post + * @return void */ public static function postRedirect($destination, $post) { @@ -545,6 +658,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. PLease use SimpleSAML\Utils\HTTP::getPOSTRedirectURL() * instead. + * @param string $destination + * @param array $post + * @return string */ public static function createPostRedirectLink($destination, $post) { @@ -555,6 +671,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::getPOSTRedirectURL() * instead. + * @param string $destination + * @param array $post + * @return string */ public static function createHttpPostRedirectLink($destination, $post) { @@ -581,6 +700,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. + * @param string $certificate + * @param string $caFile + * @return void */ public static function validateCA($certificate, $caFile) { @@ -590,6 +712,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Time::initTimezone() instead. + * @return void */ public static function initTimezone() { @@ -599,6 +722,10 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\System::writeFile() instead. + * @param string $filename + * @param array $data + * @param int $mode + * @return void */ public static function writeFile($filename, $data, $mode = 0600) { @@ -608,6 +735,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\System::getTempDir instead. + * @return string */ public static function getTempDir() { @@ -617,6 +745,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Logger::maskErrors() instead. + * @param string $mask + * @return void */ public static function maskErrors($mask) { @@ -626,6 +756,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Logger::popErrorMask() instead. + * @return void */ public static function popErrorMask() { @@ -636,6 +767,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use * SimpleSAML\Utils\Config\Metadata::getDefaultEndpoint() instead. + * @param array $endpoints + * @param array|null $bindings + * @return array|null */ public static function getDefaultEndpoint(array $endpoints, array $bindings = null) { @@ -646,6 +780,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::checkSessionCookie() * instead. + * @param string|null $retryURL + * @return void */ public static function checkCookie($retryURL = null) { @@ -655,6 +791,9 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\XML::debugSAMLMessage() instead. + * @param string|\DOMElement $message + * @param string $type + * @return void */ public static function debugMessage($message, $type) { @@ -664,6 +803,10 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::fetch() instead. + * @param string $path + * @param array $context + * @param bool $getHeaders + * @return string|array */ public static function fetch($path, $context = [], $getHeaders = false) { @@ -673,6 +816,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Crypto::aesEncrypt() instead. + * @param string $clear + * @return string */ public static function aesEncrypt($clear) { @@ -682,6 +827,8 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Crypto::aesDecrypt() instead. + * @param string $encData + * @return string */ public static function aesDecrypt($encData) { @@ -691,6 +838,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\System::getOS() instead. + * @return bool */ public static function isWindowsOS() { @@ -700,6 +848,7 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::setCookie() instead. + * @return void */ public static function setCookie($name, $value, array $params = null, $throw = true) { diff --git a/lib/SimpleSAML/XML/Errors.php b/lib/SimpleSAML/XML/Errors.php index 6f6d228ef34432187b2bcf481e66b1df82a3854f..01720fb8101b120797a58e1adbf875213d937bba 100644 --- a/lib/SimpleSAML/XML/Errors.php +++ b/lib/SimpleSAML/XML/Errors.php @@ -29,6 +29,8 @@ class Errors /** * Append current XML errors to the current stack level. + * + * @return void */ private static function addErrors() { @@ -45,6 +47,8 @@ class Errors * * A call to this function will begin a new error logging context. Every call must have * a corresponding call to end(). + * + * @return void */ public static function begin() { diff --git a/lib/SimpleSAML/XML/Parser.php b/lib/SimpleSAML/XML/Parser.php index 39287b2cb967edb1f4a0b7839a7860afb52f7cbb..234aaf3cafd1b1429b052fb8525830aee5327028 100644 --- a/lib/SimpleSAML/XML/Parser.php +++ b/lib/SimpleSAML/XML/Parser.php @@ -11,20 +11,27 @@ namespace SimpleSAML\XML; class Parser { + /** @var \SimpleXMLElement|null */ public $simplexml = null; + /** + * @param string $xml + */ public function __construct($xml) { - ; $this->simplexml = new \SimpleXMLElement($xml); $this->simplexml->registerXPathNamespace('saml2', 'urn:oasis:names:tc:SAML:2.0:assertion'); $this->simplexml->registerXPathNamespace('saml2meta', 'urn:oasis:names:tc:SAML:2.0:metadata'); $this->simplexml->registerXPathNamespace('ds', 'http://www.w3.org/2000/09/xmldsig#'); } + + /** + * @param \SimpleXMLElement $element + * @return \SimpleSAML\XML\Parser + */ public static function fromSimpleXMLElement(\SimpleXMLElement $element) { - // Traverse all existing namespaces in element $namespaces = $element->getNamespaces(); foreach ($namespaces as $prefix => $ns) { @@ -38,6 +45,13 @@ class Parser return $parser; } + + /** + * @param string $xpath + * @param string $defvalue + * @throws \Exception + * @return string + */ public function getValueDefault($xpath, $defvalue) { try { @@ -47,6 +61,13 @@ class Parser } } + + /** + * @param string $xpath + * @param bool $required + * @throws \Exception + * @return string + */ public function getValue($xpath, $required = false) { $result = $this->simplexml->xpath($xpath); @@ -62,6 +83,13 @@ class Parser return (string) $result[0]; } + + /** + * @param array $xpath + * @param bool $required + * @throws \Exception + * @return string|null + */ public function getValueAlternatives(array $xpath, $required = false) { foreach ($xpath as $x) { diff --git a/lib/SimpleSAML/XML/Shib13/AuthnRequest.php b/lib/SimpleSAML/XML/Shib13/AuthnRequest.php index 221951d9b777e5b71f8513890582afec4acc852d..680d2aebb7d4beff5b140cbb115f4033e5b14df1 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnRequest.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnRequest.php @@ -12,28 +12,56 @@ namespace SimpleSAML\XML\Shib13; class AuthnRequest { + /** @var string|null */ private $issuer = null; + + /** @var string|null */ private $relayState = null; + + /** + * @param string|null $relayState + * @return void + */ public function setRelayState($relayState) { $this->relayState = $relayState; } + + /** + * @return string|null + */ public function getRelayState() { return $this->relayState; } + + /** + * @param string|null $relayState + * @return void + */ public function setIssuer($issuer) { $this->issuer = $issuer; } + + + /** + * @return string|null + */ public function getIssuer() { return $this->issuer; } + + /** + * @param string $destination + * @param string $shire + * @return string|null + */ public function createRedirect($destination, $shire) { $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php index 8b6c1fb6e3686a77638c6ddc625f649000a27bab..f943c1925a3fe086a7842a7de18effb510ec0af8 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php @@ -21,7 +21,7 @@ use SimpleSAML\XML\Validator; class AuthnResponse { /** - * @var \SimpleSAML\XML\Validator This variable contains an XML validator for this message. + * @var \SimpleSAML\XML\Validator|null This variable contains an XML validator for this message. */ private $validator = null; @@ -32,7 +32,11 @@ class AuthnResponse private $messageValidated = false; + /** @var string */ const SHIB_PROTOCOL_NS = 'urn:oasis:names:tc:SAML:1.0:protocol'; + + + /** @var string */ const SHIB_ASSERT_NS = 'urn:oasis:names:tc:SAML:1.0:assertion'; @@ -51,6 +55,7 @@ class AuthnResponse * Set whether this message was validated externally. * * @param bool $messageValidated TRUE if the message is already validated, FALSE if not. + * @return void */ public function setMessageValidated($messageValidated) { @@ -60,6 +65,11 @@ class AuthnResponse } + /** + * @param string $xml + * @throws \Exception + * @return void + */ public function setXML($xml) { assert(is_string($xml)); @@ -71,16 +81,30 @@ class AuthnResponse } } + + /** + * @param string|null $relayState + * @return void + */ public function setRelayState($relayState) { $this->relayState = $relayState; } + + /** + * @return string|null + */ public function getRelayState() { return $this->relayState; } + + /** + * @throws \SimpleSAML\Error\Exception + * @return bool + */ public function validate() { assert($this->dom instanceof DOMDocument); @@ -131,7 +155,7 @@ class AuthnResponse /** * Checks if the given node is validated by the signature on this response. * - * @param \DOMElement $node Node to be validated. + * @param \DOMElement|\SimpleXMLElement $node Node to be validated. * @return bool TRUE if the node is validated or FALSE if not. */ private function isNodeValidated($node) @@ -182,6 +206,7 @@ class AuthnResponse return $xPath->query($query, $node); } + /** * Retrieve the session index of this response. * @@ -201,6 +226,10 @@ class AuthnResponse } + /** + * @throws \Exception + * @return array + */ public function getAttributes() { $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); @@ -273,6 +302,10 @@ class AuthnResponse } + /** + * @throws \Exception + * @return string + */ public function getIssuer() { $query = '/shibp:Response/shib:Assertion/@Issuer'; @@ -285,6 +318,10 @@ class AuthnResponse } } + + /** + * @return array + */ public function getNameID() { $nameID = []; diff --git a/lib/SimpleSAML/XML/Signer.php b/lib/SimpleSAML/XML/Signer.php index 26f46ab62f3163f6a47896a6edafdf7b3c8e1e0b..ee58c4c092c4aa3b512905ab62bfc6c39c19b392 100644 --- a/lib/SimpleSAML/XML/Signer.php +++ b/lib/SimpleSAML/XML/Signer.php @@ -96,6 +96,7 @@ class Signer * by \SimpleSAML\Utils\Crypto::loadPrivateKey(...). * * @param array $privatekey The private key. + * @return void */ public function loadPrivateKeyArray($privatekey) { @@ -122,6 +123,7 @@ class Signer * @param bool $full_path Whether the filename found in the configuration contains the * full path to the private key or not. Default to false. * @throws \Exception + * @return void */ public function loadPrivateKey($file, $pass = null, $full_path = false) { @@ -159,6 +161,7 @@ class Signer * * @param array $publickey The public key. * @throws \Exception + * @return void */ public function loadPublicKeyArray($publickey) { @@ -185,6 +188,7 @@ class Signer * @param bool $full_path Whether the filename found in the configuration contains the * full path to the private key or not. Default to false. * @throws \Exception + * @return void */ public function loadCertificate($file, $full_path = false) { @@ -213,6 +217,7 @@ class Signer * Set the attribute name for the ID value. * * @param string $idAttrName The name of the attribute which contains the id. + * @return void */ public function setIDAttribute($idAttrName) { @@ -232,6 +237,7 @@ class Signer * @param bool $full_path Whether the filename found in the configuration contains the * full path to the private key or not. Default to false. * @throws \Exception + * @return void */ public function addCertificate($file, $full_path = false) { @@ -268,6 +274,7 @@ class Signer * in which case the signature will be appended to the element spesified in * $insertInto. * @throws \Exception + * @return void */ public function sign($node, $insertInto, $insertBefore = null) { diff --git a/lib/SimpleSAML/XML/Validator.php b/lib/SimpleSAML/XML/Validator.php index 8dd46f8971c6c1bfd63fd17ed9f8e1db15428875..52c5b57d7c460c0d36c3fccab2999823b657307e 100644 --- a/lib/SimpleSAML/XML/Validator.php +++ b/lib/SimpleSAML/XML/Validator.php @@ -19,7 +19,7 @@ class Validator * @var string This variable contains the X509 certificate the XML document * was signed with, or NULL if it wasn't signed with an X509 certificate. */ - private $x509Certificate; + private $x509Certificate = null; /** * @var array|null This variable contains the nodes which are signed. @@ -156,7 +156,7 @@ class Validator * * @param string $x509cert The certificate as a base64-encoded string. The string may optionally * be framed with '-----BEGIN CERTIFICATE-----' and '-----END CERTIFICATE-----'. - * @return string The fingerprint as a 40-character lowercase hexadecimal number. NULL is returned if the + * @return string|null The fingerprint as a 40-character lowercase hexadecimal number. NULL is returned if the * argument isn't an X509 certificate. */ private static function calculateX509Fingerprint($x509cert) @@ -239,6 +239,7 @@ class Validator * @param string|array $fingerprints The fingerprints which should match. This can be a single string, * or an array of fingerprints. * @throws \Exception + * @return void */ public function validateFingerprint($fingerprints) { @@ -297,6 +298,7 @@ class Validator * * @param string $caFile File with trusted certificates, in PEM-format. * @throws \Exception + * @return void */ public function validateCA($caFile) { @@ -413,6 +415,7 @@ class Validator * @param string $certificate The certificate, in PEM format. * @param string $caFile File with trusted certificates, in PEM-format. * @throws \Exception + * @return void * @deprecated */ public static function validateCertificate($certificate, $caFile)