Skip to content

Commit

Permalink
Merge pull request #6809 from ChurchCRM/deps
Browse files Browse the repository at this point in the history
  • Loading branch information
DawoudIO authored Jan 10, 2024
2 parents 3bbeb02 + e323e5d commit 9dc669f
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/ChurchCRM/Authentication/AuthenticationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static function endSession(bool $preventRedirect = false): void
$currentSessionUserName = 'Unknown';

try {
if (self::getCurrentUser() !== null) {
if (self::getCurrentUser() instanceof User) {
$currentSessionUserName = self::getCurrentUser()->getName();
}
} catch (\Exception $e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function validateUserSessionIsActive(bool $updateLastOperationTimestamp):
$authenticationResult = new AuthenticationResult();

// First check to see if a `user` key exists on the session.
if (null === $this->currentUser) {
if (!$this->currentUser instanceof User) {
$authenticationResult->isAuthenticated = false;
LoggerUtils::getAuthLogger()->debug('No active user session.');

Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/Reports/PDF_Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public function printName($sName): void
$this->SetFont($this->_Font, '', $this->_Char_Size);
}

public function sGetCustomString($rsCustomFields, $aRow)
public function sGetCustomString($rsCustomFields, $aRow): string
{
$numCustomFields = mysqli_num_rows($rsCustomFields);
if ($numCustomFields > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/ChurchCRM/Service/SystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static function getDBServerVersion()
}
}

public static function getPrerequisiteStatus()
public static function getPrerequisiteStatus(): string
{
if (AppIntegrityService::arePrerequisitesMet()) {
return 'All Prerequisites met';
Expand Down Expand Up @@ -161,7 +161,7 @@ public static function getMaxUploadFileSize($humanFormat = true)
}
}

private static function parseSize(string $size)
private static function parseSize(string $size): float
{
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/dto/SystemURLs.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function getURLs()
return self::$urls;
}

public static function getSupportURL($topic = '')
public static function getSupportURL($topic = ''): string
{
$supportURLs = [
'HttpsTask' => 'https://github.com/ChurchCRM/CRM/wiki/SSL',
Expand Down
4 changes: 2 additions & 2 deletions src/ChurchCRM/model/ChurchCRM/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ public function getAge(?\DateTimeInterface $now = null): string
{
$birthDate = $this->getBirthDate();

if ($birthDate === null || $this->hideAge()) {
if (!$birthDate instanceof \DateTimeImmutable || $this->hideAge()) {
return false;
}
if (!$now instanceof \DateTimeInterface) {
Expand All @@ -657,7 +657,7 @@ public function getAge(?\DateTimeInterface $now = null): string
public function getNumericAge(): int
{
$birthDate = $this->getBirthDate();
if ($birthDate === null || $this->hideAge()) {
if (!$birthDate instanceof \DateTimeImmutable || $this->hideAge()) {
return false;
}
if (empty($now)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/model/ChurchCRM/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ public function getNewTwoFARecoveryCodes(): array
return $recoveryCodes;
}

public function isTwoFACodeValid($twoFACode)
public function isTwoFACodeValid($twoFACode): bool
{
$google2fa = new Google2FA();
$window = 2; //TODO: make this a system config
Expand Down
10 changes: 4 additions & 6 deletions src/ChurchCRM/utils/GeoUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,10 @@ public static function getLatLong(string $address): array
$geoCoder = new StatefulGeocoder($provider, $localeInfo->getShortLocale());
$result = $geoCoder->geocodeQuery(GeocodeQuery::create($address));
$logger->debug('We have ' . $result->count() . ' results');
if ($result instanceof Collection) {
$firstResult = $result->get(0);
$coordinates = $firstResult->getCoordinates();
$lat = $coordinates->getLatitude();
$long = $coordinates->getLongitude();
}
$firstResult = $result->get(0);
$coordinates = $firstResult->getCoordinates();
$lat = $coordinates->getLatitude();
$long = $coordinates->getLongitude();
} catch (\Exception $exception) {
$logger->warning('issue creating geoCoder ' . $exception->getMessage());
}
Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/utils/InputUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function filterFloat($sInput): float
return (float) floatval(trim($sInput));
}

public static function filterDate($sInput)
public static function filterDate($sInput): string
{
// Attempts to take a date in any format and convert it to YYYY-MM-DD format
// Logel Philippe
Expand Down
12 changes: 6 additions & 6 deletions src/ChurchCRM/utils/LoggerUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
class LoggerUtils
{
private static ?Logger $appLogger = null;
private static ?\Monolog\Handler\StreamHandler $appLogHandler = null;
private static ?StreamHandler $appLogHandler = null;
private static ?Logger $cspLogger = null;
private static ?Logger $authLogger = null;
private static ?Logger $slimLogger = null;
private static ?\Monolog\Handler\StreamHandler $authLogHandler = null;
private static ?StreamHandler $authLogHandler = null;
private static ?string $correlationId = null;

public static function getCorrelationId(): ?string
Expand All @@ -37,7 +37,7 @@ public static function buildLogFilePath(string $type): string
}
public static function getSlimMVCLogger(): Logger
{
if (self::$slimLogger === null) {
if (!self::$slimLogger instanceof Logger) {
$slimLogger = new Logger('slim-app');
$streamHandler = new StreamHandler(self::buildLogFilePath('slim'), SystemConfig::getValue('sLogLevel'));
$slimLogger->pushHandler($streamHandler);
Expand All @@ -52,7 +52,7 @@ public static function getSlimMVCLogger(): Logger
*/
public static function getAppLogger($level = null): ?Logger
{
if (self::$appLogger === null) {
if (!self::$appLogger instanceof Logger) {
// if $level is null
// (meaning this function was invoked without explicitly setting the level),
// then get the level from the database
Expand Down Expand Up @@ -94,7 +94,7 @@ private static function getCaller(): array
*/
public static function getAuthLogger($level = null): ?Logger
{
if (self::$authLogger === null) {
if (!self::$authLogger instanceof Logger) {
// if $level is null
// (meaning this function was invoked without explicitly setting the level),
// then get the level from the database
Expand Down Expand Up @@ -128,7 +128,7 @@ public static function resetAppLoggerLevel(): void

public static function getCSPLogger(): ?Logger
{
if (self::$cspLogger === null) {
if (!self::$cspLogger instanceof Logger) {
self::$cspLogger = new Logger('cspLogger');
self::$cspLogger->pushHandler(new StreamHandler(self::buildLogFilePath('csp'), self::getLogLevel()));
}
Expand Down
4 changes: 2 additions & 2 deletions src/Include/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ function FormatDate($dDate, $bWithTime = false): string
}
}

function AlternateRowStyle($sCurrentStyle)
function AlternateRowStyle($sCurrentStyle): string
{
if ($sCurrentStyle == 'RowColorA') {
return 'RowColorB';
Expand Down Expand Up @@ -443,7 +443,7 @@ function ConvertToBoolean($sInput)
}
}

function ConvertFromBoolean($sInput)
function ConvertFromBoolean($sInput): int
{
if ($sInput) {
return 1;
Expand Down
4 changes: 2 additions & 2 deletions src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
},
"require-dev": {
"phpstan/phpstan": "^1.10",
"rector/rector": "^0.18.5",
"rector/rector": "^0.19.0",
"squizlabs/php_codesniffer": "^3.7"
}
}
}
26 changes: 13 additions & 13 deletions src/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@
LevelSetList::UP_TO_PHP_74,
SetList::GMAGICK_TO_IMAGICK,
SetList::TYPE_DECLARATION,
SetList::INSTANCEOF,
]);
};

0 comments on commit 9dc669f

Please sign in to comment.