From e8bec89e3b3f8eae16fb160f914dc081e87d7229 Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Sat, 15 Feb 2020 17:19:29 +0100 Subject: [PATCH] Fix phpcs + rebase issue --- lib/SimpleSAML/Auth/ProcessingFilter.php | 2 +- lib/SimpleSAML/Auth/State.php | 2 +- lib/SimpleSAML/Configuration.php | 4 +- lib/SimpleSAML/Database.php | 6 +- lib/SimpleSAML/Error/ErrorCodes.php | 2 +- .../Error/UnserializableException.php | 2 +- lib/SimpleSAML/HTTP/RunnableResponse.php | 6 +- lib/SimpleSAML/IdP.php | 36 +++++----- lib/SimpleSAML/IdP/IFrameLogoutHandler.php | 2 +- lib/SimpleSAML/Locale/Localization.php | 2 +- lib/SimpleSAML/Logger.php | 30 ++++---- .../Logger/ErrorLogLoggingHandler.php | 4 +- lib/SimpleSAML/Logger/FileLoggingHandler.php | 4 +- .../Logger/LoggingHandlerInterface.php | 4 +- .../Logger/SyslogLoggingHandler.php | 4 +- lib/SimpleSAML/Memcache.php | 6 +- lib/SimpleSAML/Metadata/Sources/MDQ.php | 43 ++--------- lib/SimpleSAML/Module.php | 8 +-- lib/SimpleSAML/Session.php | 32 ++++----- lib/SimpleSAML/SessionHandler.php | 20 +++--- lib/SimpleSAML/SessionHandlerCookie.php | 6 +- lib/SimpleSAML/SessionHandlerPHP.php | 14 ++-- lib/SimpleSAML/SessionHandlerStore.php | 2 +- lib/SimpleSAML/Stats.php | 2 +- lib/SimpleSAML/Stats/Output.php | 2 +- lib/SimpleSAML/Store.php | 6 +- lib/SimpleSAML/Utils/Arrays.php | 2 +- lib/SimpleSAML/Utils/Attributes.php | 4 +- lib/SimpleSAML/Utils/Auth.php | 8 +-- lib/SimpleSAML/Utils/ClearableState.php | 2 +- lib/SimpleSAML/Utils/Config.php | 6 +- lib/SimpleSAML/Utils/Config/Metadata.php | 8 +-- lib/SimpleSAML/Utils/HttpAdapter.php | 72 ++++++++++++------- lib/SimpleSAML/Utils/Net.php | 2 +- lib/SimpleSAML/Utils/Random.php | 2 +- lib/SimpleSAML/Utils/Time.php | 6 +- lib/SimpleSAML/Utils/XML.php | 14 ++-- lib/SimpleSAML/XHTML/Template.php | 2 +- .../XHTML/TemplateControllerInterface.php | 4 +- lib/SimpleSAML/XHTML/TemplateLoader.php | 4 +- lib/SimpleSAML/XML/Parser.php | 8 +-- modules/core/lib/Auth/UserPassOrgBase.php | 2 +- modules/core/lib/Stats/Output/File.php | 2 +- modules/core/lib/Stats/Output/Log.php | 2 +- .../multiauth/lib/Auth/Source/MultiAuth.php | 4 +- modules/saml/lib/Auth/Source/SP.php | 6 +- modules/saml/lib/Error.php | 2 +- 47 files changed, 204 insertions(+), 209 deletions(-) diff --git a/lib/SimpleSAML/Auth/ProcessingFilter.php b/lib/SimpleSAML/Auth/ProcessingFilter.php index 464633d82..8e0e4db7f 100644 --- a/lib/SimpleSAML/Auth/ProcessingFilter.php +++ b/lib/SimpleSAML/Auth/ProcessingFilter.php @@ -67,5 +67,5 @@ abstract class ProcessingFilter * @param array &$request The request we are currently processing. * @return void */ - abstract public function process(array &$request) : void; + abstract public function process(array &$request): void; } diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php index 9d1f568c8..7293c30e3 100644 --- a/lib/SimpleSAML/Auth/State.php +++ b/lib/SimpleSAML/Auth/State.php @@ -200,7 +200,7 @@ class State * * @return string Identifier which can be used to retrieve the state later. */ - public static function saveState(array &$state, string $stage, bool $rawId = false) : string + public static function saveState(array &$state, string $stage, bool $rawId = false): string { $return = self::getStateId($state, $rawId); $id = $state[self::ID]; diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index e2ce8c5e4..7cf763f94 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -190,7 +190,7 @@ class Configuration implements Utils\ClearableState * @param string $configSet The configuration set. Defaults to 'simplesaml'. * @return void */ - public static function setConfigDir(string $path, string $configSet = 'simplesaml') : void + public static function setConfigDir(string $path, string $configSet = 'simplesaml'): void { self::$configDirs[$configSet] = $path; } @@ -323,7 +323,7 @@ class Configuration implements Utils\ClearableState * * @throws \Exception If the configuration with $instancename name is not initialized. */ - public static function getInstance(string $instancename = 'simplesaml') : Configuration + public static function getInstance(string $instancename = 'simplesaml'): Configuration { // check if the instance exists already if (array_key_exists($instancename, self::$instance)) { diff --git a/lib/SimpleSAML/Database.php b/lib/SimpleSAML/Database.php index cfa21d955..c0a5dcf3d 100644 --- a/lib/SimpleSAML/Database.php +++ b/lib/SimpleSAML/Database.php @@ -58,7 +58,7 @@ class Database * * @return \SimpleSAML\Database The shared database connection. */ - public static function getInstance(Configuration $altConfig = null) : Database + public static function getInstance(Configuration $altConfig = null): Database { $config = ($altConfig) ? $altConfig : Configuration::getInstance(); $instanceId = self::generateInstanceId($config); @@ -184,7 +184,7 @@ class Database * * @return string Table with configured prefix */ - public function applyPrefix(string $table) : string + public function applyPrefix(string $table): string { return $this->tablePrefix . $table; } @@ -284,7 +284,7 @@ class Database * * @return array The array with error information. */ - public function getLastError() : array + public function getLastError(): array { return $this->lastError; } diff --git a/lib/SimpleSAML/Error/ErrorCodes.php b/lib/SimpleSAML/Error/ErrorCodes.php index e62393dc1..e05d8c6cf 100644 --- a/lib/SimpleSAML/Error/ErrorCodes.php +++ b/lib/SimpleSAML/Error/ErrorCodes.php @@ -20,7 +20,7 @@ class ErrorCodes * * @return array A map from error code to error code title */ - final public static function defaultGetAllErrorCodeTitles() : array + final public static function defaultGetAllErrorCodeTitles(): array { return [ 'ACSPARAMS' => Translate::noop('{errors:title_ACSPARAMS}'), diff --git a/lib/SimpleSAML/Error/UnserializableException.php b/lib/SimpleSAML/Error/UnserializableException.php index 1b762c7f6..971d906a3 100644 --- a/lib/SimpleSAML/Error/UnserializableException.php +++ b/lib/SimpleSAML/Error/UnserializableException.php @@ -56,7 +56,7 @@ class UnserializableException extends Exception * * @return string The classname. */ - public function getClass() : string + public function getClass(): string { return $this->class; } diff --git a/lib/SimpleSAML/HTTP/RunnableResponse.php b/lib/SimpleSAML/HTTP/RunnableResponse.php index cd1523fd0..d8fae69c8 100644 --- a/lib/SimpleSAML/HTTP/RunnableResponse.php +++ b/lib/SimpleSAML/HTTP/RunnableResponse.php @@ -43,7 +43,7 @@ class RunnableResponse extends Response * * @return callable */ - public function getCallable() : callable + public function getCallable(): callable { return $this->callable; } @@ -54,7 +54,7 @@ class RunnableResponse extends Response * * @return array */ - public function getArguments() : array + public function getArguments(): array { return $this->arguments; } @@ -65,7 +65,7 @@ class RunnableResponse extends Response * * @return self */ - public function send() + public function send(): object { return call_user_func_array($this->callable, $this->arguments); } diff --git a/lib/SimpleSAML/IdP.php b/lib/SimpleSAML/IdP.php index f509bbf8e..7eebc6ecb 100644 --- a/lib/SimpleSAML/IdP.php +++ b/lib/SimpleSAML/IdP.php @@ -114,7 +114,7 @@ class IdP * * @return string The ID of this IdP. */ - public function getId() : string + public function getId(): string { return $this->id; } @@ -127,7 +127,7 @@ class IdP * * @return \SimpleSAML\IdP The IdP. */ - public static function getById(string $id) : IdP + public static function getById(string $id): IdP { if (isset(self::$idpCache[$id])) { return self::$idpCache[$id]; @@ -146,7 +146,7 @@ class IdP * * @return \SimpleSAML\IdP The IdP. */ - public static function getByState(array &$state) : IdP + public static function getByState(array &$state): IdP { Assert::notNull($state['core:IdP']); @@ -159,7 +159,7 @@ class IdP * * @return Configuration The configuration object. */ - public function getConfig() : Configuration + public function getConfig(): Configuration { return $this->config; } @@ -172,7 +172,7 @@ class IdP * * @return array|null The name of the SP, as an associative array of language => text, or null if this isn't an SP. */ - public function getSPName(string $assocId) : ?array + public function getSPName(string $assocId): ?array { $prefix = substr($assocId, 0, 4); $spEntityId = substr($assocId, strlen($prefix) + 1); @@ -208,7 +208,7 @@ class IdP * @param array $association The SP association. * @return void */ - public function addAssociation(array $association) : void + public function addAssociation(array $association): void { Assert::notNull($association['id']); Assert::notNull($association['Handler']); @@ -225,7 +225,7 @@ class IdP * * @return array List of SP associations. */ - public function getAssociations() : array + public function getAssociations(): array { $session = Session::getSessionFromRequest(); return $session->getAssociations($this->associationGroup); @@ -238,7 +238,7 @@ class IdP * @param string $assocId The association id. * @return void */ - public function terminateAssociation(string $assocId) : void + public function terminateAssociation(string $assocId): void { $session = Session::getSessionFromRequest(); $session->terminateAssociation($this->associationGroup, $assocId); @@ -250,7 +250,7 @@ class IdP * * @return boolean True if the user is authenticated, false otherwise. */ - public function isAuthenticated() : bool + public function isAuthenticated(): bool { return $this->authSource->isAuthenticated(); } @@ -262,7 +262,7 @@ class IdP * @param array $state The authentication request state array. * @return void */ - public static function postAuthProc(array $state) : void + public static function postAuthProc(array $state): void { Assert::isCallable($state['Responder']); @@ -289,7 +289,7 @@ class IdP * @throws \SimpleSAML\Error\Exception If we are not authenticated. * @return void */ - public static function postAuth(array $state) : void + public static function postAuth(array $state): void { $idp = IdP::getByState($state); @@ -337,7 +337,7 @@ class IdP * @throws \SimpleSAML\Module\saml\Error\NoPassive If we were asked to do passive authentication. * @return void */ - private function authenticate(array &$state) : void + private function authenticate(array &$state): void { if (isset($state['isPassive']) && (bool) $state['isPassive']) { throw new NoPassive(Constants::STATUS_RESPONDER, 'Passive authentication not supported.'); @@ -360,7 +360,7 @@ class IdP * @throws \Exception If there is no auth source defined for this IdP. * @return void */ - private function reauthenticate(array &$state) : void + private function reauthenticate(array &$state): void { $sourceImpl = $this->authSource->getAuthSource(); $sourceImpl->reauthenticate($state); @@ -373,7 +373,7 @@ class IdP * @param array &$state The authentication request state. * @return void */ - public function handleAuthenticationRequest(array &$state) : void + public function handleAuthenticationRequest(array &$state): void { Assert::notNull($state['Responder']); @@ -423,7 +423,7 @@ class IdP * * @throws \Exception If we cannot find a logout handler. */ - public function getLogoutHandler() : LogoutHandlerInterface + public function getLogoutHandler(): LogoutHandlerInterface { // find the logout handler $logouttype = $this->getConfig()->getString('logouttype', 'traditional'); @@ -451,7 +451,7 @@ class IdP * @param array &$state The logout request state. * @return void */ - public function finishLogout(array &$state) : void + public function finishLogout(array &$state): void { Assert::notNull($state['Responder']); @@ -471,7 +471,7 @@ class IdP * association. * @return void */ - public function handleLogoutRequest(array &$state, ?string $assocId) : void + public function handleLogoutRequest(array &$state, ?string $assocId): void { Assert::notNull($state['Responder']); Assert::nullOrString($assocId); @@ -553,7 +553,7 @@ class IdP * @param array &$state The logout state from doLogoutRedirect(). * @return void */ - public static function finishLogoutRedirect(IdP $idp, array $state) : void + public static function finishLogoutRedirect(IdP $idp, array $state): void { Assert::notNull($state['core:Logout:URL']); diff --git a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php index 17c789d58..627fea7d0 100644 --- a/lib/SimpleSAML/IdP/IFrameLogoutHandler.php +++ b/lib/SimpleSAML/IdP/IFrameLogoutHandler.php @@ -45,7 +45,7 @@ class IFrameLogoutHandler implements LogoutHandlerInterface * @param string|null $assocId The SP we are logging out from. * @return void */ - public function startLogout(array &$state, ?string $assocId) : void + public function startLogout(array &$state, ?string $assocId): void { $associations = $this->idp->getAssociations(); diff --git a/lib/SimpleSAML/Locale/Localization.php b/lib/SimpleSAML/Locale/Localization.php index 03b8a6d83..411116441 100644 --- a/lib/SimpleSAML/Locale/Localization.php +++ b/lib/SimpleSAML/Locale/Localization.php @@ -243,7 +243,7 @@ class Localization */ private function loadGettextGettextFromPO( string $domain = self::DEFAULT_DOMAIN, - bool $catchException = true + bool $catchException = true ): void { try { $langPath = $this->getLangPath($domain); diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index a62a73b83..0142a21f1 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -164,7 +164,7 @@ class Logger * @param string $string The message to log. * @return void */ - public static function emergency(string $string) : void + public static function emergency(string $string): void { self::log(self::EMERG, $string); } @@ -176,7 +176,7 @@ class Logger * @param string $string The message to log. * @return void */ - public static function critical(string $string) : void + public static function critical(string $string): void { self::log(self::CRIT, $string); } @@ -188,7 +188,7 @@ class Logger * @param string $string The message to log. * @return void */ - public static function alert(string $string) : void + public static function alert(string $string): void { self::log(self::ALERT, $string); } @@ -200,7 +200,7 @@ class Logger * @param string $string The message to log. * @return void */ - public static function error(string $string) : void + public static function error(string $string): void { self::log(self::ERR, $string); } @@ -212,7 +212,7 @@ class Logger * @param string $string The message to log. * @return void */ - public static function warning(string $string) : void + public static function warning(string $string): void { self::log(self::WARNING, $string); } @@ -224,7 +224,7 @@ class Logger * @param string $string The message to log. * @return void */ - public static function notice(string $string) : void + public static function notice(string $string): void { self::log(self::NOTICE, $string); } @@ -236,7 +236,7 @@ class Logger * @param string $string The message to log. * @return void */ - public static function info(string $string) : void + public static function info(string $string): void { self::log(self::INFO, $string); } @@ -249,7 +249,7 @@ class Logger * @param string $string The message to log. * @return void */ - public static function debug(string $string) : void + public static function debug(string $string): void { self::log(self::DEBUG, $string); } @@ -261,7 +261,7 @@ class Logger * @param string $string The message to log. * @return void */ - public static function stats(string $string) : void + public static function stats(string $string): void { self::log(self::NOTICE, $string, true); } @@ -273,7 +273,7 @@ class Logger * @param boolean $val Whether to capture logs or not. Defaults to TRUE. * @return void */ - public static function setCaptureLog(bool $val = true) : void + public static function setCaptureLog(bool $val = true): void { self::$captureLog = $val; } @@ -283,7 +283,7 @@ class Logger * Get the captured log. * @return array */ - public static function getCapturedLog() : array + public static function getCapturedLog(): array { return self::$capturedLog; } @@ -295,7 +295,7 @@ class Logger * @param string $trackId The track identifier to use during this session. * @return void */ - public static function setTrackId(string $trackId) : void + public static function setTrackId(string $trackId): void { self::$trackid = $trackId; self::flush(); @@ -324,7 +324,7 @@ class Logger * * @return void */ - public static function shutdown() : void + public static function shutdown(): void { if (self::$trackid === self::NO_TRACKID) { try { @@ -347,7 +347,7 @@ class Logger * * @return bool True if the error is masked, false otherwise. */ - public static function isErrorMasked(int $errno) : bool + public static function isErrorMasked(int $errno): bool { return ($errno & self::$logMask) || !($errno & error_reporting()); } @@ -361,7 +361,7 @@ class Logger * @param int $mask The log levels that should be masked. * @return void */ - public static function maskErrors(int $mask) : void + public static function maskErrors(int $mask): void { $currentEnabled = error_reporting(); self::$logLevelStack[] = [$currentEnabled, self::$logMask]; diff --git a/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php b/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php index 0fdbdeddf..4806dab9b 100644 --- a/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php +++ b/lib/SimpleSAML/Logger/ErrorLogLoggingHandler.php @@ -58,7 +58,7 @@ class ErrorLogLoggingHandler implements LoggingHandlerInterface * @param string $format The format used for logs. * @return void */ - public function setLogFormat(string $format) : void + public function setLogFormat(string $format): void { // we don't need the format here } @@ -71,7 +71,7 @@ class ErrorLogLoggingHandler implements LoggingHandlerInterface * @param string $string The formatted message to log. * @return void */ - public function log(int $level, string $string) : void + public function log(int $level, string $string): void { if (array_key_exists($level, self::$levelNames)) { $levelName = self::$levelNames[$level]; diff --git a/lib/SimpleSAML/Logger/FileLoggingHandler.php b/lib/SimpleSAML/Logger/FileLoggingHandler.php index 659b06b86..9f912b1a8 100644 --- a/lib/SimpleSAML/Logger/FileLoggingHandler.php +++ b/lib/SimpleSAML/Logger/FileLoggingHandler.php @@ -82,7 +82,7 @@ class FileLoggingHandler implements LoggingHandlerInterface * @param string $format The format used for logs. * @return void */ - public function setLogFormat(string $format) : void + public function setLogFormat(string $format): void { $this->format = $format; } @@ -95,7 +95,7 @@ class FileLoggingHandler implements LoggingHandlerInterface * @param string $string The formatted message to log. * @return void */ - public function log(int $level, string $string) : void + public function log(int $level, string $string): void { if (!is_null($this->logFile)) { // set human-readable log level. Copied from SimpleSAML\Logger\ErrorLogLoggingHandler. diff --git a/lib/SimpleSAML/Logger/LoggingHandlerInterface.php b/lib/SimpleSAML/Logger/LoggingHandlerInterface.php index 16585d6a6..7dbb7789b 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerInterface.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerInterface.php @@ -30,7 +30,7 @@ interface LoggingHandlerInterface * @param string $string The message to log. * @return void */ - public function log(int $level, string $string) : void; + public function log(int $level, string $string): void; /** @@ -39,5 +39,5 @@ interface LoggingHandlerInterface * @param string $format The format used for logs. * @return void */ - public function setLogFormat(string $format) : void; + public function setLogFormat(string $format): void; } diff --git a/lib/SimpleSAML/Logger/SyslogLoggingHandler.php b/lib/SimpleSAML/Logger/SyslogLoggingHandler.php index 57ad7d340..bba5e48e7 100644 --- a/lib/SimpleSAML/Logger/SyslogLoggingHandler.php +++ b/lib/SimpleSAML/Logger/SyslogLoggingHandler.php @@ -49,7 +49,7 @@ class SyslogLoggingHandler implements LoggingHandlerInterface * @param string $format The format used for logs. * @return void */ - public function setLogFormat(string $format) : void + public function setLogFormat(string $format): void { $this->format = $format; } @@ -62,7 +62,7 @@ class SyslogLoggingHandler implements LoggingHandlerInterface * @param string $string The formatted message to log. * @return void */ - public function log(int $level, string $string) : void + public function log(int $level, string $string): void { // changing log level to supported levels if OS is Windows if ($this->isWindows) { diff --git a/lib/SimpleSAML/Memcache.php b/lib/SimpleSAML/Memcache.php index e9a23c904..ac5085e54 100644 --- a/lib/SimpleSAML/Memcache.php +++ b/lib/SimpleSAML/Memcache.php @@ -154,7 +154,7 @@ class Memcache * @param integer|null $expire The expiration timestamp of the data. * @return void */ - public static function set(string $key, $value, ?int $expire = null) : void + public static function set(string $key, $value, ?int $expire = null): void { Logger::debug("saving key $key to memcache"); $savedInfo = [ @@ -443,7 +443,7 @@ class Memcache * * @throws \Exception If memcache server status couldn't be retrieved. */ - public static function getStats() : array + public static function getStats(): array { $ret = []; @@ -470,7 +470,7 @@ class Memcache * * @return array An array with the extended stats output for each server group. */ - public static function getRawStats() : array + public static function getRawStats(): array { $ret = []; diff --git a/lib/SimpleSAML/Metadata/Sources/MDQ.php b/lib/SimpleSAML/Metadata/Sources/MDQ.php index 513cbeb40..1b388c3ac 100644 --- a/lib/SimpleSAML/Metadata/Sources/MDQ.php +++ b/lib/SimpleSAML/Metadata/Sources/MDQ.php @@ -63,11 +63,6 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource */ protected function __construct(array $config) { -<<<<<<< HEAD - Assert::isArray($config); - -======= ->>>>>>> Fully typehint lib/Metadata/*.php if (!array_key_exists('server', $config)) { throw new \Exception(__CLASS__ . ": the 'server' configuration option is not set."); } else { @@ -96,7 +91,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource * * @return array An empty array. */ - public function getMetadataSet(string $set) : array + public function getMetadataSet(string $set): array { // we don't have this metadata set return []; @@ -111,14 +106,8 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource * * @return string The full path to the cache file. */ - private function getCacheFilename(string $set, string $entityId) : string + private function getCacheFilename(string $set, string $entityId): string { -<<<<<<< HEAD - Assert::string($set); - Assert::string($entityId); - -======= ->>>>>>> Fully typehint lib/Metadata/*.php if ($this->cacheDir === null) { throw new Error\ConfigurationError("Missing cache directory configuration."); } @@ -138,11 +127,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource * if the entity could not be found. * @throws \Exception If an error occurs while loading metadata from cache. */ -<<<<<<< HEAD - private function getFromCache(string $set, string $entityId) -======= - private function getFromCache(string $set, string $entityId) : ?array ->>>>>>> Fully typehint lib/Metadata/*.php + private function getFromCache(string $set, string $entityId): ?array { if (empty($this->cacheDir)) { return null; @@ -199,11 +184,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource * @throws \Exception If metadata cannot be written to cache. * @return void */ -<<<<<<< HEAD - private function writeToCache(string $set, string $entityId, array $data) -======= - private function writeToCache(string $set, string $entityId, array $data) : void ->>>>>>> Fully typehint lib/Metadata/*.php + private function writeToCache(string $set, string $entityId, array $data): void { if (empty($this->cacheDir)) { return; @@ -227,11 +208,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource * @return array|NULL The associative array with the metadata, or NULL if no metadata for * the given set was found. */ -<<<<<<< HEAD - private static function getParsedSet(SAMLParser $entity, string $set) -======= - private static function getParsedSet(SAMLParser $entity, string $set) : ?array ->>>>>>> Fully typehint lib/Metadata/*.php + private static function getParsedSet(SAMLParser $entity, string $set): ?array { switch ($set) { case 'saml20-idp-remote': @@ -268,14 +245,8 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource * @throws \Exception If an error occurs while validating the signature or the metadata is in an * incorrect set. */ - public function getMetaData(string $index, string $set) : ?array + public function getMetaData(string $index, string $set): ?array { -<<<<<<< HEAD - Assert::string($index); - Assert::string($set); - -======= ->>>>>>> Fully typehint lib/Metadata/*.php Logger::info(__CLASS__ . ': loading metadata entity [' . $index . '] from [' . $set . ']'); // read from cache if possible @@ -342,7 +313,7 @@ class MDQ extends \SimpleSAML\Metadata\MetaDataStorageSource * @param string $set The set we want to get metadata from. * @return array An associative array with the metadata for the requested entities, if found. */ - public function getMetaDataForEntities(array $entityIds, string $set) : array + public function getMetaDataForEntities(array $entityIds, string $set): array { return $this->getMetaDataForEntitiesIndividually($entityIds, $set); } diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php index d1d3b34f3..a2cbf2fe4 100644 --- a/lib/SimpleSAML/Module.php +++ b/lib/SimpleSAML/Module.php @@ -86,7 +86,7 @@ class Module * * @return string The base directory of a module. */ - public static function getModuleDir(string $module) : string + public static function getModuleDir(string $module): string { $baseDir = dirname(dirname(dirname(__FILE__))) . '/modules'; $moduleDir = $baseDir . '/' . $module; @@ -106,7 +106,7 @@ class Module * * @throws \Exception If module.enable is set and is not boolean. */ - public static function isModuleEnabled(string $module) : bool + public static function isModuleEnabled(string $module): bool { $config = Configuration::getOptionalConfig(); return self::isModuleEnabledWithConf($module, $config->getArray('module.enable', [])); @@ -374,7 +374,7 @@ class Module * * @throws \Exception If we cannot open the module's directory. */ - public static function getModules() : array + public static function getModules(): array { if (!empty(self::$modules)) { return self::$modules; @@ -590,7 +590,7 @@ class Module * @return \Symfony\Component\HttpFoundation\RedirectResponse * A redirection to the URI specified in the request, but without the trailing slash. */ - public static function removeTrailingSlash(Request $request) : RedirectResponse + public static function removeTrailingSlash(Request $request): RedirectResponse { $pathInfo = $request->server->get('PATH_INFO'); $url = str_replace($pathInfo, rtrim($pathInfo, ' /'), $request->getRequestUri()); diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 26cba31e3..00d57606f 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -191,7 +191,7 @@ class Session implements \Serializable, Utils\ClearableState * @param Configuration $config * @return void */ - public function setConfiguration(Configuration $config) : void + public function setConfiguration(Configuration $config): void { self::$config = $config; } @@ -204,7 +204,7 @@ class Session implements \Serializable, Utils\ClearableState * * @return string The serialized representation of this session object. */ - public function serialize() : string + public function serialize(): string { return serialize(get_object_vars($this)); } @@ -221,7 +221,7 @@ class Session implements \Serializable, Utils\ClearableState * * Cannot typehint param as string due to upstream restrictions */ - public function unserialize($serialized) : void + public function unserialize($serialized): void { $session = unserialize($serialized); if (is_array($session)) { @@ -254,7 +254,7 @@ class Session implements \Serializable, Utils\ClearableState * @return Session The current session. * @throws \Exception When session couldn't be initialized and the session fallback is disabled by configuration. */ - public static function getSessionFromRequest() : Session + public static function getSessionFromRequest(): Session { // check if we already have initialized the session if (isset(self::$instance)) { @@ -483,7 +483,7 @@ class Session implements \Serializable, Utils\ClearableState * * @return void */ - public function cleanup() : void + public function cleanup(): void { $this->save(); $sh = SessionHandler::getSessionHandler(); @@ -500,7 +500,7 @@ class Session implements \Serializable, Utils\ClearableState * * @return void */ - public function markDirty() : void + public function markDirty(): void { if ($this->isTransient()) { return; @@ -533,7 +533,7 @@ class Session implements \Serializable, Utils\ClearableState * * @return string|null The session ID, or NULL for transient sessions. */ - public function getSessionId() : ?string + public function getSessionId(): ?string { return $this->sessionId; } @@ -544,7 +544,7 @@ class Session implements \Serializable, Utils\ClearableState * * @return boolean The session transient flag. */ - public function isTransient() : bool + public function isTransient(): bool { return $this->transient; } @@ -556,7 +556,7 @@ class Session implements \Serializable, Utils\ClearableState * * @return string The unique ID. */ - public function getTrackID() : string + public function getTrackID(): string { return $this->trackid; } @@ -567,7 +567,7 @@ class Session implements \Serializable, Utils\ClearableState * * @return integer|null The remember me expire time. */ - public function getRememberMeExpire() : ?int + public function getRememberMeExpire(): ?int { return $this->rememberMeExpire; } @@ -579,7 +579,7 @@ class Session implements \Serializable, Utils\ClearableState * @param int $expire Unix timestamp when remember me session cookies expire. * @return void */ - public function setRememberMeExpire(int $expire = null) : void + public function setRememberMeExpire(int $expire = null): void { Assert::nullOrInteger($expire); @@ -699,7 +699,7 @@ class Session implements \Serializable, Utils\ClearableState * @param string $authority The authentication source we are logging out of. * @return void */ - public function doLogout(string $authority) : void + public function doLogout(string $authority): void { Logger::debug('Session: doLogout(' . var_export($authority, true) . ')'); @@ -840,7 +840,7 @@ class Session implements \Serializable, Utils\ClearableState * * @throws \Exception If the handler is not a valid function or method. */ - public function registerLogoutHandler(string $authority, string $classname, string $functionname) : void + public function registerLogoutHandler(string $authority, string $classname, string $functionname): void { Assert::notNull($this->authData[$authority]); @@ -939,7 +939,7 @@ class Session implements \Serializable, Utils\ClearableState * * @return void */ - private function expireData() : void + private function expireData(): void { $ct = time(); @@ -1040,7 +1040,7 @@ class Session implements \Serializable, Utils\ClearableState * * @return bool true if it was set, false if not. */ - public function hasSessionCookie() : bool + public function hasSessionCookie(): bool { $sh = SessionHandler::getSessionHandler(); return $sh->hasSessionCookie(); @@ -1173,7 +1173,7 @@ class Session implements \Serializable, Utils\ClearableState * Clear any configuration information cached * @return void */ - public static function clearInternalState() : void + public static function clearInternalState(): void { self::$config = null; self::$instance = null; diff --git a/lib/SimpleSAML/SessionHandler.php b/lib/SimpleSAML/SessionHandler.php index db0935990..4fdcb6dcf 100644 --- a/lib/SimpleSAML/SessionHandler.php +++ b/lib/SimpleSAML/SessionHandler.php @@ -37,7 +37,7 @@ abstract class SessionHandler * * @throws \Exception If we cannot instantiate the session handler. */ - public static function getSessionHandler() : SessionHandler + public static function getSessionHandler(): SessionHandler { if (self::$sessionHandler === null) { self::createSessionHandler(); @@ -62,7 +62,7 @@ abstract class SessionHandler * * @return string The new session id. */ - abstract public function newSessionId() : string; + abstract public function newSessionId(): string; /** @@ -70,7 +70,7 @@ abstract class SessionHandler * * @return string|null The session id saved in the cookie or null if no session cookie was set. */ - abstract public function getCookieSessionId() : ?string; + abstract public function getCookieSessionId(): ?string; /** @@ -78,7 +78,7 @@ abstract class SessionHandler * * @return string The session cookie name. */ - abstract public function getSessionCookieName() : string; + abstract public function getSessionCookieName(): string; /** @@ -87,7 +87,7 @@ abstract class SessionHandler * @param \SimpleSAML\Session $session The session object we should save. * @return void */ - abstract public function saveSession(Session $session) : void; + abstract public function saveSession(Session $session): void; /** @@ -97,7 +97,7 @@ abstract class SessionHandler * * @return \SimpleSAML\Session|null The session object, or null if it doesn't exist. */ - abstract public function loadSession(?string $sessionId) : ?Session; + abstract public function loadSession(?string $sessionId): ?Session; /** @@ -107,7 +107,7 @@ abstract class SessionHandler * * @return bool True if it was set, false if not. */ - abstract public function hasSessionCookie() : bool; + abstract public function hasSessionCookie(): bool; /** @@ -120,7 +120,7 @@ abstract class SessionHandler * * @throws \SimpleSAML\Error\CannotSetCookie If we can't set the cookie. */ - abstract public function setCookie(string $sessionName, ?string $sessionID, array $cookieParams = null) : void; + abstract public function setCookie(string $sessionName, ?string $sessionID, array $cookieParams = null): void; /** @@ -135,7 +135,7 @@ abstract class SessionHandler * * @throws \Exception If we cannot instantiate the session handler. */ - private static function createSessionHandler() : void + private static function createSessionHandler(): void { $store = Store::getInstance(); if ($store === false) { @@ -152,7 +152,7 @@ abstract class SessionHandler * @return array An array with the cookie parameters. * @link http://www.php.net/manual/en/function.session-get-cookie-params.php */ - public function getCookieParams() : array + public function getCookieParams(): array { $config = Configuration::getInstance(); diff --git a/lib/SimpleSAML/SessionHandlerCookie.php b/lib/SimpleSAML/SessionHandlerCookie.php index c66112fe6..e2d185490 100644 --- a/lib/SimpleSAML/SessionHandlerCookie.php +++ b/lib/SimpleSAML/SessionHandlerCookie.php @@ -55,7 +55,7 @@ abstract class SessionHandlerCookie extends SessionHandler * * @return string The new session id. */ - public function newSessionId() : string + public function newSessionId(): string { $this->session_id = self::createSessionID(); Session::createSession($this->session_id); @@ -69,7 +69,7 @@ abstract class SessionHandlerCookie extends SessionHandler * * @return string|null The session id saved in the cookie or null if no session cookie was set. */ - public function getCookieSessionId() : ?string + public function getCookieSessionId(): ?string { if ($this->session_id === null) { if ($this->hasSessionCookie()) { @@ -93,7 +93,7 @@ abstract class SessionHandlerCookie extends SessionHandler * * @return string The session cookie name. */ - public function getSessionCookieName() : string + public function getSessionCookieName(): string { return $this->cookie_name; } diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php index ec4257de8..fd59a25a7 100644 --- a/lib/SimpleSAML/SessionHandlerPHP.php +++ b/lib/SimpleSAML/SessionHandlerPHP.php @@ -123,7 +123,7 @@ class SessionHandlerPHP extends SessionHandler * * @return void */ - public function restorePrevious() : void + public function restorePrevious(): void { if (empty($this->previous_session)) { return; // nothing to do here @@ -162,7 +162,7 @@ class SessionHandlerPHP extends SessionHandler * * @return string The new session id. */ - public function newSessionId() : string + public function newSessionId(): string { // generate new (secure) session id if (function_exists('session_create_id')) { @@ -187,7 +187,7 @@ class SessionHandlerPHP extends SessionHandler * * @throws \SimpleSAML\Error\Exception If the cookie is marked as secure but we are not using HTTPS. */ - public function getCookieSessionId() : ?string + public function getCookieSessionId(): ?string { if (!$this->hasSessionCookie()) { return null; // there's no session cookie, can't return ID @@ -217,7 +217,7 @@ class SessionHandlerPHP extends SessionHandler * * @return string The session cookie name. */ - public function getSessionCookieName() : string + public function getSessionCookieName(): string { return $this->cookie_name; } @@ -284,7 +284,7 @@ class SessionHandlerPHP extends SessionHandler * * @return boolean True if it was set, false otherwise. */ - public function hasSessionCookie() : bool + public function hasSessionCookie(): bool { return array_key_exists($this->cookie_name, $_COOKIE); } @@ -301,7 +301,7 @@ class SessionHandlerPHP extends SessionHandler * @throws \SimpleSAML\Error\Exception If both 'session.phpsession.limitedpath' and 'session.cookie.path' options * are set at the same time in the configuration. */ - public function getCookieParams() : array + public function getCookieParams(): array { $config = Configuration::getInstance(); @@ -334,7 +334,7 @@ class SessionHandlerPHP extends SessionHandler * * @throws \SimpleSAML\Error\CannotSetCookie If we can't set the cookie. */ - public function setCookie(string $sessionName, ?string $sessionID, array $cookieParams = null) : void + public function setCookie(string $sessionName, ?string $sessionID, array $cookieParams = null): void { if ($cookieParams === null) { $cookieParams = session_get_cookie_params(); diff --git a/lib/SimpleSAML/SessionHandlerStore.php b/lib/SimpleSAML/SessionHandlerStore.php index b163a5bcc..4c565d7bc 100644 --- a/lib/SimpleSAML/SessionHandlerStore.php +++ b/lib/SimpleSAML/SessionHandlerStore.php @@ -68,7 +68,7 @@ class SessionHandlerStore extends SessionHandlerCookie * @param \SimpleSAML\Session $session The session object we should save. * @return void */ - public function saveSession(Session $session) : void + public function saveSession(Session $session): void { if ($session->isTransient()) { // transient session, nothing to save diff --git a/lib/SimpleSAML/Stats.php b/lib/SimpleSAML/Stats.php index f63b46d9b..0dd4f0c1e 100644 --- a/lib/SimpleSAML/Stats.php +++ b/lib/SimpleSAML/Stats.php @@ -54,7 +54,7 @@ class Stats * * @return void */ - private static function initOutputs() : void + private static function initOutputs(): void { $config = Configuration::getInstance(); $outputCfgs = $config->getArray('statistics.out', []); diff --git a/lib/SimpleSAML/Stats/Output.php b/lib/SimpleSAML/Stats/Output.php index 7ce4562e3..251bc63b0 100644 --- a/lib/SimpleSAML/Stats/Output.php +++ b/lib/SimpleSAML/Stats/Output.php @@ -31,5 +31,5 @@ abstract class Output * @param array $data The event. * @return void */ - abstract public function emit(array $data) : void; + abstract public function emit(array $data): void; } diff --git a/lib/SimpleSAML/Store.php b/lib/SimpleSAML/Store.php index 364521df4..3f2c35e27 100644 --- a/lib/SimpleSAML/Store.php +++ b/lib/SimpleSAML/Store.php @@ -94,7 +94,7 @@ abstract class Store implements Utils\ClearableState * @param int|null $expire The expiration time (unix timestamp), or null if it never expires. * @return void */ - abstract public function set(string $type, string $key, $value, ?int $expire = null) : void; + abstract public function set(string $type, string $key, $value, ?int $expire = null): void; /** @@ -104,14 +104,14 @@ abstract class Store implements Utils\ClearableState * @param string $key The key. * @return void */ - abstract public function delete(string $type, string $key) : void; + abstract public function delete(string $type, string $key): void; /** * Clear any SSP specific state, such as SSP environmental variables or cached internals. * @return void */ - public static function clearInternalState() : void + public static function clearInternalState(): void { self::$instance = null; } diff --git a/lib/SimpleSAML/Utils/Arrays.php b/lib/SimpleSAML/Utils/Arrays.php index 91e6518f1..f6b1fcf2d 100644 --- a/lib/SimpleSAML/Utils/Arrays.php +++ b/lib/SimpleSAML/Utils/Arrays.php @@ -23,7 +23,7 @@ class Arrays * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> */ - public static function arrayize($data, $index = 0) : array + public static function arrayize($data, $index = 0): array { return (is_array($data)) ? $data : [$index => $data]; } diff --git a/lib/SimpleSAML/Utils/Attributes.php b/lib/SimpleSAML/Utils/Attributes.php index b78811329..837a7e1d8 100644 --- a/lib/SimpleSAML/Utils/Attributes.php +++ b/lib/SimpleSAML/Utils/Attributes.php @@ -69,7 +69,7 @@ class Attributes * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> */ - public static function normalizeAttributesArray(array $attributes) : array + public static function normalizeAttributesArray(array $attributes): array { $newAttrs = []; foreach ($attributes as $name => $values) { @@ -106,7 +106,7 @@ class Attributes * * @return array The attribute name, split to the namespace and the actual attribute name. */ - public static function getAttributeNamespace(string $name, string $defaultns) : array + public static function getAttributeNamespace(string $name, string $defaultns): array { $slash = strrpos($name, '/'); if ($slash !== false) { diff --git a/lib/SimpleSAML/Utils/Auth.php b/lib/SimpleSAML/Utils/Auth.php index e0df2ea0a..cfbaccfe5 100644 --- a/lib/SimpleSAML/Utils/Auth.php +++ b/lib/SimpleSAML/Utils/Auth.php @@ -24,7 +24,7 @@ class Auth * @return string A URL which can be used for admin authentication. * @throws \InvalidArgumentException If $returnTo is neither a string nor null. */ - public static function getAdminLoginURL(?string $returnTo = null) : string + public static function getAdminLoginURL(?string $returnTo = null): string { if ($returnTo === null) { $returnTo = HTTP::getSelfURL(); @@ -42,7 +42,7 @@ class Auth * @return string A URL which can be used for logging out. * @throws \InvalidArgumentException If $returnTo is neither a string nor null. */ - public static function getAdminLogoutURL(?string $returnTo = null) : string + public static function getAdminLogoutURL(?string $returnTo = null): string { $as = new Authentication\Simple('admin'); return $as->getLogoutURL($returnTo = null); @@ -56,7 +56,7 @@ class Auth * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function isAdmin() : bool + public static function isAdmin(): bool { $session = Session::getSessionFromRequest(); return $session->isValid('admin') || $session->isValid('login-admin'); @@ -75,7 +75,7 @@ class Auth * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> */ - public static function requireAdmin() : void + public static function requireAdmin(): void { if (self::isAdmin()) { return; diff --git a/lib/SimpleSAML/Utils/ClearableState.php b/lib/SimpleSAML/Utils/ClearableState.php index 526037d5a..60fc07851 100644 --- a/lib/SimpleSAML/Utils/ClearableState.php +++ b/lib/SimpleSAML/Utils/ClearableState.php @@ -16,5 +16,5 @@ interface ClearableState * Clear any cached internal state. * @return void */ - public static function clearInternalState() : void; + public static function clearInternalState(): void; } diff --git a/lib/SimpleSAML/Utils/Config.php b/lib/SimpleSAML/Utils/Config.php index ea7ef1f77..4d7baf293 100644 --- a/lib/SimpleSAML/Utils/Config.php +++ b/lib/SimpleSAML/Utils/Config.php @@ -23,7 +23,7 @@ class Config * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function getCertPath(string $path) : string + public static function getCertPath(string $path): string { $globalConfig = Configuration::getInstance(); $base = $globalConfig->getPathValue('certdir', 'cert/'); @@ -46,7 +46,7 @@ class Config * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function getSecretSalt() : string + public static function getSecretSalt(): string { $secretSalt = Configuration::getInstance()->getString('secretsalt'); if ($secretSalt === 'defaultsecretsalt') { @@ -64,7 +64,7 @@ class Config * * @return string The path to the configuration directory. */ - public static function getConfigDir() : string + public static function getConfigDir(): string { $configDir = dirname(dirname(dirname(__DIR__))) . '/config'; $configDirEnv = getenv('SIMPLESAMLPHP_CONFIG_DIR'); diff --git a/lib/SimpleSAML/Utils/Config/Metadata.php b/lib/SimpleSAML/Utils/Config/Metadata.php index 2459d4310..c591ed1be 100644 --- a/lib/SimpleSAML/Utils/Config/Metadata.php +++ b/lib/SimpleSAML/Utils/Config/Metadata.php @@ -104,7 +104,7 @@ class Metadata * @throws \InvalidArgumentException If $contact is neither an array nor null, or the contact does not conform to * valid configuration rules for contacts. */ - public static function getContact(?array $contact) : array + public static function getContact(?array $contact): array { // check the type if (!isset($contact['contactType']) || !in_array($contact['contactType'], self::$VALID_CONTACT_TYPES, true)) { @@ -242,7 +242,7 @@ class Metadata * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function getDefaultEndpoint(array $endpoints, array $bindings = null) : ?array + public static function getDefaultEndpoint(array $endpoints, array $bindings = null): ?array { $firstNotFalse = null; $firstAllowed = null; @@ -296,7 +296,7 @@ class Metadata * * @return boolean True if the entity should be hidden, false otherwise. */ - public static function isHiddenFromDiscovery(array $metadata) : bool + public static function isHiddenFromDiscovery(array $metadata): bool { Logger::maskErrors(E_ALL); $hidden = in_array(self::$HIDE_FROM_DISCOVERY, $metadata['EntityAttributes'][self::$ENTITY_CATEGORY], true); @@ -312,7 +312,7 @@ class Metadata * * @return null|array */ - public static function parseNameIdPolicy($nameIdPolicy) : ?array + public static function parseNameIdPolicy($nameIdPolicy): ?array { $policy = null; diff --git a/lib/SimpleSAML/Utils/HttpAdapter.php b/lib/SimpleSAML/Utils/HttpAdapter.php index d5a833b65..f5a85b9c9 100644 --- a/lib/SimpleSAML/Utils/HttpAdapter.php +++ b/lib/SimpleSAML/Utils/HttpAdapter.php @@ -15,20 +15,22 @@ class HttpAdapter * @see HTTP::getServerHTTPS() * @return bool */ - public function getServerHTTPS() : bool + public function getServerHTTPS(): bool { return HTTP::getServerHTTPS(); } + /** * @see HTTP::getServerPort() * @return string */ - public function getServerPort() : string + public function getServerPort(): string { return HTTP::getServerPort(); } + /** * @see HTTP::addURLParameters() * @@ -36,22 +38,24 @@ class HttpAdapter * @param array $parameters * @return string */ - public function addURLParameters(string $url, array $parameters) : string + public function addURLParameters(string $url, array $parameters): string { return HTTP::addURLParameters($url, $parameters); } + /** * @see HTTP::checkSessionCookie() * * @param string|null $retryURL * @return void */ - public function checkSessionCookie(string $retryURL = null) : void + public function checkSessionCookie(string $retryURL = null): void { HTTP::checkSessionCookie($retryURL); } + /** * @see HTTP::checkURLAllowed() * @@ -59,11 +63,12 @@ class HttpAdapter * @param array|null $trustedSites * @return string */ - public function checkURLAllowed(string $url, array $trustedSites = null) : string + public function checkURLAllowed(string $url, array $trustedSites = null): string { return HTTP::checkURLAllowed($url, $trustedSites); } + /** * @see HTTP::fetch() * @@ -77,44 +82,49 @@ class HttpAdapter return HTTP::fetch($url, $context, $getHeaders); } + /** * @see HTTP::getAcceptLanguage() * @return array */ - public function getAcceptLanguage() : array + public function getAcceptLanguage(): array { return HTTP::getAcceptLanguage(); } + /** * @see HTTP::guessBasePath() * @return string */ - public function guessBasePath() : string + public function guessBasePath(): string { return HTTP::guessBasePath(); } + /** * @see HTTP::getBaseURL() * @return string */ - public function getBaseURL() : string + public function getBaseURL(): string { return HTTP::getBaseURL(); } + /** * @see HTTP::getFirstPathElement() * * @param bool $trailingslash * @return string */ - public function getFirstPathElement(bool $trailingslash = true) : string + public function getFirstPathElement(bool $trailingslash = true): string { return HTTP::getFirstPathElement($trailingslash); } + /** * @see HTTP::getPOSTRedirectURL() * @@ -122,95 +132,105 @@ class HttpAdapter * @param array $data * @return string */ - public function getPOSTRedirectURL(string $destination, array $data) : string + public function getPOSTRedirectURL(string $destination, array $data): string { return HTTP::getPOSTRedirectURL($destination, $data); } + /** * @see HTTP::getSelfHost() * @return string */ - public function getSelfHost() : string + public function getSelfHost(): string { return HTTP::getSelfHost(); } + /** * @see HTTP::getSelfHostWithNonStandardPort() * @return string */ - public function getSelfHostWithNonStandardPort() : string + public function getSelfHostWithNonStandardPort(): string { return HTTP::getSelfHostWithNonStandardPort(); } + /** * @see HTTP::getSelfHostWithPath() * @return string */ - public function getSelfHostWithPath() : string + public function getSelfHostWithPath(): string { return HTTP::getSelfHostWithPath(); } + /** * @see HTTP::getSelfURL() * @return string */ - public function getSelfURL() : string + public function getSelfURL(): string { return HTTP::getSelfURL(); } + /** * @see HTTP::getSelfURLHost() * @return string */ - public function getSelfURLHost() : string + public function getSelfURLHost(): string { return HTTP::getSelfURLHost(); } + /** * @see HTTP::getSelfURLNoQuery() * @return string */ - public function getSelfURLNoQuery() : string + public function getSelfURLNoQuery(): string { return HTTP::getSelfURLNoQuery(); } + /** * @see HTTP::isHTTPS() * @return bool */ - public function isHTTPS() : bool + public function isHTTPS(): bool { return HTTP::isHTTPS(); } + /** * @see HTTP::normalizeURL() * @param string $url * @return string */ - public function normalizeURL(string $url) : string + public function normalizeURL(string $url): string { return HTTP::normalizeURL($url); } + /** * @see HTTP::parseQueryString() * * @param string $query_string * @return array */ - public function parseQueryString(string $query_string) : array + public function parseQueryString(string $query_string): array { return HTTP::parseQueryString($query_string); } + /** * @see HTTP::redirectTrustedURL() * @@ -218,11 +238,12 @@ class HttpAdapter * @param array $parameters * @return void */ - public function redirectTrustedURL(string $url, array $parameters = []) : void + public function redirectTrustedURL(string $url, array $parameters = []): void { HTTP::redirectTrustedURL($url, $parameters); } + /** * @see HTTP::redirectUntrustedURL() * @@ -230,11 +251,12 @@ class HttpAdapter * @param array $parameters * @return void */ - public function redirectUntrustedURL(string $url, array $parameters = []) : void + public function redirectUntrustedURL(string $url, array $parameters = []): void { HTTP::redirectUntrustedURL($url, $parameters); } + /** * @see HTTP::resolveURL() * @@ -242,11 +264,12 @@ class HttpAdapter * @param string|null $base * @return string */ - public function resolveURL(string $url, string $base = null) : string + public function resolveURL(string $url, string $base = null): string { return HTTP::resolveURL($url, $base); } + /** * @see HTTP::setCookie() * @@ -256,11 +279,12 @@ class HttpAdapter * @param bool $throw * @return void */ - public function setCookie(string $name, string $value, array $params = null, bool $throw = true) : void + public function setCookie(string $name, string $value, array $params = null, bool $throw = true): void { HTTP::setCookie($name, $value, $params, $throw); } + /** * @see HTTP::submitPOSTData() * @@ -268,7 +292,7 @@ class HttpAdapter * @param array $data * @return void */ - public function submitPOSTData(string $destination, array $data) : void + public function submitPOSTData(string $destination, array $data): void { HTTP::submitPOSTData($destination, $data); } diff --git a/lib/SimpleSAML/Utils/Net.php b/lib/SimpleSAML/Utils/Net.php index 5e0a3453f..67a0bb342 100644 --- a/lib/SimpleSAML/Utils/Net.php +++ b/lib/SimpleSAML/Utils/Net.php @@ -25,7 +25,7 @@ class Net * @author Brook Schofield, GÉANT * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> */ - public static function ipCIDRcheck(string $cidr, string $ip = null) : bool + public static function ipCIDRcheck(string $cidr, string $ip = null): bool { if ($ip === null) { $ip = $_SERVER['REMOTE_ADDR']; diff --git a/lib/SimpleSAML/Utils/Random.php b/lib/SimpleSAML/Utils/Random.php index 1709038de..13cb535f5 100644 --- a/lib/SimpleSAML/Utils/Random.php +++ b/lib/SimpleSAML/Utils/Random.php @@ -25,7 +25,7 @@ class Random * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> */ - public static function generateID() : string + public static function generateID(): string { return '_' . bin2hex(openssl_random_pseudo_bytes((int) ((self::ID_LENGTH - 1) / 2))); } diff --git a/lib/SimpleSAML/Utils/Time.php b/lib/SimpleSAML/Utils/Time.php index d47a707a7..3ecbc8534 100644 --- a/lib/SimpleSAML/Utils/Time.php +++ b/lib/SimpleSAML/Utils/Time.php @@ -32,7 +32,7 @@ class Time * @return string The timestamp. * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function generateTimestamp(int $instant = null) : string + public static function generateTimestamp(int $instant = null): string { if ($instant === null) { $instant = time(); @@ -51,7 +51,7 @@ class Time * @return void * @throws \SimpleSAML\Error\Exception If the timezone set in the configuration is invalid. */ - public static function initTimezone() : void + public static function initTimezone(): void { if (self::$tz_initialized) { return; @@ -91,7 +91,7 @@ class Time * @throws \InvalidArgumentException If $duration is not a valid ISO 8601 duration or if the input parameters do * not have the right data types. */ - public static function parseDuration(string $duration, int $timestamp = null) : int + public static function parseDuration(string $duration, int $timestamp = null): int { // parse the duration. We use a very strict pattern $durationRegEx = '#^(-?)P(?:(?:(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)' . diff --git a/lib/SimpleSAML/Utils/XML.php b/lib/SimpleSAML/Utils/XML.php index c7590f7bf..46e2f3f22 100644 --- a/lib/SimpleSAML/Utils/XML.php +++ b/lib/SimpleSAML/Utils/XML.php @@ -43,7 +43,7 @@ class XML * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> * @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no> */ - public static function checkSAMLMessage(string $message, string $type) : void + public static function checkSAMLMessage(string $message, string $type): void { $allowed_types = ['saml20', 'saml11', 'saml-meta']; if (!in_array($type, $allowed_types, true)) { @@ -105,7 +105,7 @@ class XML * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function debugSAMLMessage($message, string $type) : void + public static function debugSAMLMessage($message, string $type): void { if (!(is_string($message) || $message instanceof DOMElement)) { throw new \InvalidArgumentException('Invalid input parameters.'); @@ -171,7 +171,7 @@ class XML * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function formatDOMElement(DOMNode $root, string $indentBase = '') : void + public static function formatDOMElement(DOMNode $root, string $indentBase = ''): void { // check what this element contains $fullText = ''; // all text in this element @@ -257,7 +257,7 @@ class XML * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function formatXMLString(string $xml, string $indentBase = '') : string + public static function formatXMLString(string $xml, string $indentBase = ''): string { try { $doc = DOMDocumentFactory::fromString($xml); @@ -287,7 +287,7 @@ class XML * @throws \InvalidArgumentException If $element is not an instance of DOMElement, $localName is not a string or * $namespaceURI is not a string. */ - public static function getDOMChildren(DOMNode $element, string $localName, string $namespaceURI) : array + public static function getDOMChildren(DOMNode $element, string $localName, string $namespaceURI): array { $ret = []; @@ -319,7 +319,7 @@ class XML * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function getDOMText(DOMElement $element) : string + public static function getDOMText(DOMElement $element): string { $txt = ''; @@ -360,7 +360,7 @@ class XML * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no> * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> */ - public static function isDOMNodeOfType(DOMNode $element, string $name, string $nsURI) : bool + public static function isDOMNodeOfType(DOMNode $element, string $name, string $nsURI): bool { if (strlen($nsURI) === 0) { // most likely a comment-node diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php index 86224427d..521325380 100644 --- a/lib/SimpleSAML/XHTML/Template.php +++ b/lib/SimpleSAML/XHTML/Template.php @@ -203,7 +203,7 @@ class Template extends Response * * @return string The name of the template to use. */ - public function getTemplateName() : string + public function getTemplateName(): string { return $this->normalizeTemplateName($this->template); } diff --git a/lib/SimpleSAML/XHTML/TemplateControllerInterface.php b/lib/SimpleSAML/XHTML/TemplateControllerInterface.php index e72027f0d..fe789e399 100644 --- a/lib/SimpleSAML/XHTML/TemplateControllerInterface.php +++ b/lib/SimpleSAML/XHTML/TemplateControllerInterface.php @@ -21,7 +21,7 @@ interface TemplateControllerInterface * * @return void */ - public function setUpTwig(Environment &$twig) : void; + public function setUpTwig(Environment &$twig): void; /** @@ -33,5 +33,5 @@ interface TemplateControllerInterface * * @return void */ - public function display(array &$data) : void; + public function display(array &$data): void; } diff --git a/lib/SimpleSAML/XHTML/TemplateLoader.php b/lib/SimpleSAML/XHTML/TemplateLoader.php index 5430a0273..919ded5d9 100644 --- a/lib/SimpleSAML/XHTML/TemplateLoader.php +++ b/lib/SimpleSAML/XHTML/TemplateLoader.php @@ -46,7 +46,7 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader * @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. */ - protected function parseModuleName(string $name, string $default = self::MAIN_NAMESPACE) : array + protected function parseModuleName(string $name, string $default = self::MAIN_NAMESPACE): array { if (strpos($name, ':')) { // we have our old SSP format @@ -69,7 +69,7 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader * * @throws \InvalidArgumentException If the module is not enabled or it has no templates directory. */ - public static function getModuleTemplateDir(string $module) : string + public static function getModuleTemplateDir(string $module): string { if (!Module::isModuleEnabled($module)) { throw new \InvalidArgumentException('The module \'' . $module . '\' is not enabled.'); diff --git a/lib/SimpleSAML/XML/Parser.php b/lib/SimpleSAML/XML/Parser.php index 9da5dd381..7996e73ba 100644 --- a/lib/SimpleSAML/XML/Parser.php +++ b/lib/SimpleSAML/XML/Parser.php @@ -34,7 +34,7 @@ class Parser * @param \SimpleXMLElement $element * @return \SimpleSAML\XML\Parser */ - public static function fromSimpleXMLElement(SimpleXMLElement $element) : Parser + public static function fromSimpleXMLElement(SimpleXMLElement $element): Parser { // Traverse all existing namespaces in element $namespaces = $element->getNamespaces(); @@ -59,7 +59,7 @@ class Parser * @throws \Exception * @return string */ - public function getValueDefault(string $xpath, string $defvalue) : string + public function getValueDefault(string $xpath, string $defvalue): string { try { /** @var string */ @@ -76,7 +76,7 @@ class Parser * @throws \Exception * @return string|null */ - public function getValue(string $xpath, bool $required = false) : ?string + public function getValue(string $xpath, bool $required = false): ?string { $result = $this->simplexml->xpath($xpath); if (!is_array($result) || empty($result)) { @@ -98,7 +98,7 @@ class Parser * @throws \Exception * @return string|null */ - public function getValueAlternatives(array $xpath, bool $required = false) : ?string + public function getValueAlternatives(array $xpath, bool $required = false): ?string { foreach ($xpath as $x) { $seek = $this->getValue($x); diff --git a/modules/core/lib/Auth/UserPassOrgBase.php b/modules/core/lib/Auth/UserPassOrgBase.php index dce40e894..f8ba52fd0 100644 --- a/modules/core/lib/Auth/UserPassOrgBase.php +++ b/modules/core/lib/Auth/UserPassOrgBase.php @@ -277,7 +277,7 @@ abstract class UserPassOrgBase extends \SimpleSAML\Auth\Source string $username, string $password, string $organization - ): void { + ): void { /* Retrieve the authentication state. */ /** @var array $state */ $state = Auth\State::loadState($authStateId, self::STAGEID); diff --git a/modules/core/lib/Stats/Output/File.php b/modules/core/lib/Stats/Output/File.php index 30563548c..a6562637a 100644 --- a/modules/core/lib/Stats/Output/File.php +++ b/modules/core/lib/Stats/Output/File.php @@ -85,7 +85,7 @@ class File extends \SimpleSAML\Stats\Output * @param array $data The event. * @return void */ - public function emit(array $data) : void + public function emit(array $data): void { Assert::notNull($data['time']); diff --git a/modules/core/lib/Stats/Output/Log.php b/modules/core/lib/Stats/Output/Log.php index 4817c1c9e..aa881b0b8 100644 --- a/modules/core/lib/Stats/Output/Log.php +++ b/modules/core/lib/Stats/Output/Log.php @@ -43,7 +43,7 @@ class Log extends \SimpleSAML\Stats\Output * @param array $data The event * @return void */ - public function emit(array $data) : void + public function emit(array $data): void { $str_data = json_encode($data); call_user_func($this->logger, 'EVENT ' . $str_data); diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php index 4db78af18..5bad36250 100644 --- a/modules/multiauth/lib/Auth/Source/MultiAuth.php +++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php @@ -139,7 +139,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source * @param array &$state Information about the current authentication. * @return void */ - public function authenticate(array &$state) : void + public function authenticate(array &$state): void { Assert::isArray($state); @@ -234,7 +234,7 @@ class MultiAuth extends \SimpleSAML\Auth\Source * @param array &$state Information about the current logout operation. * @return void */ - public function logout(array &$state) : void + public function logout(array &$state): void { Assert::isArray($state); diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php index 0d62b13b2..5dedebf51 100644 --- a/modules/saml/lib/Auth/Source/SP.php +++ b/modules/saml/lib/Auth/Source/SP.php @@ -730,7 +730,7 @@ class SP extends \SimpleSAML\Auth\Source * @param array &$state Information about the current authentication. * @return void */ - public function authenticate(array &$state) : void + public function authenticate(array &$state): void { Assert::isArray($state); @@ -789,7 +789,7 @@ class SP extends \SimpleSAML\Auth\Source * @param array &$state Information about the current authentication. * @return void */ - public function reauthenticate(array &$state) : void + public function reauthenticate(array &$state): void { $session = Session::getSessionFromRequest(); $data = $session->getAuthState($this->authId); @@ -1034,7 +1034,7 @@ class SP extends \SimpleSAML\Auth\Source * @param array $state The logout state. * @return void */ - public function logout(array &$state) : void + public function logout(array &$state): void { Assert::isArray($state); Assert::keyExists($state, 'saml:logout:Type'); diff --git a/modules/saml/lib/Error.php b/modules/saml/lib/Error.php index 7bbfce42f..e299117b2 100644 --- a/modules/saml/lib/Error.php +++ b/modules/saml/lib/Error.php @@ -110,7 +110,7 @@ class Error extends \SimpleSAML\Error\Exception * @param \Exception $exception The original exception. * @return \Exception The new exception. */ - public static function fromException(\Exception $exception) : \Exception + public static function fromException(\Exception $exception): \Exception { if ($exception instanceof \SimpleSAML\Module\saml\Error) { // Return the original exception unchanged -- GitLab