From: Andrew Engelbrecht Date: Thu, 3 Aug 2023 20:49:06 +0000 (-0400) Subject: fix function and attribute types X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=dc005d8a45b8de5bcdce2a7045f0967387a86ea9;p=fsfdrupalauth.git fix function and attribute types --- diff --git a/lib/Auth/Source/FSFDrupalAuth.php b/lib/Auth/Source/FSFDrupalAuth.php index efad30f..57b5e40 100644 --- a/lib/Auth/Source/FSFDrupalAuth.php +++ b/lib/Auth/Source/FSFDrupalAuth.php @@ -37,7 +37,7 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase /** * The options that we should connect to the database with. */ - private string $options; + private array $options; /** * The query we should use to retrieve the attributes for the user. @@ -144,6 +144,8 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase if (isset($config['options'])) { $this->options = $config['options']; + } else { + $this->options = []; } } @@ -189,7 +191,7 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase * Check the password against a Drupal hash * */ - private function check_password(string $password, string $hash): boolean { + private function check_password(string $password, string $hash): bool { // // The reason for running a separate process is so that the PHP global @@ -256,7 +258,7 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase * query the database with arbitrary queries that only require a user name. * */ - private function query_db(string $queryname, string $query_params): array + private function query_db(string $queryname, array $query_params): array { $db = $this->connect(); @@ -361,8 +363,8 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase * @param string $query_name Name of query in authsources * @param array $extra_params Associative array of parameters to include in query */ - $donation_query = function (string $query_name, array $extra_params): array - use (string $username) { + $donation_query = function (string $query_name, array $extra_params) + use ($username): array { $parameters = ['username' => $username]; @@ -375,7 +377,7 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase $old_membership_query = $donation_query; - $compare_res = function (array $result, int $amount): void { + $compare_res = function (array $result, int $amount): bool { foreach ($result[0] as $key => $value) { if (intval($value) >= $amount) { return true; @@ -397,8 +399,8 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase // the time window with a single donation. this approximates whether // the person was, or would have been, a member during the configured // time window. - $nomination_process_analyze_history = function (array $selective_donations_history): boolean - use (string $nomination_process_start_date, string $nomination_process_end_date) { + $nomination_process_analyze_history = function (array $selective_donations_history) + use ($nomination_process_start_date, $nomination_process_end_date): bool { $eligible = false; @@ -444,8 +446,8 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase return false; }; - $discussion_process_analyze_history = function (array $selective_donations_history): boolean - use (string $discussion_process_start_date, string $discussion_process_end_date) { + $discussion_process_analyze_history = function (array $selective_donations_history) + use ($discussion_process_start_date, $discussion_process_end_date): bool { $eligible = false; $total = 0; @@ -591,7 +593,7 @@ class FSFDrupalAuth extends \SimpleSAML\Module\core\Auth\UserPassBase * @param string $password The password the user wrote. * @return array Associative array with the users attributes. */ - protected function login(string $username, string $password): array + protected function login($username, $password) { //// keep this commented when it's not in use. it prints user passwords to the log file