Skip to content

Commit

Permalink
chore(core): scrutinizer issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Apr 16, 2024
1 parent 9beb005 commit 7d53b45
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion engine/classes/Elgg/Database/Plugins.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function generateEntities(): bool {
} else {
// create new plugin
// priority is forced to last in save() if not set.
$plugin = \ElggPlugin::fromId($plugin_id);
\ElggPlugin::fromId($plugin_id);
}
}

Expand Down
15 changes: 7 additions & 8 deletions engine/classes/Elgg/Upgrade/Loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,11 @@ public function __construct(
/**
* Run upgrade loop for a preset number of seconds
*
* @param int $max_duration Maximum loop duration
* @param int|null $max_duration Maximum loop duration
*
* @return void
*/
public function loop($max_duration = null): void {

public function loop(int $max_duration = null): void {
$started = microtime(true);

$this->upgrade->setStartTime();
Expand Down Expand Up @@ -181,17 +180,17 @@ protected function report(): void {
/**
* Check if the loop cand and should continue
*
* @param float $started Timestamp of the loop initiation
* @param int $max_duration Maximum loop duration
* @param float $started Timestamp of the loop initiation
* @param int|null $max_duration Maximum loop duration
*
* @return bool
*/
protected function canContinue($started, $max_duration = null): bool {
protected function canContinue($started, int $max_duration = null): bool {
if (!isset($max_duration)) {
$max_duration = elgg_get_config('batch_run_time_in_secs');
$max_duration = (int) elgg_get_config('batch_run_time_in_secs');
}

if ($max_duration && (microtime(true) - $started) >= $max_duration) {
if ($max_duration > 0 && (microtime(true) - $started) >= $max_duration) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions engine/classes/Elgg/UpgradeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function runUpgrades($upgrades): Promise {

$promises[] = new Promise(function ($resolve, $reject) use ($upgrade) {
try {
$result = $this->executeUpgrade($upgrade, false);
$result = $this->executeUpgrade($upgrade, 0);
} catch (\Throwable $ex) {
return $reject($ex);
}
Expand Down Expand Up @@ -267,8 +267,8 @@ function () use ($async) {
* Call the upgrade's run() for a specified period of time, or until it completes
*
* @param \ElggUpgrade $upgrade Upgrade to run
* @param int $max_duration Maximum duration in seconds
* Set to false to execute an entire upgrade
* @param int|null $max_duration Maximum duration in seconds
* Set to 0 to execute an entire upgrade
*
* @return Result
*/
Expand Down
3 changes: 2 additions & 1 deletion engine/lib/mb_wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ function elgg_strtoupper() {
* Wrapper for mb_convert_case($str, MB_CASE_TITLE)
*
* @param string $str String
*
* @return string
* @since 2.3
*/
Expand Down Expand Up @@ -188,7 +189,7 @@ function elgg_substr_count() {
* wrapped function in the same order they are passed to this
* function.
*
* @return false|string
* @return string
* @since 1.7.0
*/
function elgg_substr() {
Expand Down
2 changes: 1 addition & 1 deletion mod/system_log/classes/Elgg/SystemLog/SystemLogQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ protected function normalizeOptions(): void {
*
* @param QueryBuilder $qb Query builder
*
* @return CompositeExpression|string
* @return CompositeExpression|null|string
*/
protected function buildQuery(QueryBuilder $qb) {
$wheres = [];
Expand Down

0 comments on commit 7d53b45

Please sign in to comment.