diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php index 86c7465cd51706c59d2b46c3bbc51de9da27eb23..eb6ef0479d051bd68b9a34c14a789112c46e7ec6 100644 --- a/lib/SimpleSAML/Auth/Default.php +++ b/lib/SimpleSAML/Auth/Default.php @@ -18,6 +18,11 @@ class DefaultAuth { /** * @deprecated This method will be removed in SSP 2.0. Use Source::initLogin() instead. + * @param string $authId + * @param string $return + * @param string|null $errorURL + * @param array $params + * @return void */ public static function initLogin( $authId, @@ -34,6 +39,8 @@ class DefaultAuth /** * @deprecated This method will be removed in SSP 2.0. Please use * State::getPersistentAuthData() instead. + * @param array &$state + * @return array */ public static function extractPersistentAuthState(array &$state) { @@ -43,6 +50,8 @@ class DefaultAuth /** * @deprecated This method will be removed in SSP 2.0. Please use Source::loginCompleted() instead. + * @param array $state + * @return void */ public static function loginCompleted($state) { @@ -52,6 +61,9 @@ class DefaultAuth /** * @deprecated This method will be removed in SSP 2.0. + * @param string $returnURL + * @param string $authority + * @return void */ public static function initLogoutReturn($returnURL, $authority) { @@ -78,6 +90,9 @@ class DefaultAuth /** * @deprecated This method will be removed in SSP 2.0. + * @param string $returnURL + * @param string $authority + * @return void */ public static function initLogout($returnURL, $authority) { @@ -92,6 +107,8 @@ class DefaultAuth /** * @deprecated This method will be removed in SSP 2.0. + * @param array $state + * @return void */ public static function logoutCompleted($state) { @@ -104,6 +121,8 @@ class DefaultAuth /** * @deprecated This method will be removed in SSP 2.0. Please use Source::logoutCallback() instead. + * @param array $state + * @return void */ public static function logoutCallback($state) { @@ -114,6 +133,10 @@ class DefaultAuth /** * @deprecated This method will be removed in SSP 2.0. Please use * \SimpleSAML\Module\saml\Auth\Source\SP::handleUnsolicitedAuth() instead. + * @param string $authId + * @param array $state + * @param string $redirectTo + * @return void */ public static function handleUnsolicitedAuth($authId, array $state, $redirectTo) { diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php index c83d221f9c73d69869edf334a97e77f16a96121a..4a2749d4020e7fda5d52f66d72898c5ad04d164f 100644 --- a/lib/SimpleSAML/Auth/LDAP.php +++ b/lib/SimpleSAML/Auth/LDAP.php @@ -34,12 +34,14 @@ class LDAP /** * LDAP link identifier. * - * @var resource + * @var resource|null */ protected $ldap = null; /** * LDAP user: authz_id if SASL is in use, binding dn otherwise + * + * @var string|null */ protected $authz_id = null; @@ -59,6 +61,7 @@ class LDAP * @param int $timeout * @param int $port * @param bool $referrals + * @psalm-suppress NullArgument */ public function __construct( $hostname, @@ -145,8 +148,8 @@ class LDAP * Convenience method to create an LDAPException as well as log the * description. * - * @param string $description - * The exception's description + * @param string $description The exception's description + * @param int|null $type The exception's type * @return \Exception */ private function makeException($description, $type = null) @@ -235,6 +238,7 @@ class LDAP * - Failed to get DN for entry * @throws Error\UserNotFound if: * - Zero entries were found + * @psalm-suppress TypeDoesNotContainType */ private function search($base, $attribute, $value, $searchFilter = null, $scope = "subtree") { @@ -321,7 +325,7 @@ class LDAP * Additional searchFilter to be added to the (attribute=value) filter * @param string $scope * The scope of the search - * @return string + * @return string|null * The DN of the matching element, if found. If no element was found and * $allowZeroHits is set to FALSE, an exception will be thrown; otherwise * NULL will be returned. @@ -420,6 +424,8 @@ class LDAP throw $this->makeException('ldap:LdapConnection->search_manual : No base DNs were passed', ERR_INTERNAL); } + $attributes = \SimpleSAML\Utils\Arrays::arrayize($attributes); + // Search each base until result is found $result = false; foreach ($bases as $base) { @@ -560,8 +566,8 @@ class LDAP * Applies an LDAP option to the current connection. * * @throws Exception - * @param $option - * @param $value + * @param mixed $option + * @param mixed $value * @return void */ public function setOption($option, $value) @@ -614,6 +620,7 @@ class LDAP // Attempt to get attributes // TODO: Should aliases be dereferenced? + /** @var array $attributes */ $result = @ldap_read($this->ldap, $dn, 'objectClass=*', $attributes, 0, 0, $this->timeout); if ($result === false) { throw $this->makeException('Library - LDAP getAttributes(): Failed to get attributes from DN \''.$dn.'\''); @@ -726,6 +733,7 @@ class LDAP * * @static * @param string|array $values Array of values to escape + * @param bool $singleValue * @return array Array $values, but escaped */ public static function escape_filter_value($values = [], $singleValue = true) @@ -734,17 +742,17 @@ class LDAP $values = \SimpleSAML\Utils\Arrays::arrayize($values); foreach ($values as $key => $val) { - // Escaping of filter meta characters - $val = str_replace('\\', '\5c', $val); - $val = str_replace('*', '\2a', $val); - $val = str_replace('(', '\28', $val); - $val = str_replace(')', '\29', $val); - - // ASCII < 32 escaping - $val = self::asc2hex32($val); - - if (null === $val) { + if ($val === null) { $val = '\0'; // apply escaped "null" if string is empty + } else { + // Escaping of filter meta characters + $val = str_replace('\\', '\5c', $val); + $val = str_replace('*', '\2a', $val); + $val = str_replace('(', '\28', $val); + $val = str_replace(')', '\29', $val); + + // ASCII < 32 escaping + $val = self::asc2hex32($val); } $values[$key] = $val; @@ -783,6 +791,11 @@ class LDAP /** * Convert SASL authz_id into a DN + * + * @param string $searchBase + * @param array $searchAttributes + * @param string $authz_id + * @return string|null */ private function authzidToDn($searchBase, $searchAttributes, $authz_id) { @@ -811,6 +824,11 @@ class LDAP * When it was integrated into PHP repository, the function prototype * was changed, The new prototype was used in third party patch for * PHP 7.0 and 7.1, hence the version test below. + * + * @param string $searchBase + * @param array $searchAttributes + * @throws \Exception + * @return string|null */ public function whoami($searchBase, $searchAttributes) { diff --git a/lib/SimpleSAML/Auth/ProcessingChain.php b/lib/SimpleSAML/Auth/ProcessingChain.php index a82d51334a2efa2ae2a7a0a07b8592975df7f407..e2ba6aa07cdff4af663eeb45628669919f1d1988 100644 --- a/lib/SimpleSAML/Auth/ProcessingChain.php +++ b/lib/SimpleSAML/Auth/ProcessingChain.php @@ -46,6 +46,7 @@ class ProcessingChain * * @param array $idpMetadata The metadata for the IdP. * @param array $spMetadata The metadata for the SP. + * @param string $mode */ public function __construct($idpMetadata, $spMetadata, $mode = 'idp') { @@ -84,6 +85,7 @@ class ProcessingChain * * @param array &$target Target filter list. This list must be sorted. * @param array $src Source filters. May be unsorted. + * @return void */ private static function addFilters(&$target, $src) { @@ -181,6 +183,9 @@ class ProcessingChain * @see State::EXCEPTION_HANDLER_FUNC * * @param array &$state The state we are processing. + * @throws \SimpleSAML\Error\Exception + * @throws \SimpleSAML\Error\UnserializableException + * @return void */ public function processState(&$state) { @@ -226,6 +231,7 @@ class ProcessingChain * to whatever exception handler is defined in the state array. * * @param array $state The state we are processing. + * @return void */ public static function resumeProcessing($state) { @@ -280,6 +286,7 @@ class ProcessingChain * This function will only return if processing completes. * * @param array &$state The state we are processing. + * @return void */ public function processStatePassive(&$state) { @@ -316,7 +323,7 @@ class ProcessingChain * * @param string $id The state identifier. * @see State::parseStateID() - * @return array The state referenced by the $id parameter. + * @return array|null The state referenced by the $id parameter. */ public static function fetchProcessedState($id) { @@ -328,6 +335,8 @@ class ProcessingChain /** * @deprecated This method will be removed in SSP 2.0. + * @param array &$state + * @return void */ private static function addUserID(&$state) { diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php index ffaa0cc92a2921fcd53cc9f472cde8fba3a64dbf..927418261878eb50ff2a0a0c96019a9da2f7913a 100644 --- a/lib/SimpleSAML/Auth/Simple.php +++ b/lib/SimpleSAML/Auth/Simple.php @@ -23,7 +23,7 @@ class Simple */ protected $authSource; - /** @var \SimpleSAML\Configuration */ + /** @var \SimpleSAML\Configuration|null */ protected $app_config; /** @var \SimpleSAML\Session */ @@ -97,6 +97,7 @@ class Simple * method for a description. * * @param array $params Various options to the authentication request. See the documentation. + * @return void */ public function requireAuth(array $params = []) { @@ -122,6 +123,7 @@ class Simple * Please note: this function never returns. * * @param array $params Various options to the authentication request. + * @return void */ public function login(array $params = []) { @@ -181,6 +183,7 @@ class Simple * * @param string|array|null $params Either the URL the user should be redirected to after logging out, or an array * with parameters for the logout. If this parameter is null, we will return to the current page. + * @return void */ public function logout($params = null) { @@ -229,6 +232,7 @@ class Simple * This function never returns. * * @param array $state The state after the logout. + * @return void */ public static function logoutCompleted($state) { diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php index d24f6e774fe841b6c37acf973d38e08845f41f33..6bf02b352675e9bd26da3b8d47969e5f4980d47c 100644 --- a/lib/SimpleSAML/Auth/Source.php +++ b/lib/SimpleSAML/Auth/Source.php @@ -98,6 +98,7 @@ abstract class Source * information about the user, and call completeAuth with the state array. * * @param array &$state Information about the current authentication. + * @return void */ abstract public function authenticate(&$state); @@ -109,6 +110,7 @@ abstract class Source * interact with the user even in the case when the user is already authenticated. * * @param array &$state Information about the current authentication. + * @return void */ public function reauthenticate(array &$state) { @@ -131,6 +133,7 @@ abstract class Source * but should instead be passed to the top-level exception handler. * * @param array &$state Information about the current authentication. + * @return void */ public static function completeAuth(&$state) { @@ -159,6 +162,7 @@ abstract class Source * check it by calling \SimpleSAML\Utils\HTTP::checkURLAllowed(). * @param array $params Extra information about the login. Different authentication requestors may provide different * information. Optional, will default to an empty array. + * @return void */ public function initLogin($return, $errorURL = null, array $params = []) { @@ -207,6 +211,7 @@ abstract class Source * This method never returns. * * @param array $state The state after the login has completed. + * @return void */ public static function loginCompleted($state) { @@ -245,6 +250,7 @@ abstract class Source * showing the user a page, or redirecting, this function should return. * * @param array &$state Information about the current logout operation. + * @return void */ public function logout(&$state) { @@ -261,6 +267,7 @@ abstract class Source * but should instead be passed to the top-level exception handler. * * @param array &$state Information about the current authentication. + * @return void */ public static function completeLogout(&$state) { @@ -286,7 +293,7 @@ abstract class Source * @param string $authId The authentication source identifier. * @param array $config The configuration. * - * @return Source The parsed authentication source. + * @return \SimpleSAML\Auth\Source The parsed authentication source. * @throws \Exception If the authentication source is invalid. */ private static function parseAuthSource($authId, $config) @@ -335,9 +342,9 @@ abstract class Source * authentication source of a different type is found, an exception will be thrown. * * @param string $authId The authentication source identifier. - * @param string|NULL $type The type of authentication source. If NULL, any type will be accepted. + * @param string|null $type The type of authentication source. If NULL, any type will be accepted. * - * @return Source|NULL The AuthSource object, or NULL if no authentication + * @return \SimpleSAML\Auth\Source|null The AuthSource object, or NULL if no authentication * source with the given identifier is found. * @throws \SimpleSAML\Error\Exception If no such authentication source is found or it is invalid. */ @@ -379,6 +386,7 @@ abstract class Source * Called when the authentication source receives an external logout request. * * @param array $state State array for the logout operation. + * @return void */ public static function logoutCallback($state) { @@ -411,6 +419,7 @@ abstract class Source * * @param string $assoc The identifier for this logout association. * @param array $state The state array passed to the authenticate-function. + * @return void */ protected function addLogoutCallback($assoc, $state) { @@ -455,6 +464,7 @@ abstract class Source * This function always returns. * * @param string $assoc The logout association which should be called. + * @return void */ protected function callLogoutCallback($assoc) { @@ -504,6 +514,7 @@ abstract class Source * @param string $id The auth source identifier. * * @throws \Exception If the first element of $source is not an identifier for the auth source. + * @return void */ protected static function validateSource($source, $id) { diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php index 8ee2986db0612988e7fcd8fa3154c7be6935adc4..48a5cfea6d754ba11add3f3d8a946cf19633fb49 100644 --- a/lib/SimpleSAML/Auth/State.php +++ b/lib/SimpleSAML/Auth/State.php @@ -254,7 +254,7 @@ class State * @throws \SimpleSAML\Error\NoState If we couldn't find the state and there's no URL defined to redirect to. * @throws \Exception If the stage of the state is invalid and there's no URL defined to redirect to. * - * @return array|NULL State information, or null if the state is missing and $allowMissing is true. + * @return array|null State information, or NULL if the state is missing and $allowMissing is true. */ public static function loadState($id, $stage, $allowMissing = false) { @@ -315,6 +315,7 @@ class State * This function deletes the given state to prevent the user from reusing it later. * * @param array &$state The state which should be deleted. + * @return void */ public static function deleteState(&$state) { @@ -339,6 +340,7 @@ class State * @param \SimpleSAML\Error\Exception $exception The exception. * * @throws \SimpleSAML\Error\Exception If there is no exception handler defined, it will just throw the $exception. + * @return void */ public static function throwException($state, \SimpleSAML\Error\Exception $exception) { @@ -373,9 +375,9 @@ class State /** * Retrieve an exception state. * - * @param string|NULL $id The exception id. Can be NULL, in which case it will be retrieved from the request. + * @param string|null $id The exception id. Can be NULL, in which case it will be retrieved from the request. * - * @return array|NULL The state array with the exception, or NULL if no exception was thrown. + * @return array|null The state array with the exception, or NULL if no exception was thrown. */ public static function loadExceptionState($id = null) { diff --git a/lib/SimpleSAML/Auth/TimeLimitedToken.php b/lib/SimpleSAML/Auth/TimeLimitedToken.php index eb6620d5ec039213f25ba8acee90b7a8b9350a48..5b4c3c2a294aca514dc49c0cbc802a68429e6878 100644 --- a/lib/SimpleSAML/Auth/TimeLimitedToken.php +++ b/lib/SimpleSAML/Auth/TimeLimitedToken.php @@ -66,6 +66,7 @@ class TimeLimitedToken * not only the same data must be added, but also in the same order. * * @param string $data The data to incorporate into the current token. + * @return void */ public function addVerificationData($data) { @@ -110,6 +111,7 @@ class TimeLimitedToken /** * @see generate * @deprecated This method will be removed in SSP 2.0. Use generate() instead. + * @return string */ public function generate_token() { @@ -122,7 +124,7 @@ class TimeLimitedToken * * @param string $token The token to validate. * - * @return boolean True if the given token is currently valid, false otherwise. + * @return bool True if the given token is currently valid, false otherwise. */ public function validate($token) { @@ -139,6 +141,8 @@ class TimeLimitedToken /** * @see validate * @deprecated This method will be removed in SSP 2.0. Use validate() instead. + * @param string $token + * @return bool */ public function validate_token($token) { diff --git a/lib/SimpleSAML/Bindings/Shib13/Artifact.php b/lib/SimpleSAML/Bindings/Shib13/Artifact.php index 3ce30d977fbb3d902817729e0a071af86eb85864..30d7d130bf0d083388dbf9a16448ea61a2f5f13a 100644 --- a/lib/SimpleSAML/Bindings/Shib13/Artifact.php +++ b/lib/SimpleSAML/Bindings/Shib13/Artifact.php @@ -181,8 +181,8 @@ class Artifact ]; // Fetch the artifact - $response = HTTP::fetch($url, $opts); /** @var string $response */ + $response = HTTP::fetch($url, $opts); XML::debugSAMLMessage($response, 'in'); // Find the response in the SOAP message diff --git a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php index 893682c1b8569bb0eb2e619f4f38a1b453e79c73..bc1a4b04f8580e135f6be3a4ccace51e2377c84c 100644 --- a/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php +++ b/lib/SimpleSAML/Bindings/Shib13/HTTPPost.php @@ -20,12 +20,12 @@ use SimpleSAML\XML\Signer; class HTTPPost { /** - * @var \SimpleSAML\Configuration + * @var \SimpleSAML\Configuration|null */ private $configuration = null; /** - * @var \SimpleSAML\Metadata\MetaDataStorageHandler + * @var \SimpleSAML\Metadata\MetaDataStorageHandler|null */ private $metadata = null; @@ -53,6 +53,7 @@ class HTTPPost * @param \SimpleSAML\Configuration $spmd The metadata of the SP which is receiving the response. * @param string|null $relayState The relaystate for the SP. * @param string $shire The shire which should receive the response. + * @return void */ public function sendResponse( $response, diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index f9275d521f0704d3d2499c47b920976f9aac161d..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. @@ -1269,7 +1274,7 @@ class Configuration implements Utils\ClearableState * @param mixed $default The default value. If no default is given, and the option isn't found, an exception will * be thrown. * - * @return array Associative array with language => string pairs. + * @return mixed Associative array with language => string pairs, or the provided default value. * * @throws \Exception If the translation is not an array or a string, or its index or value are not strings. */ @@ -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/Error/Assertion.php b/lib/SimpleSAML/Error/Assertion.php index c16f61164ceb5a1afb84f91bd9a7762b15e6449c..691f2c90410b5fa38fd78f1513ca097f9b08d964 100644 --- a/lib/SimpleSAML/Error/Assertion.php +++ b/lib/SimpleSAML/Error/Assertion.php @@ -53,6 +53,7 @@ class Assertion extends Exception * * This function will register this assertion handler. If will not enable assertions if they are * disabled. + * @return void */ public static function installHandler() { @@ -71,6 +72,7 @@ class Assertion extends Exception * @param string $file The file assert was called from. * @param int $line The line assert was called from. * @param mixed $message The expression which was passed to the assert-function. + * @return void */ public static function onAssertion($file, $line, $message) { diff --git a/lib/SimpleSAML/Error/AuthSource.php b/lib/SimpleSAML/Error/AuthSource.php index e075aa7bc45a5036300550bdd440de478acaae1a..4b29f3e555c210d769361396e8c21de799b741f9 100644 --- a/lib/SimpleSAML/Error/AuthSource.php +++ b/lib/SimpleSAML/Error/AuthSource.php @@ -12,13 +12,15 @@ namespace SimpleSAML\Error; class AuthSource extends Error { /** - * Authsource module name. + * Authsource module name + * @var string */ private $authsource; /** * Reason why this request was invalid. + * @var string */ private $reason; @@ -28,6 +30,7 @@ class AuthSource extends Error * * @param string $authsource Authsource module name from where this error was thrown. * @param string $reason Description of the error. + * @param Exception|null $cause */ public function __construct($authsource, $reason, $cause = null) { diff --git a/lib/SimpleSAML/Error/BadRequest.php b/lib/SimpleSAML/Error/BadRequest.php index 1deb08c0bf3e9c3d2b9982868454168fc76dc29a..418f184b4ff8b89748cf42efb3202a07c075e778 100644 --- a/lib/SimpleSAML/Error/BadRequest.php +++ b/lib/SimpleSAML/Error/BadRequest.php @@ -16,6 +16,7 @@ class BadRequest extends Error { /** * Reason why this request was invalid. + * @var string */ private $reason; diff --git a/lib/SimpleSAML/Error/CriticalConfigurationError.php b/lib/SimpleSAML/Error/CriticalConfigurationError.php index d41367fbf051cd6800045888928c134a47551798..064a30fb3cf3c1cfaa3f193952af485bf963c07e 100644 --- a/lib/SimpleSAML/Error/CriticalConfigurationError.php +++ b/lib/SimpleSAML/Error/CriticalConfigurationError.php @@ -60,7 +60,7 @@ class CriticalConfigurationError extends ConfigurationError /** - * @param ConfigurationError $exception + * @param \Exception $exception * * @return CriticalConfigurationError */ diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php index 615da09c01e8b816cfbd7c8a1b5ca4232bdbfa10..7d56196be750004d891a227e351eea3ba6bd5108 100644 --- a/lib/SimpleSAML/Error/Error.php +++ b/lib/SimpleSAML/Error/Error.php @@ -155,6 +155,7 @@ class Error extends Exception * Set the HTTP return code for this error. * * This should be overridden by subclasses who want a different return code than 500 Internal Server Error. + * @return void */ protected function setHTTPCode() { @@ -208,6 +209,7 @@ class Error extends Exception * Display this error. * * This method displays a standard SimpleSAMLphp error page and exits. + * @return void */ public function show() { diff --git a/lib/SimpleSAML/Error/Exception.php b/lib/SimpleSAML/Error/Exception.php index 5ab59f4821213500199c53e50b15968bc3e58124..78267a17c7fef8c3d963f01047cb7a3793bb299c 100644 --- a/lib/SimpleSAML/Error/Exception.php +++ b/lib/SimpleSAML/Error/Exception.php @@ -21,15 +21,15 @@ class Exception extends \Exception * * @var array */ - private $backtrace; + private $backtrace = []; /** * The cause of this exception. * - * @var Exception + * @var Exception|null */ - private $cause; + private $cause = null; /** @@ -77,6 +77,7 @@ class Exception extends \Exception * Load the backtrace from the given exception. * * @param \Exception $exception The exception we should fetch the backtrace from. + * @return void */ protected function initBacktrace(\Exception $exception) { @@ -193,6 +194,8 @@ class Exception extends \Exception /** * Print the backtrace to the log if the 'debug' option is enabled in the configuration. + * @param int $level + * @return void */ protected function logBacktrace($level = \SimpleSAML\Logger::DEBUG) { @@ -231,6 +234,7 @@ class Exception extends \Exception * Override to allow errors extending this class to specify the log level themselves. * * @param int $default_level The log level to use if this method was not overridden. + * @return void */ public function log($default_level) { @@ -248,6 +252,7 @@ class Exception extends \Exception * Print the exception to the log with log level error. * * This function will write this exception to the log, including a full backtrace. + * @return void */ public function logError() { @@ -260,6 +265,7 @@ class Exception extends \Exception * Print the exception to the log with log level warning. * * This function will write this exception to the log, including a full backtrace. + * @return void */ public function logWarning() { @@ -272,6 +278,7 @@ class Exception extends \Exception * Print the exception to the log with log level info. * * This function will write this exception to the log, including a full backtrace. + * @return void */ public function logInfo() { @@ -284,6 +291,7 @@ class Exception extends \Exception * Print the exception to the log with log level debug. * * This function will write this exception to the log, including a full backtrace. + * @return void */ public function logDebug() { diff --git a/lib/SimpleSAML/HTTP/Router.php b/lib/SimpleSAML/HTTP/Router.php index e537092a9e62352497e49233f610a9e4a3a93a13..699d3a752bbcfc93c30b655ea11f7665a2f3ea71 100644 --- a/lib/SimpleSAML/HTTP/Router.php +++ b/lib/SimpleSAML/HTTP/Router.php @@ -20,11 +20,11 @@ use Symfony\Component\Routing\RequestContext; */ class Router { - + /** @var ArgumentResolver */ protected $arguments; - /** @var \SimpleSAML\Configuration */ - protected $config; + /** @var \SimpleSAML\Configuration|null */ + protected $config = null; /** @var RequestContext */ protected $context; @@ -32,17 +32,17 @@ class Router /** @var EventDispatcher */ protected $dispatcher; - /** @var Request */ - protected $request; + /** @var Request|null */ + protected $request = null; /** @var \SimpleSAML\Module\ControllerResolver */ protected $resolver; - /** @var \SimpleSAML\Session */ - protected $session; + /** @var \SimpleSAML\Session|null */ + protected $session = null; - /** @var RequestStack */ - protected $stack; + /** @var RequestStack|null */ + protected $stack = null; /** @@ -94,6 +94,7 @@ class Router * Send a given response to the browser. * * @param Response $response The response to send. + * @return void */ public function send(Response $response) { @@ -106,6 +107,7 @@ class Router * Set the configuration to use by the controller. * * @param \SimpleSAML\Configuration $config + * @return void */ public function setConfiguration(Configuration $config) { @@ -118,6 +120,7 @@ class Router * Set the session to use by the controller. * * @param \SimpleSAML\Session $session + * @return void */ public function setSession(Session $session) { diff --git a/lib/SimpleSAML/HTTP/RunnableResponse.php b/lib/SimpleSAML/HTTP/RunnableResponse.php index ab9fc6c5f14ed6b31a7c16522de1b5e1033bd227..2692c75f15f1c341f1520bb0ec14e63dc128a919 100644 --- a/lib/SimpleSAML/HTTP/RunnableResponse.php +++ b/lib/SimpleSAML/HTTP/RunnableResponse.php @@ -60,7 +60,7 @@ class RunnableResponse extends Response /** * "Send" this response by actually running the callable. * - * @return mixed + * @return self */ public function send() { diff --git a/lib/SimpleSAML/IdP.php b/lib/SimpleSAML/IdP.php index 70db63b4c4284b55ef2a02edc277d0b0fc4a5b1d..6a963c30e048101030c366ce54f364a1b6744191 100644 --- a/lib/SimpleSAML/IdP.php +++ b/lib/SimpleSAML/IdP.php @@ -34,16 +34,16 @@ class IdP * We use this to support cross-protocol logout until * we implement a cross-protocol IdP. * - * @var string + * @var string|null */ - private $associationGroup; + private $associationGroup = null; /** * The configuration for this IdP. * - * @var Configuration + * @var Configuration|null */ - private $config; + private $config = null; /** * Our authsource. @@ -158,7 +158,7 @@ class IdP /** * Retrieve the configuration for this IdP. * - * @return Configuration The configuration object. + * @return Configuration|null The configuration object. */ public function getConfig() { @@ -213,6 +213,7 @@ class IdP * Add an SP association. * * @param array $association The SP association. + * @return void */ public function addAssociation(array $association) { @@ -242,6 +243,7 @@ class IdP * Remove an SP association. * * @param string $assocId The association id. + * @return void */ public function terminateAssociation($assocId) { @@ -267,6 +269,7 @@ class IdP * Called after authproc has run. * * @param array $state The authentication request state array. + * @return void */ public static function postAuthProc(array $state) { @@ -293,6 +296,7 @@ class IdP * @param array $state The authentication request state array. * * @throws Exception If we are not authenticated. + * @return void */ public static function postAuth(array $state) { @@ -340,6 +344,7 @@ class IdP * @param array &$state The authentication request state. * * @throws Module\saml\Error\NoPassive If we were asked to do passive authentication. + * @return void */ private function authenticate(array &$state) { @@ -362,14 +367,11 @@ class IdP * @param array &$state The authentication request state. * * @throws Exception If there is no auth source defined for this IdP. + * @return void */ private function reauthenticate(array &$state) { $sourceImpl = $this->authSource->getAuthSource(); - if ($sourceImpl === null) { - throw new Exception('No such auth source defined.'); - } - $sourceImpl->reauthenticate($state); } @@ -378,6 +380,7 @@ class IdP * Process authentication requests. * * @param array &$state The authentication request state. + * @return void */ public function handleAuthenticationRequest(array &$state) { @@ -454,6 +457,7 @@ class IdP * This function will never return. * * @param array &$state The logout request state. + * @return void */ public function finishLogout(array &$state) { @@ -473,6 +477,7 @@ class IdP * @param array &$state The logout request state. * @param string|null $assocId The association we received the logout request from, or null if there was no * association. + * @return void */ public function handleLogoutRequest(array &$state, $assocId) { @@ -508,6 +513,7 @@ class IdP * @param string $assocId The association that is terminated. * @param string|null $relayState The RelayState from the start of the logout. * @param Exception|null $error The error that occurred during session termination (if any). + * @return void */ public function handleLogoutResponse($assocId, $relayState, Exception $error = null) { @@ -530,6 +536,7 @@ class IdP * This function never returns. * * @param string $url The URL the user should be returned to after logout. + * @return void */ public function doLogoutRedirect($url) { @@ -552,6 +559,7 @@ class IdP * * @param IdP $idp Deprecated. Will be removed. * @param array &$state The logout state from doLogoutRedirect(). + * @return void */ public static function finishLogoutRedirect(IdP $idp, array $state) { diff --git a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php index b2d808cc29363bc5e1f5f37add2264b9ea783f76..363fae8d35838c86f849b6848adec6505cba33ca 100644 --- a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php +++ b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php @@ -35,6 +35,7 @@ class IFrameLogoutHandler implements LogoutHandlerInterface * * @param array &$state The logout state. * @param string|null $assocId The SP we are logging out from. + * @return void */ public function startLogout(array &$state, $assocId) { @@ -82,8 +83,9 @@ class IFrameLogoutHandler implements LogoutHandlerInterface * This function will never return. * * @param string $assocId The association that is terminated. - * @param string|null $relayState The RelayState from the start of the logout. + * @param string $relayState The RelayState from the start of the logout. * @param \SimpleSAML\Error\Exception|null $error The error that occurred during session termination (if any). + * @return void */ public function onResponse($assocId, $relayState, \SimpleSAML\Error\Exception $error = null) { diff --git a/lib/SimpleSAML/IdP/LogoutHandlerInterface.php b/lib/SimpleSAML/IdP/LogoutHandlerInterface.php index 773bda69470d21ac329985931c57df989e9da1da..3ac7a3d118c2b2b36acf2327172b8bacec51ea3a 100644 --- a/lib/SimpleSAML/IdP/LogoutHandlerInterface.php +++ b/lib/SimpleSAML/IdP/LogoutHandlerInterface.php @@ -24,7 +24,8 @@ interface LogoutHandlerInterface * This function must never return. * * @param array &$state The logout state. - * @param string|null $assocId The association that started the logout. + * @param string $assocId The association that started the logout. + * @return void */ public function startLogout(array &$state, $assocId); @@ -37,6 +38,7 @@ interface LogoutHandlerInterface * @param string $assocId The association that is terminated. * @param string|null $relayState The RelayState from the start of the logout. * @param \SimpleSAML\Error\Exception|null $error The error that occurred during session termination (if any). + * @return void */ public function onResponse($assocId, $relayState, \SimpleSAML\Error\Exception $error = null); } diff --git a/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php b/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php index 32652b5617a747437bc331e86870fbdc5a3a5f81..e6b1717e9058009c47cbf8e78df6068be4fe5fcd 100644 --- a/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php +++ b/lib/SimpleSAML/IdP/TraditionalLogoutHandler.php @@ -38,6 +38,7 @@ class TraditionalLogoutHandler implements LogoutHandlerInterface * This function never returns. * * @param array &$state The logout state. + * @return void */ private function logoutNextSP(array &$state) { @@ -74,6 +75,7 @@ class TraditionalLogoutHandler implements LogoutHandlerInterface * * @param array &$state The logout state. * @param string $assocId The association that started the logout. + * @return void */ public function startLogout(array &$state, $assocId) { @@ -91,6 +93,7 @@ class TraditionalLogoutHandler implements LogoutHandlerInterface * @param string $assocId The association that is terminated. * @param string|null $relayState The RelayState from the start of the logout. * @param \SimpleSAML\Error\Exception|null $error The error that occurred during session termination (if any). + * @return void * * @throws \SimpleSAML\Error\Exception If the RelayState was lost during logout. */ diff --git a/lib/SimpleSAML/Locale/Language.php b/lib/SimpleSAML/Locale/Language.php index 94a1c0bf42b82c26d347d2aff62d0c7c0edbe994..e8f06cf09875a05bfee64a5779acd3a4e5c4792b 100644 --- a/lib/SimpleSAML/Locale/Language.php +++ b/lib/SimpleSAML/Locale/Language.php @@ -196,6 +196,7 @@ class Language * * @param string $language Language code for the language to set. * @param boolean $setLanguageCookie Whether to set the language cookie or not. Defaults to true. + * @return void */ public function setLanguage($language, $setLanguageCookie = true) { @@ -255,7 +256,7 @@ class Language * * @param string $code The ISO 639-2 code of the language. * - * @return string The localized name of the language. + * @return string|null The localized name of the language. */ public function getLanguageLocalizedName($code) { @@ -281,8 +282,8 @@ class Language /** * This method returns the preferred language for the user based on the Accept-Language HTTP header. * - * @return string The preferred language based on the Accept-Language HTTP header, or null if none of the languages - * in the header is available. + * @return string|null The preferred language based on the Accept-Language HTTP header, + * or null if none of the languages in the header is available. */ private function getHTTPLanguage() { @@ -334,7 +335,8 @@ class Language /** * Return an alias for a language code, if any. * - * @return string The alias, or null if the alias was not found. + * @param string $langcode + * @return string|null The alias, or null if the alias was not found. */ public function getLanguageCodeAlias($langcode) { @@ -399,6 +401,7 @@ class Language * specified is not in the list of available languages, or the headers have already been sent to the browser. * * @param string $language The language set by the user. + * @return void */ public static function setLanguageCookie($language) { diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php index 822a71f96f80d59c5376215c65598137a04a9d9e..c9c7e93a2f4f64fe339cc98bac239843e8954649 100644 --- a/lib/SimpleSAML/Locale/Localization.php +++ b/lib/SimpleSAML/Locale/Localization.php @@ -132,6 +132,7 @@ class Localization * * @param string $module Module name * @param string $localeDir Absolute path if the module is housed elsewhere + * @return void */ public function addModuleDomain($module, $localeDir = null) { @@ -148,6 +149,7 @@ class Localization * * @param string $localeDir Location of translations * @param string $domain Domain at location + * @return void */ public function addDomain($localeDir, $domain) { @@ -156,7 +158,7 @@ class Localization $this->loadGettextGettextFromPO($domain); } - /* + /** * Get and check path of localization file * * @param string $domain Name of localization domain @@ -205,6 +207,7 @@ class Localization /** * Setup the translator + * @return void */ private function setupTranslator() { @@ -221,6 +224,7 @@ class Localization * * @param string $domain Name of domain * @param boolean $catchException Whether to catch an exception on error or return early + * @return void * * @throws \Exception If something is wrong with the locale file for the domain and activated language */ @@ -268,6 +272,7 @@ class Localization /** * Set up L18N if configured or fallback to old system + * @return void */ private function setupL10N() { diff --git a/lib/SimpleSAML/Locale/Translate.php b/lib/SimpleSAML/Locale/Translate.php index d64f222cd78715346fc40a626a7237ff3aa907ce..a5c0442ad2b23228b48dd00d4db5c80c1cb1aa07 100644 --- a/lib/SimpleSAML/Locale/Translate.php +++ b/lib/SimpleSAML/Locale/Translate.php @@ -119,7 +119,7 @@ class Translate * @param string $tag The tag name. The tag name can also be on the form '{<dictionary>:<tag>}', to retrieve a tag * from the specific dictionary. * - * @return array An associative array with language => string mappings, or null if the tag wasn't found. + * @return array|null An associative array with language => string mappings, or null if the tag wasn't found. */ public function getTag($tag) { @@ -252,6 +252,8 @@ class Translate * @param array $replacements An associative array of keys that should be replaced with values in the * translated string. * @param boolean $fallbackdefault Default translation to use as a fallback if no valid translation was found. + * @param array $oldreplacements + * @param bool $striptags * @deprecated Not used in twig, gettext * * @return string The translated tag, or a placeholder value if the tag wasn't found. @@ -285,7 +287,7 @@ class Translate ); // for backwards compatibility - if (!$replacements && $this->getTag($tag) === null) { + if (!$replacements && ($this->getTag($tag) === null)) { \SimpleSAML\Logger::warning( 'Code which uses $fallbackdefault === FALSE should be updated to use the getTag() method instead.' ); @@ -349,6 +351,7 @@ class Translate * @param array|string $translation The translation array * * @throws \Exception If $translation is neither a string nor an array. + * @return void */ public function includeInlineTranslation($tag, $translation) { @@ -370,6 +373,7 @@ class Translate * one provided in the constructor to be used to find the directory of the dictionary. This allows to combine * dictionaries inside the SimpleSAMLphp main code distribution together with external dictionaries. Defaults to * null. + * @return void */ public function includeLanguageFile($file, $otherConfig = null) { diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index f0befad0da2bceb81334ea9d07a71523f3bbb398..696ce6fe57050085ab3e91bb991d3f373145889e 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -61,12 +61,16 @@ class Logger /** * This constant defines the string we set the track ID to while we are fetching the track ID from the session * class. This is used to prevent infinite recursion. + * + * @var string */ const NO_TRACKID = '_NOTRACKIDYET_'; /** * This variable holds the track ID we have retrieved from the session class. It can also be NULL, in which case * we haven't fetched the track ID yet, or self::NO_TRACKID, which means that we are fetching the track ID now. + * + * @var string */ private static $trackid = self::NO_TRACKID; @@ -114,20 +118,36 @@ class Logger */ private static $shuttingDown = false; + /** @var int */ const EMERG = 0; + + /** @var int */ const ALERT = 1; + + /** @var int */ const CRIT = 2; + + /** @var int */ const ERR = 3; + + /** @var int */ const WARNING = 4; + + /** @var int */ const NOTICE = 5; + + /** @var int */ const INFO = 6; + + /** @var int */ const DEBUG = 7; /** * Log an emergency message. * - * @var string $string The message to log. + * @param string $string The message to log. + * @return void */ public static function emergency($string) { @@ -138,7 +158,8 @@ class Logger /** * Log a critical message. * - * @var string $string The message to log. + * @param string $string The message to log. + * @return void */ public static function critical($string) { @@ -149,7 +170,8 @@ class Logger /** * Log an alert. * - * @var string $string The message to log. + * @param string $string The message to log. + * @return void */ public static function alert($string) { @@ -160,7 +182,8 @@ class Logger /** * Log an error. * - * @var string $string The message to log. + * @param string $string The message to log. + * @return void */ public static function error($string) { @@ -171,7 +194,8 @@ class Logger /** * Log a warning. * - * @var string $string The message to log. + * @param string $string The message to log. + * @return void */ public static function warning($string) { @@ -182,7 +206,8 @@ class Logger /** * We reserve the notice level for statistics, so do not use this level for other kind of log messages. * - * @var string $string The message to log. + * @param string $string The message to log. + * @return void */ public static function notice($string) { @@ -193,7 +218,8 @@ class Logger /** * Info messages are a bit less verbose than debug messages. This is useful to trace a session. * - * @var string $string The message to log. + * @param string $string The message to log. + * @return void */ public static function info($string) { @@ -205,7 +231,8 @@ class Logger * Debug messages are very verbose, and will contain more information than what is necessary for a production * system. * - * @var string $string The message to log. + * @param string $string The message to log. + * @return void */ public static function debug($string) { @@ -216,7 +243,8 @@ class Logger /** * Statistics. * - * @var string $string The message to log. + * @param string $string The message to log. + * @return void */ public static function stats($string) { @@ -227,7 +255,8 @@ class Logger /** * Set the logger to capture logs. * - * @var boolean $val Whether to capture logs or not. Defaults to TRUE. + * @param boolean $val Whether to capture logs or not. Defaults to TRUE. + * @return void */ public static function setCaptureLog($val = true) { @@ -237,6 +266,7 @@ class Logger /** * Get the captured log. + * @return array */ public static function getCapturedLog() { @@ -247,7 +277,8 @@ class Logger /** * Set the track identifier to use in all logs. * - * @param $trackId string The track identifier to use during this session. + * @param string $trackId The track identifier to use during this session. + * @return void */ public static function setTrackId($trackId) { @@ -261,6 +292,7 @@ class Logger * This method is intended to be registered as a shutdown handler, so that any pending messages that weren't sent * to the logging handler at that point, can still make it. It is therefore not intended to be called manually. * + * @return void */ public static function flush() { @@ -299,6 +331,7 @@ class Logger * Every call to this function must be followed by a call to popErrorMask(). * * @param int $mask The log levels that should be masked. + * @return void */ public static function maskErrors($mask) { @@ -317,6 +350,8 @@ class Logger * Pop an error mask. * * This function restores the previous error mask. + * + * @return void */ public static function popErrorMask() { @@ -332,6 +367,7 @@ class Logger * @param int $level The log level corresponding to this message. * @param string $message The message itself to log. * @param boolean $stats Whether this is a stats message or a regular one. + * @return void */ private static function defer($level, $message, $stats) { @@ -346,6 +382,11 @@ class Logger } + /** + * @param \SimpleSAML\Logger\LoggingHandlerInterface|null $handler + * @return void + * @throws \Exception + */ private static function createLoggingHandler($handler = null) { // set to false to indicate that it is being initialized @@ -390,7 +431,12 @@ class Logger self::$loggingHandler->setLogFormat(self::$format); } - + /** + * @param int $level + * @param string $string + * @param bool $statsLog + * @return void + */ private static function log($level, $string, $statsLog = false) { if (self::$loggingHandler === false) { diff --git a/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php b/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php index 355fe24d1d262b0cefbf1c36b35a692701b107bc..bde8bc75733383d35d270851b97ee202676b805a 100644 --- a/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php +++ b/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php @@ -16,6 +16,8 @@ class ErrorLogLoggingHandler implements LoggingHandlerInterface { /** * This array contains the mappings from syslog log level to names. + * + * @var array */ private static $levelNames = [ Logger::EMERG => 'EMERG', @@ -51,6 +53,7 @@ class ErrorLogLoggingHandler implements LoggingHandlerInterface * Set the format desired for the logs. * * @param string $format The format used for logs. + * @return void */ public function setLogFormat($format) { @@ -63,6 +66,7 @@ class ErrorLogLoggingHandler implements LoggingHandlerInterface * * @param int $level The log level. * @param string $string The formatted message to log. + * @return void */ public function log($level, $string) { diff --git a/lib/SimpleSAML/Logger/FileLoggingHandler.php b/lib/SimpleSAML/Logger/FileLoggingHandler.php index 8e9202f55d6b289c52c1129dcbb9c9fda008a97d..5a6923f9265051521bbea863e8d1d93cd625e447 100644 --- a/lib/SimpleSAML/Logger/FileLoggingHandler.php +++ b/lib/SimpleSAML/Logger/FileLoggingHandler.php @@ -13,7 +13,6 @@ use SimpleSAML\Logger; */ class FileLoggingHandler implements LoggingHandlerInterface { - /** * A string with the path to the file where we should log our messages. * @@ -24,6 +23,8 @@ class FileLoggingHandler implements LoggingHandlerInterface /** * This array contains the mappings from syslog log levels to names. Copied more or less directly from * SimpleSAML\Logger\ErrorLogLoggingHandler. + * + * @var array */ private static $levelNames = [ Logger::EMERG => 'EMERGENCY', @@ -35,12 +36,17 @@ class FileLoggingHandler implements LoggingHandlerInterface Logger::INFO => 'INFO', Logger::DEBUG => 'DEBUG', ]; + + /** @var string|null */ protected $processname = null; - protected $format; + + /** @var string */ + protected $format = "%b %d %H:%M:%S"; /** * Build a new logging handler based on files. + * @param \SimpleSAML\Configuration $config */ public function __construct(\SimpleSAML\Configuration $config) { @@ -70,6 +76,7 @@ class FileLoggingHandler implements LoggingHandlerInterface * Set the format desired for the logs. * * @param string $format The format used for logs. + * @return void */ public function setLogFormat($format) { @@ -82,6 +89,7 @@ class FileLoggingHandler implements LoggingHandlerInterface * * @param int $level The log level. * @param string $string The formatted message to log. + * @return void */ public function log($level, $string) { diff --git a/lib/SimpleSAML/Logger/LoggingHandlerInterface.php b/lib/SimpleSAML/Logger/LoggingHandlerInterface.php index a9b939ddd0b7b2c6356766faa8634d8ec8164a2e..e3b46cf27705be1aac3835197b6b5519a85dbfde 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerInterface.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerInterface.php @@ -11,7 +11,6 @@ namespace SimpleSAML\Logger; interface LoggingHandlerInterface { - /** * Constructor for log handlers. It must accept receiving a \SimpleSAML\Configuration object. * @@ -25,6 +24,7 @@ interface LoggingHandlerInterface * * @param int $level The log level. * @param string $string The message to log. + * @return void */ public function log($level, $string); @@ -33,6 +33,7 @@ interface LoggingHandlerInterface * Set the format desired for the logs. * * @param string $format The format used for logs. + * @return void */ public function setLogFormat($format); } diff --git a/lib/SimpleSAML/Logger/StandardErrorLoggingHandler.php b/lib/SimpleSAML/Logger/StandardErrorLoggingHandler.php index 3413e68cea3f4cb0e965c32e9ac899a8126aad57..f17e58ddc5e12fddab7c4933ebe72959769df098 100644 --- a/lib/SimpleSAML/Logger/StandardErrorLoggingHandler.php +++ b/lib/SimpleSAML/Logger/StandardErrorLoggingHandler.php @@ -10,11 +10,12 @@ namespace SimpleSAML\Logger; */ class StandardErrorLoggingHandler extends FileLoggingHandler { - /** * StandardError constructor. * * It runs the parent constructor and sets the log file to be the standard error descriptor. + * + * @param \SimpleSAML\Configuration $config */ public function __construct(\SimpleSAML\Configuration $config) { diff --git a/lib/SimpleSAML/Logger/SyslogLoggingHandler.php b/lib/SimpleSAML/Logger/SyslogLoggingHandler.php index 8d6e21a396fa899d3bd095adba6bece993fef95d..fcbb157ffc554e94c9f99c52869fb0038a042282 100644 --- a/lib/SimpleSAML/Logger/SyslogLoggingHandler.php +++ b/lib/SimpleSAML/Logger/SyslogLoggingHandler.php @@ -13,12 +13,16 @@ use SimpleSAML\Utils\System; */ class SyslogLoggingHandler implements LoggingHandlerInterface { + /** @var bool */ private $isWindows = false; - private $format; + + /** @var string */ + protected $format = "%b %d %H:%M:%S"; /** * Build a new logging handler based on syslog. + * @param \SimpleSAML\Configuration $config */ public function __construct(\SimpleSAML\Configuration $config) { @@ -40,6 +44,7 @@ class SyslogLoggingHandler implements LoggingHandlerInterface * Set the format desired for the logs. * * @param string $format The format used for logs. + * @return void */ public function setLogFormat($format) { @@ -52,6 +57,7 @@ class SyslogLoggingHandler implements LoggingHandlerInterface * * @param int $level The log level. * @param string $string The formatted message to log. + * @return void */ public function log($level, $string) { 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/Metadata/MetaDataStorageHandler.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php index 6e712ea3a3491a332dec2538b5c84a0f88218ab1..a0ee3db680e55e1ac973f90b49e9d4f9a3b072a5 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandler.php @@ -19,7 +19,7 @@ class MetaDataStorageHandler implements ClearableState * instance of the metadata handler. This variable will be null if * we haven't instantiated a metadata handler yet. * - * @var MetaDataStorageHandler + * @var MetaDataStorageHandler|null */ private static $metadataHandler = null; @@ -241,7 +241,7 @@ class MetaDataStorageHandler implements ClearableState * @param string $set Which set of metadata we are looking it up in. * @param string $ip IP address * - * @return string The entity id of a entity which have a CIDR hint where the provided + * @return string|null The entity id of a entity which have a CIDR hint where the provided * IP address match. */ public function getPreferredEntityIdFromCIDRhint($set, $ip) @@ -261,7 +261,7 @@ class MetaDataStorageHandler implements ClearableState * This function looks up the metadata for the given entity id in the given set. It will throw an * exception if it is unable to locate the metadata. * - * @param string $index The entity id we are looking up. This parameter may be NULL, in which case we look up + * @param string|null $index The entity id we are looking up. This parameter may be NULL, in which case we look up * the current entity id based on the current hostname/path. * @param string $set The set of metadata we are looking up the entity id in. * @@ -366,6 +366,7 @@ class MetaDataStorageHandler implements ClearableState * Clear any metadata cached. * Allows for metadata configuration to be changed and reloaded during a given request. Most useful * when running phpunit tests and needing to alter config.php and metadata sources between test cases + * @return void */ public static function clearInternalState() { diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php index 2d7883b8c96cfaefc228266581498b5115ca23d3..4664edcab3c1297089865ec2d80b8d605a269fba 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerFlatFile.php @@ -66,7 +66,7 @@ class MetaDataStorageHandlerFlatFile extends MetaDataStorageSource * * @param string $set The set of metadata we are loading. * - * @return array An associative array with the metadata, or null if we are unable to load metadata from the given + * @return array|null An associative array with the metadata, or null if we are unable to load metadata from the given * file. * @throws Exception If the metadata set cannot be loaded. */ @@ -109,6 +109,7 @@ class MetaDataStorageHandlerFlatFile extends MetaDataStorageSource if ($metadataSet === null) { $metadataSet = []; } + /** @var array $metadataSet */ // add the entity id of an entry to each entry in the metadata foreach ($metadataSet as $entityId => &$entry) { @@ -120,11 +121,15 @@ class MetaDataStorageHandlerFlatFile extends MetaDataStorageSource } $this->cachedMetadata[$set] = $metadataSet; - return $metadataSet; } + /** + * @param string $set + * @throws \Exception + * @return string + */ private function generateDynamicHostedEntityID($set) { // get the configuration diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php index 0645a0bec5485e5fb918a6cbba22c5f327b7e3e6..f33f8757089d104189474dd55130e674f1457912 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php @@ -72,8 +72,8 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource * * @param string $set The set of metadata we are loading. * - * @return array $metadata Associative array with the metadata, or NULL if we are unable to load metadata from the - * given file. + * @return array|null $metadata Associative array with the metadata, or NULL if we are unable to load + * metadata from the given file. * * @throws Exception If a database error occurs. * @throws \SimpleSAML\Error\Exception If the metadata can be retrieved from the database, but cannot be decoded. @@ -129,6 +129,7 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource if ($metadataSet === null) { $metadataSet = []; } + /** @var array $metadataSet */ foreach ($metadataSet as $entityId => &$entry) { if (preg_match('/__DYNAMIC(:[0-9]+)?__/', $entityId)) { @@ -148,7 +149,7 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource * @param string $entityId The entityId we are looking up. * @param string $set The set we are looking for metadata in. * - * @return array An associative array with metadata for the given entity, or NULL if we are unable to + * @return array|null An associative array with metadata for the given entity, or NULL if we are unable to * locate the entity. */ public function getMetaData($entityId, $set) @@ -189,6 +190,11 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource } } + /** + * @param string $set + * @throws \Exception + * @return string + */ private function generateDynamicHostedEntityID($set) { assert(is_string($set)); diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php index 8c050775678d401067097278739cb1e4915680ec..fa57368561aa78726bfbfe527d227c966d024c76 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php @@ -21,7 +21,7 @@ class MetaDataStorageHandlerSerialize extends MetaDataStorageSource /** * The base directory where metadata is stored. * - * @var string + * @var string|null */ private $directory; @@ -168,7 +168,7 @@ class MetaDataStorageHandlerSerialize extends MetaDataStorageSource * @param string $entityId The entityId we are looking up. * @param string $set The set we are looking for metadata in. * - * @return array An associative array with metadata for the given entity, or NULL if we are unable to + * @return array|null An associative array with metadata for the given entity, or NULL if we are unable to * locate the entity. */ public function getMetaData($entityId, $set) @@ -212,7 +212,7 @@ class MetaDataStorageHandlerSerialize extends MetaDataStorageSource * @param string $set The metadata set this metadata entry belongs to. * @param array $metadata The metadata. * - * @return boolean True if successfully saved, false otherwise. + * @return bool True if successfully saved, false otherwise. */ public function saveMetadata($entityId, $set, $metadata) { @@ -261,6 +261,7 @@ class MetaDataStorageHandlerSerialize extends MetaDataStorageSource * * @param string $entityId The entityId of the metadata entry. * @param string $set The metadata set this metadata entry belongs to. + * @return void */ public function deleteMetadata($entityId, $set) { diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php index 76aeabb635076f76ca54c640aea061331c20d866..ceb10ade551584d873be311773fb0950096b8b07 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php @@ -133,6 +133,7 @@ abstract class MetaDataStorageSource { $metadataSet = $this->getMetadataSet($set); + /** @psalm-suppress DocblockTypeContradiction */ if ($metadataSet === null) { // this metadata source does not have this metadata set return null; @@ -167,7 +168,7 @@ abstract class MetaDataStorageSource * @param string $ip IP address * @param string $type Do you want to return the metaindex or the entityID. [entityid|metaindex] * - * @return string The entity id of a entity which have a CIDR hint where the provided + * @return string|null The entity id of a entity which have a CIDR hint where the provided * IP address match. */ public function getPreferredEntityIdFromCIDRhint($set, $ip, $type = 'entityid') @@ -211,8 +212,10 @@ abstract class MetaDataStorageSource } - /* - * + /** + * @param string $entityId + * @param string $set + * @return mixed|null */ private function lookupIndexFromEntityId($entityId, $set) { @@ -250,7 +253,7 @@ abstract class MetaDataStorageSource * @param string $index The entityId or metaindex we are looking up. * @param string $set The set we are looking for metadata in. * - * @return array An associative array with metadata for the given entity, or NULL if we are unable to + * @return array|null An associative array with metadata for the given entity, or NULL if we are unable to * locate the entity. */ public function getMetaData($index, $set) diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index 929cb5ebf0678bda483963630dde401a4e2f48c2..733d802f731c4020dc0d0b78c51a9f30802e77f1 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -2,6 +2,8 @@ namespace SimpleSAML\Metadata; +use \SAML2\XML\md\EntityDescriptor; + /** * Class for generating SAML 2.0 metadata from SimpleSAMLphp metadata arrays. * @@ -40,9 +42,10 @@ class SAMLBuilder * Initialize the SAML builder. * * @param string $entityId The entity id of the entity. - * @param double|null $maxCache The maximum time in seconds the metadata should be cached. Defaults to null - * @param double|null $maxDuration The maximum time in seconds this metadata should be considered valid. Defaults + * @param int|null $maxCache The maximum time in seconds the metadata should be cached. Defaults to null + * @param int|null $maxDuration The maximum time in seconds this metadata should be considered valid. Defaults * to null. + * @return void */ public function __construct($entityId, $maxCache = null, $maxDuration = null) { @@ -51,11 +54,15 @@ class SAMLBuilder $this->maxCache = $maxCache; $this->maxDuration = $maxDuration; - $this->entityDescriptor = new \SAML2\XML\md\EntityDescriptor(); + $this->entityDescriptor = new EntityDescriptor(); $this->entityDescriptor->setEntityID($entityId); } + /** + * @param array $metadata + * @return void + */ private function setExpiration($metadata) { if (array_key_exists('expire', $metadata)) { @@ -113,6 +120,7 @@ class SAMLBuilder * Add a SecurityTokenServiceType for ADFS metadata. * * @param array $metadata The metadata with the information about the SecurityTokenServiceType. + * @return void */ public function addSecurityTokenServiceType($metadata) { @@ -136,6 +144,7 @@ class SAMLBuilder * * @param \SimpleSAML\Configuration $metadata The metadata to get extensions from. * @param \SAML2\XML\md\RoleDescriptor $e Reference to the element where the Extensions element should be included. + * @return void */ private function addExtensions(\SimpleSAML\Configuration $metadata, \SAML2\XML\md\RoleDescriptor $e) { @@ -283,6 +292,7 @@ class SAMLBuilder * @param array $orgName An array with the localized OrganizationName. * @param array $orgDisplayName An array with the localized OrganizationDisplayName. * @param array $orgURL An array with the localized OrganizationURL. + * @return void */ public function addOrganization(array $orgName, array $orgDisplayName, array $orgURL) { @@ -300,6 +310,7 @@ class SAMLBuilder * Add an Organization element based on metadata array. * * @param array $metadata The metadata we should extract the organization information from. + * @return void */ public function addOrganizationInfo(array $metadata) { @@ -337,24 +348,6 @@ class SAMLBuilder foreach ($endpoints as &$ep) { if ($indexed) { $t = new \SAML2\XML\md\IndexedEndpointType(); - } else { - $t = new \SAML2\XML\md\EndpointType(); - } - - $t->setBinding($ep['Binding']); - $t->setLocation($ep['Location']); - if (isset($ep['ResponseLocation'])) { - $t->setResponseLocation($ep['ResponseLocation']); - } - if (isset($ep['hoksso:ProtocolBinding'])) { - $t->setAttributeNS( - \SAML2\Constants::NS_HOK, - 'hoksso:ProtocolBinding', - \SAML2\Constants::BINDING_HTTP_REDIRECT - ); - } - - if ($indexed) { if (!isset($ep['index'])) { // Find the maximum index $maxIndex = -1; @@ -372,6 +365,21 @@ class SAMLBuilder } $t->setIndex($ep['index']); + } else { + $t = new \SAML2\XML\md\EndpointType(); + } + + $t->setBinding($ep['Binding']); + $t->setLocation($ep['Location']); + if (isset($ep['ResponseLocation'])) { + $t->setResponseLocation($ep['ResponseLocation']); + } + if (isset($ep['hoksso:ProtocolBinding'])) { + $t->setAttributeNS( + \SAML2\Constants::NS_HOK, + 'hoksso:ProtocolBinding', + \SAML2\Constants::BINDING_HTTP_REDIRECT + ); } $ret[] = $t; @@ -386,6 +394,7 @@ class SAMLBuilder * * @param \SAML2\XML\md\SPSSODescriptor $spDesc The SPSSODescriptor element. * @param \SimpleSAML\Configuration $metadata The metadata. + * @return void */ private function addAttributeConsumingService( \SAML2\XML\md\SPSSODescriptor $spDesc, @@ -441,6 +450,7 @@ class SAMLBuilder * * @param string $set The metadata set this metadata comes from. * @param array $metadata The metadata. + * @return void */ public function addMetadata($set, $metadata) { @@ -476,6 +486,7 @@ class SAMLBuilder * * @param array $metadata The metadata. * @param array $protocols The protocols supported. Defaults to \SAML2\Constants::NS_SAMLP. + * @return void */ public function addMetadataSP20($metadata, $protocols = [\SAML2\Constants::NS_SAMLP]) { @@ -532,6 +543,7 @@ class SAMLBuilder * Add metadata of a SAML 2.0 identity provider. * * @param array $metadata The metadata. + * @return void */ public function addMetadataIdP20($metadata) { @@ -581,6 +593,7 @@ class SAMLBuilder * Add metadata of a SAML 1.1 service provider. * * @param array $metadata The metadata. + * @return void */ public function addMetadataSP11($metadata) { @@ -619,6 +632,7 @@ class SAMLBuilder * Add metadata of a SAML 1.1 identity provider. * * @param array $metadata The metadata. + * @return void */ public function addMetadataIdP11($metadata) { @@ -651,6 +665,7 @@ class SAMLBuilder * * @param array $metadata The AttributeAuthorityDescriptor, in the format returned by * \SimpleSAML\Metadata\SAMLParser. + * @return void */ public function addAttributeAuthority(array $metadata) { @@ -688,6 +703,7 @@ class SAMLBuilder * @param string $type The type of contact. Deprecated. * @param array $details The details about the contact. * + * @return void * @todo Change the signature to remove $type. * @todo Remove the capability to pass a name and parse it inside the method. */ @@ -747,6 +763,7 @@ class SAMLBuilder * @param \SAML2\XML\md\RoleDescriptor $rd The RoleDescriptor the certificate should be added to. * @param string $use The value of the 'use' attribute. * @param string $x509data The certificate data. + * @return void */ private function addX509KeyDescriptor(\SAML2\XML\md\RoleDescriptor $rd, $use, $x509data) { @@ -766,6 +783,7 @@ class SAMLBuilder * * @param \SAML2\XML\md\RoleDescriptor $rd The RoleDescriptor the certificate should be added to. * @param \SimpleSAML\Configuration $metadata The metadata of the entity. + * @return void */ private function addCertificate(\SAML2\XML\md\RoleDescriptor $rd, \SimpleSAML\Configuration $metadata) { diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index 1a86ae37bf9fc8df362e15b01738471ba5f6c5a8..f85c7b894f2429f6d43e41c7251ff6736834cca0 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -212,6 +212,7 @@ class SAMLParser */ public static function parseFile($file) { + /** @var string $data */ $data = \SimpleSAML\Utils\HTTP::fetch($file); try { @@ -282,7 +283,7 @@ class SAMLParser * the file contains a single EntityDescriptorElement, then the array will contain a single SAMLParser * instance. * - * @param string $file The path to the file which contains the EntityDescriptor or EntitiesDescriptor element. + * @param string|null $file The path to the file which contains the EntityDescriptor or EntitiesDescriptor element. * * @return SAMLParser[] An array of SAMLParser instances. * @throws \Exception If the file does not parse as XML. @@ -293,6 +294,7 @@ class SAMLParser throw new \Exception('Cannot open file NULL. File name not specified.'); } + /** @var string $data */ $data = \SimpleSAML\Utils\HTTP::fetch($file); try { @@ -409,9 +411,9 @@ class SAMLParser * how long a given XML-element is valid. It returns this as a unix timestamp. * * @param mixed $element The element we should determine the expiry time of. - * @param int|NULL $maxExpireTime The maximum expiration time. + * @param int|null $maxExpireTime The maximum expiration time. * - * @return int The unix timestamp for when the element should expire. Will be NULL if no + * @return int|null The unix timestamp for when the element should expire. Will be NULL if no * limit is set for the element. */ private static function getExpireTime($element, $maxExpireTime) @@ -438,6 +440,9 @@ class SAMLParser } + /** + * @return array + */ private function getMetadataCommon() { $ret = []; @@ -470,6 +475,7 @@ class SAMLParser * * @param array &$metadata The metadata that should be updated. * @param array $roleDescriptor The parsed role descriptor. + * @return void */ private function addExtensions(array &$metadata, array $roleDescriptor) { @@ -520,7 +526,8 @@ class SAMLParser * * Metadata must be loaded with one of the parse functions before this function can be called. * - * @return array An associative array with metadata or NULL if we are unable to generate metadata for a SAML 1.x SP. + * @return array|null An associative array with metadata or NULL if we are unable to + * generate metadata for a SAML 1.x SP. */ public function getMetadata1xSP() { @@ -593,8 +600,8 @@ class SAMLParser * * Metadata must be loaded with one of the parse functions before this function can be called. * - * @return array An associative array with metadata or NULL if we are unable to generate metadata for a SAML 1.x - * IdP. + * @return array|null An associative array with metadata or NULL if we are unable to + * generate metadata for a SAML 1.x IdP. */ public function getMetadata1xIdP() { @@ -650,7 +657,8 @@ class SAMLParser * * Metadata must be loaded with one of the parse functions before this function can be called. * - * @return array An associative array with metadata or NULL if we are unable to generate metadata for a SAML 2.x SP. + * @return array|null An associative array with metadata or NULL if we are unable to + * generate metadata for a SAML 2.x SP. */ public function getMetadata20SP() { @@ -752,8 +760,8 @@ class SAMLParser * * Metadata must be loaded with one of the parse functions before this function can be called. * - * @return array An associative array with metadata or NULL if we are unable to generate metadata for a SAML 2.0 - * IdP. + * @return array|null An associative array with metadata or NULL if we are unable to + * generate metadata for a SAML 2.0 IdP. */ public function getMetadata20IdP() { @@ -828,7 +836,7 @@ class SAMLParser * - 'keys': Array of associative arrays with the elements from parseKeyDescriptor. * * @param \SAML2\XML\md\RoleDescriptor $element The element we should extract metadata from. - * @param int|NULL $expireTime The unix timestamp for when this element should expire, or + * @param int|null $expireTime The unix timestamp for when this element should expire, or * NULL if unknown. * * @return array An associative array with metadata we have extracted from this element. @@ -910,6 +918,7 @@ class SAMLParser * @param \SAML2\XML\md\SPSSODescriptor $element The element which should be parsed. * @param int|NULL $expireTime The unix timestamp for when this element should expire, or * NULL if unknown. + * @return void */ private function processSPSSODescriptor(\SAML2\XML\md\SPSSODescriptor $element, $expireTime) { @@ -946,6 +955,7 @@ class SAMLParser * @param \SAML2\XML\md\IDPSSODescriptor $element The element which should be parsed. * @param int|NULL $expireTime The unix timestamp for when this element should expire, or * NULL if unknown. + * @return void */ private function processIDPSSODescriptor(\SAML2\XML\md\IDPSSODescriptor $element, $expireTime) { @@ -972,6 +982,7 @@ class SAMLParser * @param \SAML2\XML\md\AttributeAuthorityDescriptor $element The element which should be parsed. * @param int|NULL $expireTime The unix timestamp for when this element should * expire, or NULL if unknown. + * @return void */ private function processAttributeAuthorityDescriptor( \SAML2\XML\md\AttributeAuthorityDescriptor $element, @@ -1145,6 +1156,7 @@ class SAMLParser * Parse and process a Organization element. * * @param \SAML2\XML\md\Organization $element The Organization element. + * @return void */ private function processOrganization(\SAML2\XML\md\Organization $element) { @@ -1158,8 +1170,8 @@ class SAMLParser * Parse and process a ContactPerson element. * * @param \SAML2\XML\md\ContactPerson $element The ContactPerson element. + * @return void */ - private function processContactPerson(\SAML2\XML\md\ContactPerson $element) { $contactPerson = []; @@ -1192,6 +1204,7 @@ class SAMLParser * * @param \SAML2\XML\md\AttributeConsumingService $element The AttributeConsumingService to parse. * @param array $sp The array with the SP's metadata. + * @return void */ private static function parseAttributeConsumerService(\SAML2\XML\md\AttributeConsumingService $element, &$sp) { @@ -1338,7 +1351,7 @@ class SAMLParser /** * This function finds SP descriptors which supports one of the given protocols. * - * @param $protocols Array with the protocols we accept. + * @param array $protocols Array with the protocols we accept. * * @return array with SP descriptors which supports one of the given protocols. */ @@ -1362,7 +1375,7 @@ class SAMLParser /** * This function finds IdP descriptors which supports one of the given protocols. * - * @param $protocols Array with the protocols we accept. + * @param array $protocols Array with the protocols we accept. * * @return array with IdP descriptors which supports one of the given protocols. */ diff --git a/lib/SimpleSAML/Metadata/Sources/MDQ.php b/lib/SimpleSAML/Metadata/Sources/MDQ.php index 7c73449fee90e037aa115b44a30ab2a99e971cd1..1f141657be9631a62597c2916c7fad85a23341df 100644 --- a/lib/SimpleSAML/Metadata/Sources/MDQ.php +++ b/lib/SimpleSAML/Metadata/Sources/MDQ.php @@ -199,6 +199,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource * @param array $data The associative array with the metadata for this entity. * * @throws \Exception If metadata cannot be written to cache. + * @return void */ private function writeToCache($set, $entityId, $data) { @@ -266,7 +267,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource * @param string $index The entityId or metaindex we are looking up. * @param string $set The set we are looking for metadata in. * - * @return array An associative array with metadata for the given entity, or NULL if we are unable to + * @return array|null An associative array with metadata for the given entity, or NULL if we are unable to * locate the entity. * @throws \Exception If an error occurs while validating the signature or the metadata is in an * incorrect set. 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/Module/ControllerResolver.php b/lib/SimpleSAML/Module/ControllerResolver.php index 25bfa08fd194178913b6962482970dbfda1753e3..85d39744362857f9a8ce3faff8d8b368736453b6 100644 --- a/lib/SimpleSAML/Module/ControllerResolver.php +++ b/lib/SimpleSAML/Module/ControllerResolver.php @@ -44,9 +44,9 @@ class ControllerResolver extends SymfonyControllerResolver implements ArgumentRe protected $module; /** @var array */ - protected $params; + protected $params = []; - /** @var RouteCollection */ + /** @var RouteCollection|null */ protected $routes; @@ -172,6 +172,7 @@ class ControllerResolver extends SymfonyControllerResolver implements ArgumentRe * Set the configuration to use by the controllers. * * @param \SimpleSAML\Configuration $config + * @return void */ public function setConfiguration(Configuration $config) { @@ -184,6 +185,7 @@ class ControllerResolver extends SymfonyControllerResolver implements ArgumentRe * Set the session to use by the controllers. * * @param \SimpleSAML\Session $session + * @return void */ public function setSession(Session $session) { diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index cd158b3fe6b35cd0dd8d58b11c3b440a61d55863..062382c9cdfee0c887f12cb2845707bdd693b33b 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() { @@ -557,6 +569,7 @@ class Session implements \Serializable, Utils\ClearableState * Set remember me expire time. * * @param int $expire Unix timestamp when remember me session cookies expire. + * @return void */ public function setRememberMeExpire($expire = null) { @@ -578,6 +591,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 +684,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 +710,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 +776,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 +804,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 +826,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 +854,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 +881,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 +935,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 +1022,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 +1055,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 +1118,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 +1177,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..70fca6c395745af92203389d07a065e0de30f3b6 100644 --- a/lib/SimpleSAML/Store.php +++ b/lib/SimpleSAML/Store.php @@ -24,7 +24,7 @@ abstract class Store implements Utils\ClearableState /** * Retrieve our singleton instance. * - * @return false|\SimpleSAML\Store The data store, or false if it isn't enabled. + * @return bool|\SimpleSAML\Store The data store, or false if it isn't enabled. * * @throws \SimpleSAML\Error\CriticalConfigurationError */ @@ -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/Store/Memcache.php b/lib/SimpleSAML/Store/Memcache.php index 209ae762f3672a58913838350a14656990d237f0..01739072e49a8785f6fde2e833ec6f1dfafb07d8 100644 --- a/lib/SimpleSAML/Store/Memcache.php +++ b/lib/SimpleSAML/Store/Memcache.php @@ -52,7 +52,8 @@ class Memcache extends Store * @param string $type The data type. * @param string $key The key. * @param mixed $value The value. - * @param int|NULL $expire The expiration time (unix timestamp), or NULL if it never expires. + * @param int|null $expire The expiration time (unix timestamp), or NULL if it never expires. + * @return void */ public function set($type, $key, $value, $expire = null) { @@ -73,6 +74,7 @@ class Memcache extends Store * * @param string $type The data type. * @param string $key The key. + * @return void */ public function delete($type, $key) { diff --git a/lib/SimpleSAML/Store/Redis.php b/lib/SimpleSAML/Store/Redis.php index 310caa98f42cb480cc1e8d17102a20d7f7c0cc82..53c27f4549c333c95953f61b7f2e168e37c7c20e 100644 --- a/lib/SimpleSAML/Store/Redis.php +++ b/lib/SimpleSAML/Store/Redis.php @@ -12,10 +12,12 @@ use \SimpleSAML\Store; */ class Redis extends Store { + /** @var \Predis\Client */ public $redis; /** * Initialize the Redis data store. + * @param \Predis\Client|null $redis */ public function __construct($redis = null) { @@ -87,6 +89,7 @@ class Redis extends Store * @param string $key The key to insert. * @param mixed $value The value itself. * @param int|null $expire The expiration time (unix timestamp), or null if it never expires. + * @return void */ public function set($type, $key, $value, $expire = null) { @@ -109,6 +112,7 @@ class Redis extends Store * * @param string $type The type of the data * @param string $key The key to delete. + * @return void */ public function delete($type, $key) { diff --git a/lib/SimpleSAML/Store/SQL.php b/lib/SimpleSAML/Store/SQL.php index 72bb84248cefd72baf526943579cbafedca2e982..175d15c67f2aae9b5756fdda44df0f9c20b5a825 100644 --- a/lib/SimpleSAML/Store/SQL.php +++ b/lib/SimpleSAML/Store/SQL.php @@ -77,6 +77,7 @@ class SQL extends Store /** * Initialize the table-version table. + * @return void */ private function initTableVersionTable() { @@ -100,6 +101,7 @@ class SQL extends Store /** * Initialize key-value table. + * @return void */ private function initKVTable() { @@ -185,6 +187,7 @@ class SQL extends Store * * @param string $name Table name. * @param int $version Table version. + * @return void */ public function setTableVersion($name, $version) { @@ -208,6 +211,7 @@ class SQL extends Store * @param string $table The table we should update. * @param array $keys The key columns. * @param array $data Associative array with columns. + * @return void */ public function insertOrUpdate($table, array $keys, array $data) { @@ -266,6 +270,7 @@ class SQL extends Store /** * Clean the key-value table of expired entries. + * @return void */ private function cleanKVStore() { @@ -329,6 +334,7 @@ class SQL extends Store * @param string $key The key to insert. * @param mixed $value The value itself. * @param int|null $expire The expiration time (unix timestamp), or null if it never expires. + * @return void */ public function set($type, $key, $value, $expire = null) { @@ -367,6 +373,7 @@ class SQL extends Store * * @param string $type The type of the data * @param string $key The key to delete. + * @return void */ public function delete($type, $key) { diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index c6e04223e9baf472b6a5909d01bce4043ca676ce..33392a458a08e53577860092c8c1d3e53ebb23aa 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 string */ 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 string|null $start + * @param string|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 \DOMElement $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 array */ 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 string|false */ 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 void */ 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 $url + * @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 array */ 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 string $xml + * @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 string $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 int $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,11 @@ class Utilities /** * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::setCookie() instead. + * @param string $name + * @param string|null $value + * @param array|null $params + * @param bool $throw + * @return void */ public static function setCookie($name, $value, array $params = null, $throw = true) { diff --git a/lib/SimpleSAML/Utils/Arrays.php b/lib/SimpleSAML/Utils/Arrays.php index c27b198eb0284d72b69d013325ad924bdfa05498..b38d0ca5c7726c7b561e632f720f6453b9cb051f 100644 --- a/lib/SimpleSAML/Utils/Arrays.php +++ b/lib/SimpleSAML/Utils/Arrays.php @@ -1,4 +1,5 @@ <?php + namespace SimpleSAML\Utils; /** @@ -8,7 +9,6 @@ namespace SimpleSAML\Utils; */ class Arrays { - /** * Put a non-array variable into an array. * diff --git a/lib/SimpleSAML/Utils/Auth.php b/lib/SimpleSAML/Utils/Auth.php index 7cff78b27c038d68e6aa07774197015dcf74bf82..61d49b6e919409d83229ea958c91e1fc3ef0f51b 100644 --- a/lib/SimpleSAML/Utils/Auth.php +++ b/lib/SimpleSAML/Utils/Auth.php @@ -1,4 +1,5 @@ <?php + namespace SimpleSAML\Utils; use SimpleSAML\Module; diff --git a/lib/SimpleSAML/Utils/Config.php b/lib/SimpleSAML/Utils/Config.php index 5f25f8a0de38e14c216c0adda424cc8d3660f36b..663073e00f48582bdeb74cc5ab814cfaf0f8a3e0 100644 --- a/lib/SimpleSAML/Utils/Config.php +++ b/lib/SimpleSAML/Utils/Config.php @@ -1,4 +1,5 @@ <?php + namespace SimpleSAML\Utils; /** diff --git a/lib/SimpleSAML/Utils/Config/Metadata.php b/lib/SimpleSAML/Utils/Config/Metadata.php index 7c66f290cd1aec631b3e06ac496a2cd251a2ccb6..f20a06c2f35a1f43e41aa9e00048077fdcab65d5 100644 --- a/lib/SimpleSAML/Utils/Config/Metadata.php +++ b/lib/SimpleSAML/Utils/Config/Metadata.php @@ -1,4 +1,5 @@ <?php + namespace SimpleSAML\Utils\Config; /** @@ -106,6 +107,10 @@ class Metadata // check the type if (!isset($contact['contactType']) || !in_array($contact['contactType'], self::$VALID_CONTACT_TYPES, true)) { $types = join(', ', array_map( + /** + * @param string $t + * @return string + */ function ($t) { return '"'.$t.'"'; }, diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php index da6ec639da285f10a7410622069284e41361c61f..4600821ba70d0b49e44a384a85a7b7a8f65c2178 100644 --- a/lib/SimpleSAML/Utils/HTTP.php +++ b/lib/SimpleSAML/Utils/HTTP.php @@ -1,4 +1,5 @@ <?php + namespace SimpleSAML\Utils; use SimpleSAML\Configuration; @@ -462,8 +463,10 @@ class HTTP // data and headers if ($getHeaders) { + /** @psalm-suppress UndefinedVariable */ if (isset($http_response_header)) { $headers = []; + /** @psalm-suppress UndefinedVariable */ foreach ($http_response_header as $h) { if (preg_match('@^HTTP/1\.[01]\s+\d{3}\s+@', $h)) { $headers = []; // reset diff --git a/lib/SimpleSAML/Utils/HttpAdapter.php b/lib/SimpleSAML/Utils/HttpAdapter.php index b82392076342830ed41121630c09ef287210a96e..b2e90b475a153a297c4cbba2627bae002fcd7fd8 100644 --- a/lib/SimpleSAML/Utils/HttpAdapter.php +++ b/lib/SimpleSAML/Utils/HttpAdapter.php @@ -11,6 +11,7 @@ class HttpAdapter { /** * @see HTTP::getServerHTTPS() + * @return bool */ public function getServerHTTPS() { @@ -19,6 +20,7 @@ class HttpAdapter /** * @see HTTP::getServerPort() + * @return string */ public function getServerPort() { @@ -27,6 +29,10 @@ class HttpAdapter /** * @see HTTP::addURLParameters() + * + * @param string $url + * @param array $parameters + * @return string */ public function addURLParameters($url, $parameters) { @@ -35,6 +41,9 @@ class HttpAdapter /** * @see HTTP::checkSessionCookie() + * + * @param string|null $retryURL + * @return void */ public function checkSessionCookie($retryURL = null) { @@ -43,6 +52,10 @@ class HttpAdapter /** * @see HTTP::checkURLAllowed() + * + * @param string $url + * @param array|null $trustedSites + * @return string */ public function checkURLAllowed($url, array $trustedSites = null) { @@ -51,6 +64,11 @@ class HttpAdapter /** * @see HTTP::fetch() + * + * @param string $url + * @param array $context + * @param bool $getHeaders + * @return array|string */ public function fetch($url, $context = [], $getHeaders = false) { @@ -59,6 +77,7 @@ class HttpAdapter /** * @see HTTP::getAcceptLanguage() + * @return array */ public function getAcceptLanguage() { @@ -67,6 +86,7 @@ class HttpAdapter /** * @see HTTP::guessBasePath() + * @return string */ public function guessBasePath() { @@ -75,6 +95,7 @@ class HttpAdapter /** * @see HTTP::getBaseURL() + * @return string */ public function getBaseURL() { @@ -83,6 +104,9 @@ class HttpAdapter /** * @see HTTP::getFirstPathElement() + * + * @param bool $trailingslash + * @return string */ public function getFirstPathElement($trailingslash = true) { @@ -91,6 +115,10 @@ class HttpAdapter /** * @see HTTP::getPOSTRedirectURL() + * + * @param string $destination + * @param array $data + * @return string */ public function getPOSTRedirectURL($destination, $data) { @@ -99,6 +127,7 @@ class HttpAdapter /** * @see HTTP::getSelfHost() + * @return string */ public function getSelfHost() { @@ -107,6 +136,7 @@ class HttpAdapter /** * @see HTTP::getSelfHostWithNonStandardPort() + * @return string */ public function getSelfHostWithNonStandardPort() { @@ -115,6 +145,7 @@ class HttpAdapter /** * @see HTTP::getSelfHostWithPath() + * @return string */ public function getSelfHostWithPath() { @@ -123,6 +154,7 @@ class HttpAdapter /** * @see HTTP::getSelfURL() + * @return string */ public function getSelfURL() { @@ -131,6 +163,7 @@ class HttpAdapter /** * @see HTTP::getSelfURLHost() + * @return string */ public function getSelfURLHost() { @@ -139,6 +172,7 @@ class HttpAdapter /** * @see HTTP::getSelfURLNoQuery() + * @return string */ public function getSelfURLNoQuery() { @@ -147,6 +181,7 @@ class HttpAdapter /** * @see HTTP::isHTTPS() + * @return bool */ public function isHTTPS() { @@ -155,6 +190,8 @@ class HttpAdapter /** * @see HTTP::normalizeURL() + * @param string $url + * @return string */ public function normalizeURL($url) { @@ -163,6 +200,9 @@ class HttpAdapter /** * @see HTTP::parseQueryString() + * + * @param string $query_string + * @return array */ public function parseQueryString($query_string) { @@ -171,6 +211,10 @@ class HttpAdapter /** * @see HTTP::redirectTrustedURL() + * + * @param string $url + * @param array $parameters + * @return void */ public function redirectTrustedURL($url, $parameters = []) { @@ -179,6 +223,10 @@ class HttpAdapter /** * @see HTTP::redirectUntrustedURL() + * + * @param string $url + * @param array $parameters + * @return void */ public function redirectUntrustedURL($url, $parameters = []) { @@ -187,6 +235,10 @@ class HttpAdapter /** * @see HTTP::resolveURL() + * + * @param string $url + * @param string|null $base + * @return string */ public function resolveURL($url, $base = null) { @@ -195,6 +247,12 @@ class HttpAdapter /** * @see HTTP::setCookie() + * + * @param string $name + * @param string $value + * @param array|null $params + * @param bool $throw + * @return void */ public function setCookie($name, $value, $params = null, $throw = true) { @@ -203,6 +261,10 @@ class HttpAdapter /** * @see HTTP::submitPOSTData() + * + * @param string $destination + * @param array $data + * @return void */ public function submitPOSTData($destination, $data) { diff --git a/lib/SimpleSAML/Utils/Net.php b/lib/SimpleSAML/Utils/Net.php index 02619d2215f88f34ca19579bc744dd7bc982912f..351a7cf6e03f5b8bd5b6daa9736addd5046b19c7 100644 --- a/lib/SimpleSAML/Utils/Net.php +++ b/lib/SimpleSAML/Utils/Net.php @@ -1,4 +1,5 @@ <?php + namespace SimpleSAML\Utils; /** @@ -8,7 +9,6 @@ namespace SimpleSAML\Utils; */ class Net { - /** * Check whether an IP address is part of a CIDR. * diff --git a/lib/SimpleSAML/Utils/Random.php b/lib/SimpleSAML/Utils/Random.php index f3db05154b9a83aa01e83136b4a7650a075d047e..6ed304e45c6d4c99d03625b7853f2f95a8471947 100644 --- a/lib/SimpleSAML/Utils/Random.php +++ b/lib/SimpleSAML/Utils/Random.php @@ -1,4 +1,5 @@ <?php + namespace SimpleSAML\Utils; /** @@ -8,7 +9,6 @@ namespace SimpleSAML\Utils; */ class Random { - /** * The fixed length of random identifiers. */ diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php index 9b1f37766c0f24c75f8e654164f45b5bf151dfc7..da5e66e3c798778a78e4511a89388ccc46835f8d 100644 --- a/lib/SimpleSAML/Utils/XML.php +++ b/lib/SimpleSAML/Utils/XML.php @@ -1,4 +1,5 @@ <?php + /** * Utility class for XML and DOM manipulation. * @@ -12,7 +13,6 @@ use SimpleSAML\XML\Errors; class XML { - /** * This function performs some sanity checks on XML documents, and optionally validates them against their schema * if the 'validatexml' debugging option is enabled. A warning will be printed to the log if validation fails. @@ -69,7 +69,7 @@ class XML case 'saml-meta': $result = self::isValid($message, 'saml-schema-metadata-2.0.xsd'); } - if ($result !== true) { + if (is_string($result)) { Logger::warning($result); } } @@ -166,7 +166,7 @@ class XML $textNodes = []; // text nodes which should be deleted $childNodes = []; // other child nodes for ($i = 0; $i < $root->childNodes->length; $i++) { - /** @var \DOMElement $child */ + /** @var \DOMNode $child */ $child = $root->childNodes->item($i); if ($child instanceof \DOMText) { @@ -288,7 +288,7 @@ class XML $ret = []; for ($i = 0; $i < $element->childNodes->length; $i++) { - /** @var \DOMElement $child */ + /** @var \DOMNode $child */ $child = $element->childNodes->item($i); // skip text nodes and comment elements @@ -405,7 +405,7 @@ class XML * @param string|\DOMDocument $xml The XML string or document which should be validated. * @param string $schema The filename of the schema that should be used to validate the document. * - * @return boolean|string Returns a string with errors found if validation fails. True if validation passes ok. + * @return bool|string Returns a string with errors found if validation fails. True if validation passes ok. * @throws \InvalidArgumentException If $schema is not a string, or $xml is neither a string nor a \DOMDocument. * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> diff --git a/lib/SimpleSAML/XHTML/EMail.php b/lib/SimpleSAML/XHTML/EMail.php index a9e239029b44de780c892dbb55e7ef35bda688e2..ac52e411147e948f09f421c67923e1ab1482b49a 100644 --- a/lib/SimpleSAML/XHTML/EMail.php +++ b/lib/SimpleSAML/XHTML/EMail.php @@ -5,23 +5,42 @@ namespace SimpleSAML\XHTML; /** * A minimalistic Emailer class. Creates and sends HTML emails. * - * @author Andreas kre Solberg, UNINETT AS. <andreas.solberg@uninett.no> + * @author Andreas Åkre Solberg, UNINETT AS. <andreas.solberg@uninett.no> * @package SimpleSAMLphp */ class EMail { + /** @var string|null */ private $to = null; + + /** @var string|null */ private $cc = null; + + /** @var string|null */ private $body = null; + + /** @var string|null */ private $from = null; + + /** @var string|null */ private $replyto = null; + + /** @var string|null */ private $subject = null; + + /** @var array */ private $headers = []; /** * Constructor + * + * @param string $to + * @param string $subject + * @param string|null $from + * @param string|null $cc + * @param string|null $replyto */ public function __construct($to, $subject, $from = null, $cc = null, $replyto = null) { @@ -32,7 +51,7 @@ class EMail $this->subject = $subject; } - /* + /** * @param string $body * @return void */ @@ -42,40 +61,20 @@ class EMail } - /* + /** * @param string $body * @return string */ private function getHTML($body) { - return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> -<head> - <meta http-equiv="content-type" content="text/html; charset=utf-8" /> - <title>SimpleSAMLphp Email report</title> - <style type="text/css"> -pre, div.box { - margin: .4em 2em .4em 1em; - padding: 4px; - -} -pre { - background: #eee; - border: 1px solid #aaa; -} - </style> -</head> -<body> -<div class="container" style="background: #fafafa; border: 1px solid #eee; margin: 2em; padding: .6em;"> -'.$body.' -</div> -</body> -</html>'; + $config = \SimpleSAML\Configuration::getInstance(); + $t = new \SimpleSAML\XHTML\Template($config, 'errorreport_mail.twig'); + $twig = $t->getTwig(); + return $twig->render('errorreport_mail.twig', ['body' => $body]); } - /* + /** * @return void */ public function send() diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php index 8f835f366175bd76753ff00805029bc4ed4fab8b..0fb503807b7271a313d5fcdd26043d035d7d8474 100644 --- a/lib/SimpleSAML/XHTML/IdPDisco.php +++ b/lib/SimpleSAML/XHTML/IdPDisco.php @@ -173,6 +173,7 @@ class IdPDisco * discovery service type. * * @param string $message The message which should be logged. + * @return void */ protected function log($message) { @@ -188,7 +189,7 @@ class IdPDisco * * @param string $name The name of the cookie. * - * @return string The value of the cookie with the given name, or null if no cookie with that name exists. + * @return string|null The value of the cookie with the given name, or null if no cookie with that name exists. */ protected function getCookie($name) { @@ -209,6 +210,7 @@ class IdPDisco * * @param string $name The name of the cookie. * @param string $value The value of the cookie. + * @return void */ protected function setCookie($name, $value) { @@ -303,7 +305,7 @@ class IdPDisco /** * Retrieve the users saved choice of IdP. * - * @return string The entity id of the IdP the user has saved, or null if the user hasn't saved any choice. + * @return string|null The entity id of the IdP the user has saved, or null if the user hasn't saved any choice. */ protected function getSavedIdP() { @@ -329,7 +331,7 @@ class IdPDisco /** * Retrieve the previous IdP the user used. * - * @return string The entity id of the previous IdP the user used, or null if this is the first time. + * @return string|null The entity id of the previous IdP the user used, or null if this is the first time. */ protected function getPreviousIdP() { @@ -361,7 +363,7 @@ class IdPDisco * This function will first look at the previous IdP the user has chosen. If the user * hasn't chosen an IdP before, it will look at the IP address. * - * @return string The entity id of the IdP the user should most likely use. + * @return string|null The entity id of the IdP the user should most likely use. */ protected function getRecommendedIdP() { @@ -386,6 +388,7 @@ class IdPDisco * Save the current IdP choice to a cookie. * * @param string $idp The entityID of the IdP. + * @return void */ protected function setPreviousIdP($idp) { @@ -419,7 +422,7 @@ class IdPDisco /** * Determine which IdP the user should go to, if any. * - * @return string The entity id of the IdP the user should be sent to, or null if the user should choose. + * @return string|null The entity id of the IdP the user should be sent to, or null if the user should choose. */ protected function getTargetIdP() { @@ -543,6 +546,7 @@ class IdPDisco * Handles a request to this discovery service. * * The IdP disco parameters should be set before calling this function. + * @return void */ public function handleRequest() { @@ -619,7 +623,12 @@ class IdPDisco } usort( $newlist, - function ($idpentry1, $idpentry2) { + /** + * @param array $idpentry1 + * @param array $idpentry2 + * @return int + */ + function (array $idpentry1, array $idpentry2) { return strcasecmp($idpentry1['name'], $idpentry2['name']); } ); @@ -634,6 +643,12 @@ class IdPDisco $t->show(); } + + /** + * @param array $idpData + * @param string $language + * @return string|null + */ private function getEntityDisplayName(array $idpData, $language) { if (isset($idpData['UIInfo']['DisplayName'][$language])) { diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 097015dd9090fcb8583d658ad8d4cc9a92288a85..edb4b200c9b7d12614f3d387cd9f92442bf18dc9 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -75,7 +75,7 @@ class Template extends Response * * @var bool */ - private $useNewUI; + private $useNewUI = false; /** @@ -85,9 +85,9 @@ class Template extends Response * the 'theme.controller' configuration option to a class that implements the * \SimpleSAML\XHTML\TemplateControllerInterface interface to use it. * - * @var \SimpleSAML\XHTML\TemplateControllerInterface + * @var \SimpleSAML\XHTML\TemplateControllerInterface|null */ - private $controller; + private $controller = null; /** @@ -97,9 +97,9 @@ class Template extends Response * of the module and the name of the theme, respectively. If we are using the default theme, the variable has * the 'default' string in the "name" key, and 'null' in the "module" key. * - * @var array + * @var array|null */ - private $theme; + private $theme = null; /** * Constructor @@ -200,7 +200,7 @@ class Template extends Response $templateName = substr($templateName, 0, $tplpos); } - if ($this->useNewUI || $this->theme['module'] !== null) { + if ($this->useNewUI || ($this->theme['module'] !== null)) { return $templateName.'.twig'; } return $templateName; @@ -250,6 +250,7 @@ class Template extends Response /** * Setup twig. + * @return \Twig_Environment|false */ private function setupTwig() { @@ -311,7 +312,7 @@ class Template extends Response // add an asset() function $twig->addFunction(new \Twig_SimpleFunction('asset', [$this, 'asset'])); - if ($this->controller) { + if ($this->controller !== null) { $this->controller->setUpTwig($twig); } @@ -358,6 +359,7 @@ class Template extends Response /** * Get the template directory of a module, if it exists. * + * @param string $module * @return string The templates directory of a module * * @throws \InvalidArgumentException If the module is not enabled or it has no templates directory. @@ -383,8 +385,8 @@ class Template extends Response * Note that the module must be installed, enabled, and contain a "templates" directory. * * @param string $module The module where we need to search for templates. - * * @throws \InvalidArgumentException If the module is not enabled or it has no templates directory. + * @return void */ public function addTemplatesFromModule($module) { @@ -399,7 +401,7 @@ class Template extends Response * Generate an array for its use in the language bar, indexed by the ISO 639-2 codes of the languages available, * containing their localized names and the URL that should be used in order to change to that language. * - * @return array The array containing information of all available languages. + * @return array|null The array containing information of all available languages. */ private function generateLanguageBar() { @@ -431,6 +433,7 @@ class Template extends Response /** * Set some default context + * @return void */ private function twigDefaultContext() { @@ -498,6 +501,7 @@ class Template extends Response * This method is a remnant of the old templating system, where templates where shown manually instead of * returning a response. * + * @return void * @deprecated Do not use this method, use Twig + send() instead. Will be removed in 2.0 */ public function show() @@ -534,8 +538,9 @@ class Template extends Response * template file in the given module. * * @param string $template The relative path from the theme directory to the template file. + * @param bool $throw_exception * - * @return string The absolute path to the template file. + * @return string|null The absolute path to the template file. * * @throws \Exception If the template file couldn't be found. */ @@ -636,7 +641,7 @@ class Template extends Response /** - * @param $name + * @param string $name * * @return string * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::getLanguage() @@ -660,8 +665,9 @@ class Template extends Response /** - * @param $language + * @param string $language * @param bool $setLanguageCookie + * @return void * * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::setLanguage() * instead. @@ -684,7 +690,8 @@ class Template extends Response /** - * @param $language + * @param string $language + * @return void * * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Language::setLanguageCookie() * instead. @@ -697,6 +704,8 @@ class Template extends Response /** * Wraps Language->getLanguageList + * + * @return array */ private function getLanguageList() { @@ -705,7 +714,7 @@ class Template extends Response /** - * @param $tag + * @param string $tag * * @return array * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::getTag() instead. @@ -721,6 +730,9 @@ class Template extends Response * * @deprecated This method will be removed in SSP 2.0. Please use * \SimpleSAML\Locale\Translate::getPreferredTranslation() instead. + * + * @param array $translations + * @return string */ public function getTranslation($translations) { @@ -732,6 +744,8 @@ class Template extends Response * Includes a file relative to the template base directory. * This function can be used to include headers and footers etc. * + * @param string $file + * @return void */ private function includeAtTemplateBase($file) { @@ -749,6 +763,10 @@ class Template extends Response * @see \SimpleSAML\Locale\Translate::includeInlineTranslation() * @deprecated This method will be removed in SSP 2.0. Please use * \SimpleSAML\Locale\Translate::includeInlineTranslation() instead. + * + * @param string $tag + * @param string $translation + * @return void */ public function includeInlineTranslation($tag, $translation) { @@ -759,6 +777,7 @@ class Template extends Response /** * @param string $file * @param \SimpleSAML\Configuration|null $otherConfig + * @return void * * @deprecated This method will be removed in SSP 2.0. Please use * \SimpleSAML\Locale\Translate::includeLanguageFile() instead. @@ -771,6 +790,8 @@ class Template extends Response /** * Wrap Language->isLanguageRTL + * + * @return bool */ private function isLanguageRTL() { @@ -803,6 +824,9 @@ class Template extends Response * * @see \SimpleSAML\Locale\Translate::noop() * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::noop() instead. + * + * @param string $tag + * @return string */ public static function noop($tag) { @@ -815,6 +839,13 @@ class Template extends Response * * @see \SimpleSAML\Locale\Translate::t() * @deprecated This method will be removed in SSP 2.0. Please use \SimpleSAML\Locale\Translate::t() instead. + * + * @param string $tag + * @param array $replacements + * @param bool $fallbackdefault + * @param array $oldreplacements + * @param bool $striptags + * @return string */ public function t( $tag, diff --git a/lib/SimpleSAML/XHTML/TemplateLoader.php b/lib/SimpleSAML/XHTML/TemplateLoader.php index c5090d5544612a05e68270e28eda74e57310b352..b8de4368e5457709a1604050fc6f1432214c17de 100644 --- a/lib/SimpleSAML/XHTML/TemplateLoader.php +++ b/lib/SimpleSAML/XHTML/TemplateLoader.php @@ -14,7 +14,7 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader /** * This method adds a namespace dynamically so that we can load templates from modules whenever we want. * - * @inheritdoc + * {@inheritdoc} */ protected function findTemplate($name, $throw = true) { @@ -30,6 +30,7 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader * Parse the name of a template in a module. * * @param string $name The full name of the template, including namespace and template name / path. + * @param string $default * * @return array An array with the corresponding namespace and name of the template. The namespace defaults to * \Twig\Loader\FilesystemLoader::MAIN_NAMESPACE, if none was specified in $name. @@ -52,6 +53,7 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader /** * Get the template directory of a module, if it exists. * + * @param string $module * @return string The templates directory of a module. * * @throws \InvalidArgumentException If the module is not enabled or it has no templates directory. 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..80bd641c21f03ef8f521f63c2242cbde6bc18015 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 $issuer + * @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..0a0bf47e1d2a7287712811da590ce8055f6712a3 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,14 +32,18 @@ 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'; /** - * @var \DOMDocument The DOMDocument which represents this message. + * @var \DOMDocument|null The DOMDocument which represents this message. */ - private $dom; + private $dom = null; /** * @var string|null The relaystate which is associated with this response. @@ -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..848445ac01590a0fb5d2080d98c4f572bdd888c2 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) @@ -201,6 +201,7 @@ class Validator * @param string $certificate The X509 certificate we should validate. * @param array $fingerprints The valid fingerprints. * @throws \Exception + * @return void */ private static function validateCertificateFingerprint($certificate, $fingerprints) { @@ -239,6 +240,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 +299,7 @@ class Validator * * @param string $caFile File with trusted certificates, in PEM-format. * @throws \Exception + * @return void */ public function validateCA($caFile) { @@ -413,6 +416,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) diff --git a/psalm.xml b/psalm.xml index 31f0f3b8e2640072ba3627b2945cd7dbb66e5c84..a9ed2d69e3e9d1fa1a3f355e4357b41657fd94ae 100644 --- a/psalm.xml +++ b/psalm.xml @@ -30,6 +30,9 @@ <stubs> <file name="tests/Utils/Stubs/krb5.php" /> + <file name="tests/Utils/Stubs/memcache.php" /> + <file name="tests/Utils/Stubs/memcached.php" /> + <file name="tests/Utils/Stubs/predis.php" /> <file name="tests/Utils/Stubs/radius.php" /> </stubs> </psalm> diff --git a/templates/errorreport_mail.twig b/templates/errorreport_mail.twig new file mode 100644 index 0000000000000000000000000000000000000000..e549912e288fa470373706a9f9bab25023d490a9 --- /dev/null +++ b/templates/errorreport_mail.twig @@ -0,0 +1,30 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> + <title>SimpleSAMLphp Email report</title> + <style type="text/css"> +pre, div.box { + margin: .4em 2em .4em 1em; + padding: 4px; + +} +pre { + background: #eee; + border: 1px solid #aaa; +} +div.container { + background: #fafafa; + border: 1px solid #eee; + margin: 2em; + padding: .6em; +} + </style> +</head> +<body> +<div class="container"> +{{ body }} +</div> +</body> +</html> diff --git a/tests/Utils/Stubs/memcache.php b/tests/Utils/Stubs/memcache.php new file mode 100644 index 0000000000000000000000000000000000000000..547d3bdd4333c7f0307723cc7e459ecbeb74175c --- /dev/null +++ b/tests/Utils/Stubs/memcache.php @@ -0,0 +1,460 @@ +<?php + +// Start of memcache v.3.0.8 + +class MemcachePool { + + /** + * (PECL memcache >= 0.2.0)<br/> + * Open memcached server connection + * @link https://php.net/manual/en/memcache.connect.php + * @param string $host <p> + * Point to the host where memcached is listening for connections. This parameter + * may also specify other transports like <em>unix:///path/to/memcached.sock</em> + * to use UNIX domain sockets, in this case <b>port</b> must also + * be set to <em>0</em>. + * </p> + * @param int $port [optional] <p> + * Point to the port where memcached is listening for connections. Set this + * parameter to <em>0</em> when using UNIX domain sockets. + * </p> + * <p> + * Please note: <b>port</b> defaults to + * {@link https://php.net/manual/ru/memcache.ini.php#ini.memcache.default-port memcache.default_port} + * if not specified. For this reason it is wise to specify the port + * explicitly in this method call. + * </p> + * @param int $timeout [optional] <p>Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow.</p> + * @return boolean <p>Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.</p> + */ + public function connect ($host, $port, $timeout = 1) {} + + /** + * (PECL memcache >= 2.0.0)<br/> + * Add a memcached server to connection pool + * @link https://php.net/manual/en/memcache.addserver.php + * @param string $host <p> + * Point to the host where memcached is listening for connections. This parameter + * may also specify other transports like unix:///path/to/memcached.sock + * to use UNIX domain sockets, in this case <i>port</i> must also + * be set to 0. + * </p> + * @param int $port [optional] <p> + * Point to the port where memcached is listening for connections. + * Set this + * parameter to 0 when using UNIX domain sockets. + * </p> + * <p> + * Please note: <i>port</i> defaults to + * memcache.default_port + * if not specified. For this reason it is wise to specify the port + * explicitly in this method call. + * </p> + * @param bool $persistent [optional] <p> + * Controls the use of a persistent connection. Default to <b>TRUE</b>. + * </p> + * @param int $weight [optional] <p> + * Number of buckets to create for this server which in turn control its + * probability of it being selected. The probability is relative to the + * total weight of all servers. + * </p> + * @param int $timeout [optional] <p> + * Value in seconds which will be used for connecting to the daemon. Think + * twice before changing the default value of 1 second - you can lose all + * the advantages of caching if your connection is too slow. + * </p> + * @param int $retry_interval [optional] <p> + * Controls how often a failed server will be retried, the default value + * is 15 seconds. Setting this parameter to -1 disables automatic retry. + * Neither this nor the <i>persistent</i> parameter has any + * effect when the extension is loaded dynamically via <b>dl</b>. + * </p> + * <p> + * Each failed connection struct has its own timeout and before it has expired + * the struct will be skipped when selecting backends to serve a request. Once + * expired the connection will be successfully reconnected or marked as failed + * for another <i>retry_interval</i> seconds. The typical + * effect is that each web server child will retry the connection about every + * <i>retry_interval</i> seconds when serving a page. + * </p> + * @param bool $status [optional] <p> + * Controls if the server should be flagged as online. Setting this parameter + * to <b>FALSE</b> and <i>retry_interval</i> to -1 allows a failed + * server to be kept in the pool so as not to affect the key distribution + * algorithm. Requests for this server will then failover or fail immediately + * depending on the <i>memcache.allow_failover</i> setting. + * Default to <b>TRUE</b>, meaning the server should be considered online. + * </p> + * @param callable $failure_callback [optional] <p> + * Allows the user to specify a callback function to run upon encountering an + * error. The callback is run before failover is attempted. The function takes + * two parameters, the hostname and port of the failed server. + * </p> + * @param int $timeoutms [optional] <p> + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function addServer ($host, $port = 11211, $persistent = true, $weight = null, $timeout = 1, $retry_interval = 15, $status = true, callable $failure_callback = null, $timeoutms = null) {} + + /** + * (PECL memcache >= 2.1.0)<br/> + * Changes server parameters and status at runtime + * @link https://secure.php.net/manual/en/memcache.setserverparams.php + * @param string $host <p>Point to the host where memcached is listening for connections.</p. + * @param int $port [optional] <p> + * Point to the port where memcached is listening for connections. + * </p> + * @param int $timeout [optional] <p> + * Value in seconds which will be used for connecting to the daemon. Think twice before changing the default value of 1 second - you can lose all the advantages of caching if your connection is too slow. + * </p> + * @param int $retry_interval [optional] <p> + * Controls how often a failed server will be retried, the default value + * is 15 seconds. Setting this parameter to -1 disables automatic retry. + * Neither this nor the <b>persistent</b> parameter has any + * effect when the extension is loaded dynamically via {@link https://secure.php.net/manual/en/function.dl.php dl()}. + * </p> + * @param bool $status [optional] <p> + * Controls if the server should be flagged as online. Setting this parameter + * to <b>FALSE</b> and <b>retry_interval</b> to -1 allows a failed + * server to be kept in the pool so as not to affect the key distribution + * algorithm. Requests for this server will then failover or fail immediately + * depending on the <b>memcache.allow_failover</b> setting. + * Default to <b>TRUE</b>, meaning the server should be considered online. + * </p> + * @param callable $failure_callback [optional] <p> + * Allows the user to specify a callback function to run upon encountering an error. The callback is run before failover is attempted. + * The function takes two parameters, the hostname and port of the failed server. + * </p> + * @return boolean <p>Returns <b>TRUE</b> on success or <b>FALSE</b> on failure.</p> + */ + public function setServerParams ($host, $port = 11211, $timeout = 1, $retry_interval = 15, $status = true, callable $failure_callback = null) {} + + /** + * + */ + public function setFailureCallback () {} + + /** + * (PECL memcache >= 2.1.0)<br/> + * Returns server status + * @link https://php.net/manual/en/memcache.getserverstatus.php + * @param string $host Point to the host where memcached is listening for connections. + * @param int $port Point to the port where memcached is listening for connections. + * @return int Returns a the servers status. 0 if server is failed, non-zero otherwise + */ + public function getServerStatus ($host, $port = 11211) {} + + /** + * + */ + public function findServer () {} + + /** + * (PECL memcache >= 0.2.0)<br/> + * Return version of the server + * @link https://php.net/manual/en/memcache.getversion.php + * @return string|boolean Returns a string of server version number or <b>FALSE</b> on failure. + */ + public function getVersion () {} + + /** + * (PECL memcache >= 2.0.0)<br/> + * Add an item to the server. If the key already exists, the value will not be added and <b>FALSE</b> will be returned. + * @link https://php.net/manual/en/memcache.add.php + * @param string $key The key that will be associated with the item. + * @param mixed $var The variable to store. Strings and integers are stored as is, other types are stored serialized. + * @param int $flag [optional] <p> + * Use <b>MEMCACHE_COMPRESSED</b> to store the item + * compressed (uses zlib). + * </p> + * @param int $expire [optional] <p>Expiration time of the item. + * If it's equal to zero, the item will never expire. + * You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).</p> + * @return boolean Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. Returns <b>FALSE</b> if such key already exist. For the rest Memcache::add() behaves similarly to Memcache::set(). + */ + public function add ($key , $var, $flag = null, $expire = null) {} + + /** + * (PECL memcache >= 0.2.0)<br/> + * Stores an item var with key on the memcached server. Parameter expire is expiration time in seconds. + * If it's 0, the item never expires (but memcached server doesn't guarantee this item to be stored all the time, + * it could be deleted from the cache to make place for other items). + * You can use MEMCACHE_COMPRESSED constant as flag value if you want to use on-the-fly compression (uses zlib). + * @link https://php.net/manual/en/memcache.set.php + * @param string $key The key that will be associated with the item. + * @param mixed $var The variable to store. Strings and integers are stored as is, other types are stored serialized. + * @param int $flag [optional] Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib). + * @param int $expire [optional] Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days). + * @return boolean Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function set ($key, $var, $flag = null, $expire = null) {} + + /** + * (PECL memcache >= 0.2.0)<br/> + * Replace value of the existing item + * @link https://php.net/manual/en/memcache.replace.php + * @param string $key <p>The key that will be associated with the item.</p> + * @param mixed $var <p>The variable to store. Strings and integers are stored as is, other types are stored serialized.</p> + * @param int $flag [optional] <p>Use <b>MEMCACHE_COMPRESSED</b> to store the item compressed (uses zlib).</p> + * @param int $expire [optional] <p>Expiration time of the item. If it's equal to zero, the item will never expire. You can also use Unix timestamp or a number of seconds starting from current time, but in the latter case the number of seconds may not exceed 2592000 (30 days).</p> + * @return boolean Returns TRUE on success or FALSE on failure. + */ + public function replace ($key, $var, $flag = null, $expire = null) {} + + public function cas () {} + + public function append () {} + + /** + * @return string + */ + public function prepend () {} + + /** + * (PECL memcache >= 0.2.0)<br/> + * Retrieve item from the server + * @link https://php.net/manual/en/memcache.get.php + * @param string|array $key <p> + * The key or array of keys to fetch. + * </p> + * @param int|array $flags [optional] <p> + * If present, flags fetched along with the values will be written to this parameter. These + * flags are the same as the ones given to for example {@link https://php.net/manual/en/memcache.set.php Memcache::set()}. + * The lowest byte of the int is reserved for pecl/memcache internal usage (e.g. to indicate + * compression and serialization status). + * </p> + * @return string|array <p> + * Returns the string associated with the <b>key</b> or + * an array of found key-value pairs when <b>key</b> is an {@link https://php.net/manual/en/language.types.array.php array}. + * Returns <b>FALSE</b> on failure, <b>key</b> is not found or + * <b>key</b> is an empty {@link https://php.net/manual/en/language.types.array.php array}. + * </p> + */ + public function get ($key, &$flags = null) {} + + /** + * (PECL memcache >= 0.2.0)<br/> + * Delete item from the server + * https://secure.php.net/manual/ru/memcache.delete.php + * @param $key string The key associated with the item to delete. + * @param $timeout int [optional] This deprecated parameter is not supported, and defaults to 0 seconds. Do not use this parameter. + * @return boolean Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function delete ($key, $timeout = 0 ) {} + + /** + * (PECL memcache >= 0.2.0)<br/> + * Get statistics of the server + * @link https://php.net/manual/ru/memcache.getstats.php + * @param string $type [optional] <p> + * The type of statistics to fetch. + * Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}. + * According to the memcached protocol spec these additional arguments "are subject to change for the convenience of memcache developers".</p> + * @param int $slabid [optional] <p> + * Used in conjunction with <b>type</b> set to + * cachedump to identify the slab to dump from. The cachedump + * command ties up the server and is strictly to be used for + * debugging purposes. + * </p> + * @param int $limit [optional] <p> + * Used in conjunction with <b>type</b> set to cachedump to limit the number of entries to dump. + * </p> + * @return array|bool Returns an associative array of server statistics or <b>FALSE</b> on failure. + */ + public function getStats ($type = null, $slabid = null, $limit = 100) {} + + /** + * (PECL memcache >= 2.0.0)<br/> + * Get statistics from all servers in pool + * @link https://php.net/manual/en/memcache.getextendedstats.php + * @param string $type [optional] <p>The type of statistics to fetch. Valid values are {reset, malloc, maps, cachedump, slabs, items, sizes}. According to the memcached protocol spec these additional arguments "are subject to change for the convenience of memcache developers".</p> + * @param int $slabid [optional] <p> + * Used in conjunction with <b>type</b> set to + * cachedump to identify the slab to dump from. The cachedump + * command ties up the server and is strictly to be used for + * debugging purposes. + * </p> + * @param int $limit Used in conjunction with type set to cachedump to limit the number of entries to dump. + * @return array|bool Returns a two-dimensional associative array of server statistics or <b>FALSE</b> + * Returns a two-dimensional associative array of server statistics or <b>FALSE</b> + * on failure. + */ + public function getExtendedStats ($type = null, $slabid = null, $limit = 100) {} + + /** + * (PECL memcache >= 2.0.0)<br/> + * Enable automatic compression of large values + * @link https://php.net/manual/en/memcache.setcompressthreshold.php + * @param int $thresold <p>Controls the minimum value length before attempting to compress automatically.</p> + * @param float $min_saving [optional] <p>Specifies the minimum amount of savings to actually store the value compressed. The supplied value must be between 0 and 1. Default value is 0.2 giving a minimum 20% compression savings.</p> + * @return boolean Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function setCompressThreshold ($thresold, $min_saving = 0.2) {} + /** + * (PECL memcache >= 0.2.0)<br/> + * Increment item's value + * @link https://php.net/manual/en/memcache.increment.php + * @param $key string Key of the item to increment. + * @param $value int [optional] increment the item by <b>value</b> + * @return int|boolean Returns new items value on success or <b>FALSE</b> on failure. + */ + public function increment ($key, $value = 1) {} + + /** + * (PECL memcache >= 0.2.0)<br/> + * Decrement item's value + * @link https://php.net/manual/en/memcache.decrement.php + * @param $key string Key of the item do decrement. + * @param $value int Decrement the item by <b>value</b>. + * @return int|boolean Returns item's new value on success or <b>FALSE</b> on failure. + */ + public function decrement ($key, $value = 1) {} + + /** + * (PECL memcache >= 0.4.0)<br/> + * Close memcached server connection + * @link https://php.net/manual/en/memcache.close.php + * @return boolean Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function close () {} + + /** + * (PECL memcache >= 1.0.0)<br/> + * Flush all existing items at the server + * @link https://php.net/manual/en/memcache.flush.php + * @return boolean Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function flush () {} + +} + +/** + * Represents a connection to a set of memcache servers. + * @link https://php.net/manual/en/class.memcache.php + */ +class Memcache extends MemcachePool { + + + /** + * (PECL memcache >= 0.4.0)<br/> + * Open memcached server persistent connection + * @link https://php.net/manual/en/memcache.pconnect.php + * @param string $host <p> + * Point to the host where memcached is listening for connections. This parameter + * may also specify other transports like unix:///path/to/memcached.sock + * to use UNIX domain sockets, in this case <i>port</i> must also + * be set to 0. + * </p> + * @param int $port [optional] <p> + * Point to the port where memcached is listening for connections. Set this + * parameter to 0 when using UNIX domain sockets. + * </p> + * @param int $timeout [optional] <p> + * Value in seconds which will be used for connecting to the daemon. Think + * twice before changing the default value of 1 second - you can lose all + * the advantages of caching if your connection is too slow. + * </p> + * @return mixed a Memcache object or <b>FALSE</b> on failure. + */ + public function pconnect ($host, $port, $timeout = 1) {} +} + +// string $host [, int $port [, int $timeout ]] + +/** + * (PECL memcache >= 0.2.0)</br> + * Memcache::connect — Open memcached server connection + * @link https://php.net/manual/en/memcache.connect.php + * @param string $host <p> + * Point to the host where memcached is listening for connections. + * This parameter may also specify other transports like + * unix:///path/to/memcached.sock to use UNIX domain sockets, + * in this case port must also be set to 0. + * </p> + * @param int $port [optional] <p> + * Point to the port where memcached is listening for connections. + * Set this parameter to 0 when using UNIX domain sockets. + * Note: port defaults to memcache.default_port if not specified. + * For this reason it is wise to specify the port explicitly in this method call. + * </p> + * @param int $timeout [optional] <p> + * Value in seconds which will be used for connecting to the daemon. + * </p> + * @return bool Returns <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ +function memcache_connect ($host, $port, $timeout = 1) {} + +/** + * (PECL memcache >= 0.4.0) + * Memcache::pconnect — Open memcached server persistent connection + * + * @link https://php.net/manual/en/memcache.pconnect.php#example-5242 + * @param $host + * @param null $port + * @param int $timeout + * @return Memcache + */ +function memcache_pconnect ($host, $port=null, $timeout=1) {} + +function memcache_add_server () {} + +function memcache_set_server_params () {} + +function memcache_set_failure_callback () {} + +function memcache_get_server_status () {} + +function memcache_get_version () {} + +function memcache_add () {} + +function memcache_set () {} + +function memcache_replace () {} + +function memcache_cas () {} + +function memcache_append () {} + +function memcache_prepend () {} + +function memcache_get () {} + +function memcache_delete () {} + +/** + * (PECL memcache >= 0.2.0)<br/> + * Turn debug output on/off + * @link https://php.net/manual/en/function.memcache-debug.php + * @param bool $on_off <p> + * Turns debug output on if equals to <b>TRUE</b>. + * Turns debug output off if equals to <b>FALSE</b>. + * </p> + * @return bool <b>TRUE</b> if PHP was built with --enable-debug option, otherwise + * returns <b>FALSE</b>. + */ +function memcache_debug ($on_off) {} + +function memcache_get_stats () {} + +function memcache_get_extended_stats () {} + +function memcache_set_compress_threshold () {} + +function memcache_increment () {} + +function memcache_decrement () {} + +function memcache_close () {} + +function memcache_flush () {} + +define ('MEMCACHE_COMPRESSED', 2); +define ('MEMCACHE_USER1', 65536); +define ('MEMCACHE_USER2', 131072); +define ('MEMCACHE_USER3', 262144); +define ('MEMCACHE_USER4', 524288); +define ('MEMCACHE_HAVE_SESSION', 1); + +// End of memcache v.3.0.8 +?> diff --git a/tests/Utils/Stubs/memcached.php b/tests/Utils/Stubs/memcached.php new file mode 100644 index 0000000000000000000000000000000000000000..4b8da2c6f623b8d21c8d40bdf411434c9e99206f --- /dev/null +++ b/tests/Utils/Stubs/memcached.php @@ -0,0 +1,1308 @@ +<?php + +// Start of memcached v.3.0.4 + +/** + * Represents a connection to a set of memcached servers. + * @link https://php.net/manual/en/class.memcached.php + */ +class Memcached { + + /** + * <p>Enables or disables payload compression. When enabled, + * item values longer than a certain threshold (currently 100 bytes) will be + * compressed during storage and decompressed during retrieval + * transparently.</p> + * <p>Type: boolean, default: <b>TRUE</b>.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_COMPRESSION = -1001; + const OPT_COMPRESSION_TYPE = -1004; + + /** + * <p>This can be used to create a "domain" for your item keys. The value + * specified here will be prefixed to each of the keys. It cannot be + * longer than 128 characters and will reduce the + * maximum available key size. The prefix is applied only to the item keys, + * not to the server keys.</p> + * <p>Type: string, default: "".</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_PREFIX_KEY = -1002; + + /** + * <p> + * Specifies the serializer to use for serializing non-scalar values. + * The valid serializers are <b>Memcached::SERIALIZER_PHP</b> + * or <b>Memcached::SERIALIZER_IGBINARY</b>. The latter is + * supported only when memcached is configured with + * --enable-memcached-igbinary option and the + * igbinary extension is loaded. + * </p> + * <p>Type: integer, default: <b>Memcached::SERIALIZER_PHP</b>.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_SERIALIZER = -1003; + + /** + * <p>Indicates whether igbinary serializer support is available.</p> + * <p>Type: boolean.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HAVE_IGBINARY = 0; + + /** + * <p>Indicates whether JSON serializer support is available.</p> + * <p>Type: boolean.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HAVE_JSON = 0; + const HAVE_SESSION = 1; + const HAVE_SASL = 0; + + /** + * <p>Specifies the hashing algorithm used for the item keys. The valid + * values are supplied via <b>Memcached::HASH_*</b> constants. + * Each hash algorithm has its advantages and its disadvantages. Go with the + * default if you don't know or don't care.</p> + * <p>Type: integer, default: <b>Memcached::HASH_DEFAULT</b></p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_HASH = 2; + + /** + * <p>The default (Jenkins one-at-a-time) item key hashing algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HASH_DEFAULT = 0; + + /** + * <p>MD5 item key hashing algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HASH_MD5 = 1; + + /** + * <p>CRC item key hashing algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HASH_CRC = 2; + + /** + * <p>FNV1_64 item key hashing algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HASH_FNV1_64 = 3; + + /** + * <p>FNV1_64A item key hashing algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HASH_FNV1A_64 = 4; + + /** + * <p>FNV1_32 item key hashing algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HASH_FNV1_32 = 5; + + /** + * <p>FNV1_32A item key hashing algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HASH_FNV1A_32 = 6; + + /** + * <p>Hsieh item key hashing algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HASH_HSIEH = 7; + + /** + * <p>Murmur item key hashing algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const HASH_MURMUR = 8; + + /** + * <p>Specifies the method of distributing item keys to the servers. + * Currently supported methods are modulo and consistent hashing. Consistent + * hashing delivers better distribution and allows servers to be added to + * the cluster with minimal cache losses.</p> + * <p>Type: integer, default: <b>Memcached::DISTRIBUTION_MODULA.</b></p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_DISTRIBUTION = 9; + + /** + * <p>Modulo-based key distribution algorithm.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const DISTRIBUTION_MODULA = 0; + + /** + * <p>Consistent hashing key distribution algorithm (based on libketama).</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const DISTRIBUTION_CONSISTENT = 1; + const DISTRIBUTION_VIRTUAL_BUCKET = 6; + + /** + * <p>Enables or disables compatibility with libketama-like behavior. When + * enabled, the item key hashing algorithm is set to MD5 and distribution is + * set to be weighted consistent hashing distribution. This is useful + * because other libketama-based clients (Python, Ruby, etc.) with the same + * server configuration will be able to access the keys transparently. + * </p> + * <p> + * It is highly recommended to enable this option if you want to use + * consistent hashing, and it may be enabled by default in future + * releases. + * </p> + * <p>Type: boolean, default: <b>FALSE</b>.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_LIBKETAMA_COMPATIBLE = 16; + const OPT_LIBKETAMA_HASH = 17; + const OPT_TCP_KEEPALIVE = 32; + + /** + * <p>Enables or disables buffered I/O. Enabling buffered I/O causes + * storage commands to "buffer" instead of being sent. Any action that + * retrieves data causes this buffer to be sent to the remote connection. + * Quitting the connection or closing down the connection will also cause + * the buffered data to be pushed to the remote connection.</p> + * <p>Type: boolean, default: <b>FALSE</b>.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_BUFFER_WRITES = 10; + + /** + * <p>Enable the use of the binary protocol. Please note that you cannot + * toggle this option on an open connection.</p> + * <p>Type: boolean, default: <b>FALSE</b>.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_BINARY_PROTOCOL = 18; + + /** + * <p>Enables or disables asynchronous I/O. This is the fastest transport + * available for storage functions.</p> + * <p>Type: boolean, default: <b>FALSE</b>.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_NO_BLOCK = 0; + + /** + * <p>Enables or disables the no-delay feature for connecting sockets (may + * be faster in some environments).</p> + * <p>Type: boolean, default: <b>FALSE</b>.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_TCP_NODELAY = 1; + + /** + * <p>The maximum socket send buffer in bytes.</p> + * <p>Type: integer, default: varies by platform/kernel + * configuration.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_SOCKET_SEND_SIZE = 4; + + /** + * <p>The maximum socket receive buffer in bytes.</p> + * <p>Type: integer, default: varies by platform/kernel + * configuration.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_SOCKET_RECV_SIZE = 5; + + /** + * <p>In non-blocking mode this set the value of the timeout during socket + * connection, in milliseconds.</p> + * <p>Type: integer, default: 1000.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_CONNECT_TIMEOUT = 14; + + /** + * <p>The amount of time, in seconds, to wait until retrying a failed + * connection attempt.</p> + * <p>Type: integer, default: 0.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_RETRY_TIMEOUT = 15; + + /** + * <p>Socket sending timeout, in microseconds. In cases where you cannot + * use non-blocking I/O this will allow you to still have timeouts on the + * sending of data.</p> + * <p>Type: integer, default: 0.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_SEND_TIMEOUT = 19; + + /** + * <p>Socket reading timeout, in microseconds. In cases where you cannot + * use non-blocking I/O this will allow you to still have timeouts on the + * reading of data.</p> + * <p>Type: integer, default: 0.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_RECV_TIMEOUT = 20; + + /** + * <p>Timeout for connection polling, in milliseconds.</p> + * <p>Type: integer, default: 1000.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_POLL_TIMEOUT = 8; + + /** + * <p>Enables or disables caching of DNS lookups.</p> + * <p>Type: boolean, default: <b>FALSE</b>.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_CACHE_LOOKUPS = 6; + + /** + * <p>Specifies the failure limit for server connection attempts. The + * server will be removed after this many continuous connection + * failures.</p> + * <p>Type: integer, default: 0.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const OPT_SERVER_FAILURE_LIMIT = 21; + const OPT_AUTO_EJECT_HOSTS = 28; + const OPT_HASH_WITH_PREFIX_KEY = 25; + const OPT_NOREPLY = 26; + const OPT_SORT_HOSTS = 12; + const OPT_VERIFY_KEY = 13; + const OPT_USE_UDP = 27; + const OPT_NUMBER_OF_REPLICAS = 29; + const OPT_RANDOMIZE_REPLICA_READ = 30; + const OPT_CORK = 31; + const OPT_REMOVE_FAILED_SERVERS = 35; + const OPT_DEAD_TIMEOUT = 36; + const OPT_SERVER_TIMEOUT_LIMIT = 37; + const OPT_MAX = 38; + const OPT_IO_BYTES_WATERMARK = 23; + const OPT_IO_KEY_PREFETCH = 24; + const OPT_IO_MSG_WATERMARK = 22; + const OPT_LOAD_FROM_FILE = 34; + const OPT_SUPPORT_CAS = 7; + const OPT_TCP_KEEPIDLE = 33; + const OPT_USER_DATA = 11; + + + /** + * <p>The operation was successful.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_SUCCESS = 0; + + /** + * <p>The operation failed in some fashion.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_FAILURE = 1; + + /** + * <p>DNS lookup failed.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_HOST_LOOKUP_FAILURE = 2; + + /** + * <p>Failed to read network data.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_UNKNOWN_READ_FAILURE = 7; + + /** + * <p>Bad command in memcached protocol.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_PROTOCOL_ERROR = 8; + + /** + * <p>Error on the client side.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_CLIENT_ERROR = 9; + + /** + * <p>Error on the server side.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_SERVER_ERROR = 10; + + /** + * <p>Failed to write network data.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_WRITE_FAILURE = 5; + + /** + * <p>Failed to do compare-and-swap: item you are trying to store has been + * modified since you last fetched it.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_DATA_EXISTS = 12; + + /** + * <p>Item was not stored: but not because of an error. This normally + * means that either the condition for an "add" or a "replace" command + * wasn't met, or that the item is in a delete queue.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_NOTSTORED = 14; + + /** + * <p>Item with this key was not found (with "get" operation or "cas" + * operations).</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_NOTFOUND = 16; + + /** + * <p>Partial network data read error.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_PARTIAL_READ = 18; + + /** + * <p>Some errors occurred during multi-get.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_SOME_ERRORS = 19; + + /** + * <p>Server list is empty.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_NO_SERVERS = 20; + + /** + * <p>End of result set.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_END = 21; + + /** + * <p>System error.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_ERRNO = 26; + + /** + * <p>The operation was buffered.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_BUFFERED = 32; + + /** + * <p>The operation timed out.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_TIMEOUT = 31; + + /** + * <p>Bad key.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_BAD_KEY_PROVIDED = 33; + const RES_STORED = 15; + const RES_DELETED = 22; + const RES_STAT = 24; + const RES_ITEM = 25; + const RES_NOT_SUPPORTED = 28; + const RES_FETCH_NOTFINISHED = 30; + const RES_SERVER_MARKED_DEAD = 35; + const RES_UNKNOWN_STAT_KEY = 36; + const RES_INVALID_HOST_PROTOCOL = 34; + const RES_MEMORY_ALLOCATION_FAILURE = 17; + const RES_E2BIG = 37; + const RES_KEY_TOO_BIG = 39; + const RES_SERVER_TEMPORARILY_DISABLED = 47; + const RES_SERVER_MEMORY_ALLOCATION_FAILURE = 48; + const RES_AUTH_PROBLEM = 40; + const RES_AUTH_FAILURE = 41; + const RES_AUTH_CONTINUE = 42; + const RES_CONNECTION_FAILURE = 3; + const RES_CONNECTION_BIND_FAILURE = 4; + const RES_READ_FAILURE = 6; + const RES_DATA_DOES_NOT_EXIST = 13; + const RES_VALUE = 23; + const RES_FAIL_UNIX_SOCKET = 27; + const RES_NO_KEY_PROVIDED = 29; + const RES_INVALID_ARGUMENTS = 38; + const RES_PARSE_ERROR = 43; + const RES_PARSE_USER_ERROR = 44; + const RES_DEPRECATED = 45; + const RES_IN_PROGRESS = 46; + const RES_MAXIMUM_RETURN = 49; + + + + /** + * <p>Failed to create network socket.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_CONNECTION_SOCKET_CREATE_FAILURE = 11; + + /** + * <p>Payload failure: could not compress/decompress or serialize/unserialize the value.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const RES_PAYLOAD_FAILURE = -1001; + + /** + * <p>The default PHP serializer.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const SERIALIZER_PHP = 1; + + /** + * <p>The igbinary serializer. + * Instead of textual representation it stores PHP data structures in a + * compact binary form, resulting in space and time gains.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const SERIALIZER_IGBINARY = 2; + + /** + * <p>The JSON serializer. Requires PHP 5.2.10+.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const SERIALIZER_JSON = 3; + const SERIALIZER_JSON_ARRAY = 4; + const COMPRESSION_FASTLZ = 2; + const COMPRESSION_ZLIB = 1; + + /** + * <p>A flag for <b>Memcached::getMulti</b> and + * <b>Memcached::getMultiByKey</b> to ensure that the keys are + * returned in the same order as they were requested in. Non-existing keys + * get a default value of NULL.</p> + * @link https://php.net/manual/en/memcached.constants.php + */ + const GET_PRESERVE_ORDER = 1; + const GET_ERROR_RETURN_VALUE = false; + + + /** + * (PECL memcached >= 0.1.0)<br/> + * Create a Memcached instance + * @link https://php.net/manual/en/memcached.construct.php + * @param $persistent_id [optional] + * @param $callback [optional] + */ + public function __construct ($persistent_id = '', $on_new_object_cb = null) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Return the result code of the last operation + * @link https://php.net/manual/en/memcached.getresultcode.php + * @return int Result code of the last Memcached operation. + */ + public function getResultCode () {} + + /** + * (PECL memcached >= 1.0.0)<br/> + * Return the message describing the result of the last operation + * @link https://php.net/manual/en/memcached.getresultmessage.php + * @return string Message describing the result of the last Memcached operation. + */ + public function getResultMessage () {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Retrieve an item + * @link https://php.net/manual/en/memcached.get.php + * @param string $key <p> + * The key of the item to retrieve. + * </p> + * @param callable $cache_cb [optional] <p> + * Read-through caching callback or <b>NULL</b>. + * </p> + * @param int $flags [optional] <p> + * The flags for the get operation. + * </p> + * @return mixed the value stored in the cache or <b>FALSE</b> otherwise. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTFOUND</b> if the key does not exist. + */ + public function get ($key, callable $cache_cb = null, $flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Retrieve an item from a specific server + * @link https://php.net/manual/en/memcached.getbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key of the item to fetch. + * </p> + * @param callable $cache_cb [optional] <p> + * Read-through caching callback or <b>NULL</b> + * </p> + * @param int $flags [optional] <p> + * The flags for the get operation. + * </p> + * @return mixed the value stored in the cache or <b>FALSE</b> otherwise. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTFOUND</b> if the key does not exist. + */ + public function getByKey ($server_key, $key, callable $cache_cb = null, $flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Retrieve multiple items + * @link https://php.net/manual/en/memcached.getmulti.php + * @param array $keys <p> + * Array of keys to retrieve. + * </p> + * @param int $flags [optional] <p> + * The flags for the get operation. + * </p> + * @return mixed the array of found items or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function getMulti (array $keys, $flags = null) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Retrieve multiple items from a specific server + * @link https://php.net/manual/en/memcached.getmultibykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param array $keys <p> + * Array of keys to retrieve. + * </p> + * @param int $flags [optional] <p> + * The flags for the get operation. + * </p> + * @return array the array of found items or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function getMultiByKey ($server_key, array $keys, $flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Request multiple items + * @link https://php.net/manual/en/memcached.getdelayed.php + * @param array $keys <p> + * Array of keys to request. + * </p> + * @param bool $with_cas [optional] <p> + * Whether to request CAS token values also. + * </p> + * @param callable $value_cb [optional] <p> + * The result callback or <b>NULL</b>. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function getDelayed (array $keys, $with_cas = null, callable $value_cb = null) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Request multiple items from a specific server + * @link https://php.net/manual/en/memcached.getdelayedbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param array $keys <p> + * Array of keys to request. + * </p> + * @param bool $with_cas [optional] <p> + * Whether to request CAS token values also. + * </p> + * @param callable $value_cb [optional] <p> + * The result callback or <b>NULL</b>. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function getDelayedByKey ($server_key, array $keys, $with_cas = null, callable $value_cb = null) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Fetch the next result + * @link https://php.net/manual/en/memcached.fetch.php + * @return array the next result or <b>FALSE</b> otherwise. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_END</b> if result set is exhausted. + */ + public function fetch () {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Fetch all the remaining results + * @link https://php.net/manual/en/memcached.fetchall.php + * @return array the results or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function fetchAll () {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Store an item + * @link https://php.net/manual/en/memcached.set.php + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param mixed $value <p> + * The value to store. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function set ($key, $value, $expiration = 0, $udf_flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Store an item on a specific server + * @link https://php.net/manual/en/memcached.setbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param mixed $value <p> + * The value to store. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function setByKey ($server_key, $key, $value, $expiration = 0, $udf_flags = 0) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Set a new expiration on an item + * @link https://php.net/manual/en/memcached.touch.php + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param int $expiration <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function touch ($key, $expiration = 0) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Set a new expiration on an item on a specific server + * @link https://php.net/manual/en/memcached.touchbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param int $expiration <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function touchByKey ($server_key, $key, $expiration) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Store multiple items + * @link https://php.net/manual/en/memcached.setmulti.php + * @param array $items <p> + * An array of key/value pairs to store on the server. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function setMulti (array $items, $expiration = 0, $udf_flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Store multiple items on a specific server + * @link https://php.net/manual/en/memcached.setmultibykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param array $items <p> + * An array of key/value pairs to store on the server. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function setMultiByKey ($server_key, array $items, $expiration = 0, $udf_flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Compare and swap an item + * @link https://php.net/manual/en/memcached.cas.php + * @param float $cas_token <p> + * Unique value associated with the existing item. Generated by memcache. + * </p> + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param mixed $value <p> + * The value to store. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_DATA_EXISTS</b> if the item you are trying + * to store has been modified since you last fetched it. + */ + public function cas ($cas_token, $key, $value, $expiration = 0, $udf_flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Compare and swap an item on a specific server + * @link https://php.net/manual/en/memcached.casbykey.php + * @param float $cas_token <p> + * Unique value associated with the existing item. Generated by memcache. + * </p> + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param mixed $value <p> + * The value to store. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_DATA_EXISTS</b> if the item you are trying + * to store has been modified since you last fetched it. + */ + public function casByKey ($cas_token, $server_key, $key, $value, $expiration = 0, $udf_flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Add an item under a new key + * @link https://php.net/manual/en/memcached.add.php + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param mixed $value <p> + * The value to store. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTSTORED</b> if the key already exists. + */ + public function add ($key, $value, $expiration = 0, $udf_flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Add an item under a new key on a specific server + * @link https://php.net/manual/en/memcached.addbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param mixed $value <p> + * The value to store. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTSTORED</b> if the key already exists. + */ + public function addByKey ($server_key, $key, $value, $expiration = 0, $udf_flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Append data to an existing item + * @link https://php.net/manual/en/memcached.append.php + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param string $value <p> + * The string to append. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTSTORED</b> if the key does not exist. + */ + public function append ($key, $value) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Append data to an existing item on a specific server + * @link https://php.net/manual/en/memcached.appendbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param string $value <p> + * The string to append. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTSTORED</b> if the key does not exist. + */ + public function appendByKey ($server_key, $key, $value) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Prepend data to an existing item + * @link https://php.net/manual/en/memcached.prepend.php + * @param string $key <p> + * The key of the item to prepend the data to. + * </p> + * @param string $value <p> + * The string to prepend. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTSTORED</b> if the key does not exist. + */ + public function prepend ($key, $value) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Prepend data to an existing item on a specific server + * @link https://php.net/manual/en/memcached.prependbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key of the item to prepend the data to. + * </p> + * @param string $value <p> + * The string to prepend. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTSTORED</b> if the key does not exist. + */ + public function prependByKey ($server_key, $key, $value) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Replace the item under an existing key + * @link https://php.net/manual/en/memcached.replace.php + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param mixed $value <p> + * The value to store. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTSTORED</b> if the key does not exist. + */ + public function replace ($key, $value, $expiration = null, $udf_flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Replace the item under an existing key on a specific server + * @link https://php.net/manual/en/memcached.replacebykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key under which to store the value. + * </p> + * @param mixed $value <p> + * The value to store. + * </p> + * @param int $expiration [optional] <p> + * The expiration time, defaults to 0. See Expiration Times for more info. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTSTORED</b> if the key does not exist. + */ + public function replaceByKey ($server_key, $key, $value, $expiration = null, $udf_flags = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Delete an item + * @link https://php.net/manual/en/memcached.delete.php + * @param string $key <p> + * The key to be deleted. + * </p> + * @param int $time [optional] <p> + * The amount of time the server will wait to delete the item. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTFOUND</b> if the key does not exist. + */ + public function delete ($key, $time = 0) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Delete multiple items + * @link https://php.net/manual/en/memcached.deletemulti.php + * @param array $keys <p> + * The keys to be deleted. + * </p> + * @param int $time [optional] <p> + * The amount of time the server will wait to delete the items. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTFOUND</b> if the key does not exist. + */ + public function deleteMulti (array $keys, $time = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Delete an item from a specific server + * @link https://php.net/manual/en/memcached.deletebykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key to be deleted. + * </p> + * @param int $time [optional] <p> + * The amount of time the server will wait to delete the item. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTFOUND</b> if the key does not exist. + */ + public function deleteByKey ($server_key, $key, $time = 0) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Delete multiple items from a specific server + * @link https://php.net/manual/en/memcached.deletemultibykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param array $keys <p> + * The keys to be deleted. + * </p> + * @param int $time [optional] <p> + * The amount of time the server will wait to delete the items. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * The <b>Memcached::getResultCode</b> will return + * <b>Memcached::RES_NOTFOUND</b> if the key does not exist. + */ + public function deleteMultiByKey ($server_key, array $keys, $time = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Increment numeric item's value + * @link https://php.net/manual/en/memcached.increment.php + * @param string $key <p> + * The key of the item to increment. + * </p> + * @param int $offset [optional] <p> + * The amount by which to increment the item's value. + * </p> + * @param int $initial_value [optional] <p> + * The value to set the item to if it doesn't currently exist. + * </p> + * @param int $expiry [optional] <p> + * The expiry time to set on the item. + * </p> + * @return int new item's value on success or <b>FALSE</b> on failure. + */ + public function increment ($key, $offset = 1, $initial_value = 0, $expiry = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Decrement numeric item's value + * @link https://php.net/manual/en/memcached.decrement.php + * @param string $key <p> + * The key of the item to decrement. + * </p> + * @param int $offset [optional] <p> + * The amount by which to decrement the item's value. + * </p> + * @param int $initial_value [optional] <p> + * The value to set the item to if it doesn't currently exist. + * </p> + * @param int $expiry [optional] <p> + * The expiry time to set on the item. + * </p> + * @return int item's new value on success or <b>FALSE</b> on failure. + */ + public function decrement ($key, $offset = 1, $initial_value = 0, $expiry = 0) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Increment numeric item's value, stored on a specific server + * @link https://php.net/manual/en/memcached.incrementbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key of the item to increment. + * </p> + * @param int $offset [optional] <p> + * The amount by which to increment the item's value. + * </p> + * @param int $initial_value [optional] <p> + * The value to set the item to if it doesn't currently exist. + * </p> + * @param int $expiry [optional] <p> + * The expiry time to set on the item. + * </p> + * @return int new item's value on success or <b>FALSE</b> on failure. + */ + public function incrementByKey ($server_key, $key, $offset = 1, $initial_value = 0, $expiry = 0) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Decrement numeric item's value, stored on a specific server + * @link https://php.net/manual/en/memcached.decrementbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @param string $key <p> + * The key of the item to decrement. + * </p> + * @param int $offset [optional] <p> + * The amount by which to decrement the item's value. + * </p> + * @param int $initial_value [optional] <p> + * The value to set the item to if it doesn't currently exist. + * </p> + * @param int $expiry [optional] <p> + * The expiry time to set on the item. + * </p> + * @return int item's new value on success or <b>FALSE</b> on failure. + */ + public function decrementByKey ($server_key, $key, $offset = 1, $initial_value = 0, $expiry = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Add a server to the server pool + * @link https://php.net/manual/en/memcached.addserver.php + * @param string $host <p> + * The hostname of the memcache server. If the hostname is invalid, data-related + * operations will set + * <b>Memcached::RES_HOST_LOOKUP_FAILURE</b> result code. + * </p> + * @param int $port <p> + * The port on which memcache is running. Usually, this is + * 11211. + * </p> + * @param int $weight [optional] <p> + * The weight of the server relative to the total weight of all the + * servers in the pool. This controls the probability of the server being + * selected for operations. This is used only with consistent distribution + * option and usually corresponds to the amount of memory available to + * memcache on that server. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function addServer ($host, $port, $weight = 0) {} + + /** + * (PECL memcached >= 0.1.1)<br/> + * Add multiple servers to the server pool + * @link https://php.net/manual/en/memcached.addservers.php + * @param array $servers + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function addServers (array $servers) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Get the list of the servers in the pool + * @link https://php.net/manual/en/memcached.getserverlist.php + * @return array The list of all servers in the server pool. + */ + public function getServerList () {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Map a key to a server + * @link https://php.net/manual/en/memcached.getserverbykey.php + * @param string $server_key <p> + * The key identifying the server to store the value on or retrieve it from. Instead of hashing on the actual key for the item, we hash on the server key when deciding which memcached server to talk to. This allows related items to be grouped together on a single server for efficiency with multi operations. + * </p> + * @return array an array containing three keys of host, + * port, and weight on success or <b>FALSE</b> + * on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function getServerByKey ($server_key) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Clears all servers from the server list + * @link https://php.net/manual/en/memcached.resetserverlist.php + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function resetServerList () {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Close any open connections + * @link https://php.net/manual/en/memcached.quit.php + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function quit () {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Get server pool statistics + * @link https://php.net/manual/en/memcached.getstats.php + * @param string $type + * @return array Array of server statistics, one entry per server. + */ + public function getStats ($type = null) {} + + /** + * (PECL memcached >= 0.1.5)<br/> + * Get server pool version info + * @link https://php.net/manual/en/memcached.getversion.php + * @return array Array of server versions, one entry per server. + */ + public function getVersion () {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Gets the keys stored on all the servers + * @link https://php.net/manual/en/memcached.getallkeys.php + * @return array the keys stored on all the servers on success or <b>FALSE</b> on failure. + */ + public function getAllKeys () {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Invalidate all items in the cache + * @link https://php.net/manual/en/memcached.flush.php + * @param int $delay [optional] <p> + * Numer of seconds to wait before invalidating the items. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + * Use <b>Memcached::getResultCode</b> if necessary. + */ + public function flush ($delay = 0) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Retrieve a Memcached option value + * @link https://php.net/manual/en/memcached.getoption.php + * @param int $option <p> + * One of the Memcached::OPT_* constants. + * </p> + * @return mixed the value of the requested option, or <b>FALSE</b> on + * error. + */ + public function getOption ($option) {} + + /** + * (PECL memcached >= 0.1.0)<br/> + * Set a Memcached option + * @link https://php.net/manual/en/memcached.setoption.php + * @param int $option + * @param mixed $value + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function setOption ($option, $value) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Set Memcached options + * @link https://php.net/manual/en/memcached.setoptions.php + * @param array $options <p> + * An associative array of options where the key is the option to set and + * the value is the new value for the option. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function setOptions (array $options) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Set the credentials to use for authentication + * @link https://secure.php.net/manual/en/memcached.setsaslauthdata.php + * @param string $username <p> + * The username to use for authentication. + * </p> + * @param string $password <p> + * The password to use for authentication. + * </p> + * @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure. + */ + public function setSaslAuthData (string $username , string $password) {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Check if a persitent connection to memcache is being used + * @link https://php.net/manual/en/memcached.ispersistent.php + * @return bool true if Memcache instance uses a persistent connection, false otherwise. + */ + public function isPersistent () {} + + /** + * (PECL memcached >= 2.0.0)<br/> + * Check if the instance was recently created + * @link https://php.net/manual/en/memcached.ispristine.php + * @return bool the true if instance is recently created, false otherwise. + */ + public function isPristine () {} + + public function flushBuffers () {} + + public function setEncodingKey ( $key ) {} + + public function getLastDisconnectedServer () {} + + public function getLastErrorErrno () {} + + public function getLastErrorCode () {} + + public function getLastErrorMessage () {} + + public function setBucket (array $host_map, array $forward_map, $replicas) {} + +} + +/** + * @link https://php.net/manual/en/class.memcachedexception.php + */ +class MemcachedException extends RuntimeException { + +} +// End of memcached v.3.0.4 +?> diff --git a/tests/Utils/Stubs/predis.php b/tests/Utils/Stubs/predis.php new file mode 100644 index 0000000000000000000000000000000000000000..de29405ba26ac3bd745bb86f2d353c90931df5e9 --- /dev/null +++ b/tests/Utils/Stubs/predis.php @@ -0,0 +1,299 @@ +<?php + +namespace Predis; + +/** + * Client class used for connecting and executing commands on Redis. + * + * This is the main high-level abstraction of Predis upon which various other + * abstractions are built. Internally it aggregates various other classes each + * one with its own responsibility and scope. + * + * {@inheritdoc} + * + * @author Daniele Alessandri <suppakilla@gmail.com> + */ +class Client +{ + /** + * @param mixed $parameters Connection parameters for one or more servers. + * @param mixed $options Options to configure some behaviours of the client. + */ + public function __construct($parameters = null, $options = null) + { + } + + /** + * Creates a new instance of Predis\Configuration\Options from different + * types of arguments or simply returns the passed argument if it is an + * instance of Predis\Configuration\OptionsInterface. + * + * @param mixed $options Client options. + * + * @throws \InvalidArgumentException + * + * @return OptionsInterface + */ + protected function createOptions($options) + { + } + + /** + * Creates single or aggregate connections from different types of arguments + * (string, array) or returns the passed argument if it is an instance of a + * class implementing Predis\Connection\ConnectionInterface. + * + * Accepted types for connection parameters are: + * + * - Instance of Predis\Connection\ConnectionInterface. + * - Instance of Predis\Connection\ParametersInterface. + * - Array + * - String + * - Callable + * + * @param mixed $parameters Connection parameters or connection instance. + * + * @throws \InvalidArgumentException + * + * @return ConnectionInterface + */ + protected function createConnection($parameters) + { + } + + /** + * Wraps a callable to make sure that its returned value represents a valid + * connection type. + * + * @param mixed $callable + * + * @return \Closure + */ + protected function getConnectionInitializerWrapper($callable) + { + } + + /** + * {@inheritdoc} + */ + public function getProfile() + { + } + + /** + * {@inheritdoc} + */ + public function getOptions() + { + } + + /** + * Creates a new client instance for the specified connection ID or alias, + * only when working with an aggregate connection (cluster, replication). + * The new client instances uses the same options of the original one. + * + * @param string $connectionID Identifier of a connection. + * + * @throws \InvalidArgumentException + * + * @return Client + */ + public function getClientFor($connectionID) + { + } + + /** + * Opens the underlying connection and connects to the server. + */ + public function connect() + { + } + + /** + * Closes the underlying connection and disconnects from the server. + */ + public function disconnect() + { + } + + /** + * Closes the underlying connection and disconnects from the server. + * + * This is the same as `Client::disconnect()` as it does not actually send + * the `QUIT` command to Redis, but simply closes the connection. + */ + public function quit() + { + } + + /** + * Returns the current state of the underlying connection. + * + * @return bool + */ + public function isConnected() + { + } + + /** + * {@inheritdoc} + */ + public function getConnection() + { + } + + /** + * Retrieves the specified connection from the aggregate connection when the + * client is in cluster or replication mode. + * + * @param string $connectionID Index or alias of the single connection. + * + * @throws NotSupportedException + * + * @return Connection\NodeConnectionInterface + */ + public function getConnectionById($connectionID) + { + } + + /** + * Executes a command without filtering its arguments, parsing the response, + * applying any prefix to keys or throwing exceptions on Redis errors even + * regardless of client options. + * + * It is possible to identify Redis error responses from normal responses + * using the second optional argument which is populated by reference. + * + * @param array $arguments Command arguments as defined by the command signature. + * @param bool $error Set to TRUE when Redis returned an error response. + * + * @return mixed + */ + public function executeRaw(array $arguments, &$error = null) + { + } + + /** + * {@inheritdoc} + */ + public function __call($commandID, $arguments) + { + } + + /** + * {@inheritdoc} + */ + public function createCommand($commandID, $arguments = array()) + { + } + + /** + * {@inheritdoc} + */ + public function executeCommand(CommandInterface $command) + { + } + + /** + * Handles -ERR responses returned by Redis. + * + * @param CommandInterface $command Redis command that generated the error. + * @param ErrorResponseInterface $response Instance of the error response. + * + * @throws ServerException + * + * @return mixed + */ + protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $response) + { + } + + /** + * Creates a new pipeline context and returns it, or returns the results of + * a pipeline executed inside the optionally provided callable object. + * + * @param mixed ... Array of options, a callable for execution, or both. + * + * @return Pipeline|array + */ + public function pipeline(/* arguments */) + { + } + + /** + * Actual pipeline context initializer method. + * + * @param array $options Options for the context. + * @param mixed $callable Optional callable used to execute the context. + * + * @return Pipeline|array + */ + protected function createPipeline(array $options = null, $callable = null) + { + } + + /** + * Creates a new transaction context and returns it, or returns the results + * of a transaction executed inside the optionally provided callable object. + * + * @param mixed ... Array of options, a callable for execution, or both. + * + * @return MultiExecTransaction|array + */ + public function transaction(/* arguments */) + { + } + + /** + * Actual transaction context initializer method. + * + * @param array $options Options for the context. + * @param mixed $callable Optional callable used to execute the context. + * + * @return MultiExecTransaction|array + */ + protected function createTransaction(array $options = null, $callable = null) + { + } + + /** + * Creates a new publish/subscribe context and returns it, or starts its loop + * inside the optionally provided callable object. + * + * @param mixed ... Array of options, a callable for execution, or both. + * + * @return PubSubConsumer|null + */ + public function pubSubLoop(/* arguments */) + { + } + + /** + * Actual publish/subscribe context initializer method. + * + * @param array $options Options for the context. + * @param mixed $callable Optional callable used to execute the context. + * + * @return PubSubConsumer|null + */ + protected function createPubSub(array $options = null, $callable = null) + { + } + + /** + * Creates a new monitor consumer and returns it. + * + * @return MonitorConsumer + */ + public function monitor() + { + } + + /** + * {@inheritdoc} + */ + public function getIterator() + { + } +} +