diff --git a/src/ChurchCRM/MICRFunctions.php b/src/ChurchCRM/MICRFunctions.php index 78e9c6ea4c..e6566ce09d 100644 --- a/src/ChurchCRM/MICRFunctions.php +++ b/src/ChurchCRM/MICRFunctions.php @@ -6,24 +6,24 @@ class MICRFunctions { - public $CHECKNO_FIRST = 1; // oo tt o - public $ROUTE_FIRST1 = 2; // tt o - public $ROUTE_FIRST2 = 3; // tt oo - public $NOT_RECOGNIZED = 4; + public int $CHECKNO_FIRST = 1; // oo tt o + public int $ROUTE_FIRST1 = 2; // tt o + public int $ROUTE_FIRST2 = 3; // tt oo + public int $NOT_RECOGNIZED = 4; - public function identifyFormat($micr) + public function identifyFormat(string $micr): int { // t000000000t0000o0000000000000o ROUTE_FIRST2 // t000000000t 0000000000o 0000 ROUTE_FIRST1 // o000000o t000000000t 0000000000o CHECKNO_FIRST $firstChar = mb_substr($micr, 0, 1); - if ($firstChar == 'o') { + if ($firstChar === 'o') { return $this->CHECKNO_FIRST; } elseif ($firstChar == 't') { $firstSmallO = strpos($micr, 'o'); $secondSmallO = strrpos($micr, 'o'); - if ($firstSmallO == $secondSmallO) { + if ($firstSmallO === $secondSmallO) { // Only one 'o' $len = strlen($micr); if ($len - $firstSmallO > 12) { @@ -35,9 +35,11 @@ public function identifyFormat($micr) return $this->ROUTE_FIRST2; } } + + throw new \InvalidArgumentException('Unknown format provided'); } - public function findRoute($micr): string + public function findRoute(string $micr): string { $routeAndAccount = $this->findRouteAndAccount($micr); $breakChar = strpos($routeAndAccount, 't', 1); @@ -45,7 +47,7 @@ public function findRoute($micr): string return mb_substr($micr, 1, $breakChar - 1); } - public function findAccount($micr): string + public function findAccount(string $micr): string { $routeAndAccount = $this->findRouteAndAccount($micr); $breakChar = strpos($routeAndAccount, 't', 1); @@ -53,7 +55,7 @@ public function findAccount($micr): string return mb_substr($routeAndAccount, $breakChar + 1, strlen($micr) - $breakChar); } - public function findRouteAndAccount($micr) + public function findRouteAndAccount(string $micr): string { $formatID = $this->identifyFormat($micr); @@ -78,7 +80,7 @@ public function findRouteAndAccount($micr) } } - public function findCheckNo($micr): string + public function findCheckNo(string $micr): string { $formatID = $this->identifyFormat($micr); if ($formatID == $this->CHECKNO_FIRST) { diff --git a/src/ChurchCRM/SQLUtils.php b/src/ChurchCRM/SQLUtils.php index a5de2e61bf..36dfeb3209 100644 --- a/src/ChurchCRM/SQLUtils.php +++ b/src/ChurchCRM/SQLUtils.php @@ -71,8 +71,7 @@ public static function sqlImport(string $fileName, $mysqli): void /** * Remove comments from sql. * - * @param string sql - * @param bool is multicomment line + * @param bool $isMultiComment is multicomment line * * @return string */ @@ -94,7 +93,7 @@ private static function clearSQL($sql, &$isMultiComment) while (preg_match('{--\s|#|/\*[^!]}sUi', $sql, $matched, PREG_OFFSET_CAPTURE, $offset)) { [$comment, $foundOn] = $matched[0]; if (self::isQuoted($foundOn, $sql)) { - $offset = $foundOn + strlen($comment); + $offset = (int) $foundOn + strlen($comment); } else { if (mb_substr($comment, 0, 2) == '/*') { $closedOn = strpos($sql, '*/', $foundOn); @@ -116,11 +115,8 @@ private static function clearSQL($sql, &$isMultiComment) /** * Check if "offset" position is quoted. - * - * @param int $offset - * @param string $text */ - private static function isQuoted($offset, $text): bool + private static function isQuoted(int $offset, string $text): bool { if ($offset > strlen($text)) { $offset = strlen($text); diff --git a/src/ChurchCRM/Service/AppIntegrityService.php b/src/ChurchCRM/Service/AppIntegrityService.php index 60da47956b..cb06a3fcdb 100644 --- a/src/ChurchCRM/Service/AppIntegrityService.php +++ b/src/ChurchCRM/Service/AppIntegrityService.php @@ -256,7 +256,7 @@ public static function hasModRewrite(): bool $header['status'] = $line; } - list($key, $value) = explode(': ', $line); + [$key, $value] = explode(': ', $line); $header[$key] = $value; } diff --git a/src/ChurchCRM/Service/FinancialService.php b/src/ChurchCRM/Service/FinancialService.php index 418d75338d..4d6c709434 100644 --- a/src/ChurchCRM/Service/FinancialService.php +++ b/src/ChurchCRM/Service/FinancialService.php @@ -17,13 +17,13 @@ class FinancialService { - public function deletePayment($groupKey): void + public function deletePayment(string $groupKey): void { requireUserGroupMembership('bFinance'); PledgeQuery::create()->findOneByGroupKey($groupKey)->delete(); } - public function getMemberByScanString($tScanString): array + public function getMemberByScanString(string $tScanString): array { requireUserGroupMembership('bFinance'); diff --git a/src/ChurchCRM/Service/PersonService.php b/src/ChurchCRM/Service/PersonService.php index 127f6ca40c..76f0049b03 100644 --- a/src/ChurchCRM/Service/PersonService.php +++ b/src/ChurchCRM/Service/PersonService.php @@ -10,7 +10,7 @@ class PersonService /** * @return array> */ - public function search(string $searchTerm, $includeFamilyRole = true): array + public function search(string $searchTerm, bool $includeFamilyRole = true): array { $searchLikeString = '%' . $searchTerm . '%'; $people = PersonQuery::create() diff --git a/src/ChurchCRM/Service/SystemService.php b/src/ChurchCRM/Service/SystemService.php index 308e900641..727130b246 100644 --- a/src/ChurchCRM/Service/SystemService.php +++ b/src/ChurchCRM/Service/SystemService.php @@ -4,6 +4,7 @@ use ChurchCRM\Backup\BackupJob; use ChurchCRM\Backup\BackupType; +use ChurchCRM\dto\Prerequisite; use ChurchCRM\dto\SystemConfig; use ChurchCRM\dto\SystemURLs; use ChurchCRM\Utils\ChurchCRMReleaseManager; @@ -73,13 +74,13 @@ public static function getPrerequisiteStatus(): string { if (AppIntegrityService::arePrerequisitesMet()) { return 'All Prerequisites met'; - } else { - $unmet = AppIntegrityService::getUnmetPrerequisites(); + } - $unmetNames = array_map(fn ($o): string => $o->getName(), $unmet); + $unmet = AppIntegrityService::getUnmetPrerequisites(); - return 'Missing Prerequisites: ' . json_encode(array_values($unmetNames), JSON_THROW_ON_ERROR); - } + $unmetNames = array_map(fn (Prerequisite $o): string => $o->getName(), $unmet); + + return 'Missing Prerequisites: ' . json_encode(array_values($unmetNames), JSON_THROW_ON_ERROR); } private static function isTimerThresholdExceeded(string $LastTime, int $ThresholdHours): bool diff --git a/src/ChurchCRM/data/Countries.php b/src/ChurchCRM/data/Countries.php index 1f0957ed3b..2c2008b25e 100644 --- a/src/ChurchCRM/data/Countries.php +++ b/src/ChurchCRM/data/Countries.php @@ -277,7 +277,7 @@ public static function getNames(): array { self::initializeCountries(); - return array_map([__CLASS__, 'getSingleName'], self::$countries); + return array_map([self::class, 'getSingleName'], self::$countries); } public static function getAll(): array diff --git a/src/ChurchCRM/utils/InputUtils.php b/src/ChurchCRM/utils/InputUtils.php index 1e1dc082e7..ef3c65cab5 100644 --- a/src/ChurchCRM/utils/InputUtils.php +++ b/src/ChurchCRM/utils/InputUtils.php @@ -8,7 +8,7 @@ class InputUtils { private static string $AllowedHTMLTags = '


    • '; - public static function legacyFilterInputArr(array $arr, $key, $type = 'string', $size = 1) + public static function legacyFilterInputArr(array $arr, $key, $type = 'string', $size = 1): string|int|float { if (array_key_exists($key, $arr)) { return InputUtils::legacyFilterInput($arr[$key], $type, $size); @@ -89,7 +89,7 @@ public static function filterDate($sInput): string // Sanitizes user input as a security measure // Optionally, a filtering type and size may be specified. By default, strip any tags from a string. // Note that a database connection must already be established for the mysqli_real_escape_string function to work. - public static function legacyFilterInput($sInput, $type = 'string', $size = 1) + public static function legacyFilterInput($sInput, $type = 'string', $size = 1): string|int|float { global $cnInfoCentral; if (strlen($sInput) > 0) { diff --git a/src/EventEditor.php b/src/EventEditor.php index 52cc4c1e51..37f821d0ec 100644 --- a/src/EventEditor.php +++ b/src/EventEditor.php @@ -44,7 +44,6 @@ $iErrors = 0; if ($sAction === 'Create Event' && !empty($tyid)) { - // User is coming from the event types screen and thus there // is no existing event in the event_event table // diff --git a/src/Reports/AdvancedDeposit.php b/src/Reports/AdvancedDeposit.php index 160867980f..aeaab3c402 100644 --- a/src/Reports/AdvancedDeposit.php +++ b/src/Reports/AdvancedDeposit.php @@ -221,7 +221,7 @@ public function printRightJustified($x, $y, $str): void $this->Write(8, $str); } - public function startFirstPage() + public function startFirstPage(): int|float { global $sDateStart, $sDateEnd, $sort, $iDepID, $datetype; $this->addPage(); diff --git a/src/Reports/EnvelopeReport.php b/src/Reports/EnvelopeReport.php index cfb62db7f9..94f2d27430 100644 --- a/src/Reports/EnvelopeReport.php +++ b/src/Reports/EnvelopeReport.php @@ -84,7 +84,7 @@ public function sGetFamilyString(Family $family): string } // Number of lines is only for the $text parameter - public function addRecord($text, $numlines): void + public function addRecord($text, int $numlines): void { // Add an extra blank line after record $numlines++; @@ -105,7 +105,6 @@ public function addRecord($text, $numlines): void $families = FamilyQuery::Create()->orderByEnvelope()->filterByEnvelope(0, 'Criteria::GREATER_THAN')->find(); foreach ($families as $family) { - $OutStr = ''; $OutStr = $pdf->sGetFamilyString($family); // Count the number of lines in the output string diff --git a/src/Reports/PhotoBook.php b/src/Reports/PhotoBook.php index 376f8e6fc0..2645b5b661 100644 --- a/src/Reports/PhotoBook.php +++ b/src/Reports/PhotoBook.php @@ -20,7 +20,7 @@ class PdfPhotoBook extends ChurchInfoReport { private $group; - private $FYIDString; + private string $FYIDString; private ?int $currentX = null; private ?int $currentY = null; private int $pageMarginL = 15; diff --git a/src/v2/templates/admin/debug.php b/src/v2/templates/admin/debug.php index 46f42a8755..49cfdb4c05 100644 --- a/src/v2/templates/admin/debug.php +++ b/src/v2/templates/admin/debug.php @@ -197,7 +197,7 @@

      0) { - ?> + ?>

      :

@@ -207,7 +207,7 @@ + ?> @@ -220,11 +220,11 @@ } ?> -
filename ?> expectedhash ?>
-