Skip to content

Commit

Permalink
add some typehints
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Jul 16, 2024
1 parent a22860b commit c841fb2
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions core/CronArchive/QueueConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ public function getNextArchivesToProcess()
return $archivesToProcess;
}

private function archiveArrayContainsArchive($archiveArray, $archive)
private function archiveArrayContainsArchive(array $archiveArray, array $archive): bool
{
foreach ($archiveArray as $entry) {
if (
Expand Down Expand Up @@ -411,7 +411,7 @@ private function shouldSkipArchive($archive)
}

// public for tests
public function canSkipArchiveBecauseNoPoint(array $invalidatedArchive)
public function canSkipArchiveBecauseNoPoint(array $invalidatedArchive): bool
{
$site = new Site($invalidatedArchive['idsite']);

Expand Down Expand Up @@ -447,7 +447,8 @@ public function shouldSkipArchiveBecauseLowerPeriodOrSegmentIsInProgress(array $

// we don't care about lower periods being concurrent if they are for different segments (that are not "all visits")
if (
!empty($archiveBeingProcessed['segment']) && !empty($archiveToProcess['segment'])
!empty($archiveBeingProcessed['segment'])
&& !empty($archiveToProcess['segment'])
&& $archiveBeingProcessed['segment'] != $archiveToProcess['segment']
) {
continue;
Expand All @@ -473,7 +474,7 @@ public function shouldSkipArchiveBecauseLowerPeriodOrSegmentIsInProgress(array $
return null;
}

private function isArchiveOfLowerPeriod(array $archiveToProcess, $archiveBeingProcessed): bool
private function isArchiveOfLowerPeriod(array $archiveToProcess, array $archiveBeingProcessed): bool
{
/** @var Period $archiveToProcessPeriodObj */
$archiveToProcessPeriodObj = $archiveToProcess['periodObj'];
Expand All @@ -490,7 +491,7 @@ private function isArchiveOfLowerPeriod(array $archiveToProcess, $archiveBeingPr
return false;
}

private function isArchiveNonSegmentAndInProgressArchiveSegment(array $archiveToProcess, array $archiveBeingProcessed)
private function isArchiveNonSegmentAndInProgressArchiveSegment(array $archiveToProcess, array $archiveBeingProcessed): bool
{
// archive is for different site/period
if (
Expand All @@ -504,13 +505,13 @@ private function isArchiveNonSegmentAndInProgressArchiveSegment(array $archiveTo
return empty($archiveToProcess['segment']) && !empty($archiveBeingProcessed['segment']);
}

private function detectPluginForArchive(&$archive)
private function detectPluginForArchive(&$archive): void
{
$archive['plugin'] = $this->getPluginNameForArchiveIfAny($archive);
}

// static so it can be unit tested
public static function hasIntersectingPeriod(array $archivesToProcess, $invalidatedArchive)
public static function hasIntersectingPeriod(array $archivesToProcess, $invalidatedArchive): bool
{
if (empty($archivesToProcess)) {
return false;
Expand Down Expand Up @@ -544,7 +545,7 @@ public static function hasIntersectingPeriod(array $archivesToProcess, $invalida
return false;
}

private function findSegmentForArchive(&$archive)
private function findSegmentForArchive(&$archive): bool
{
$flag = explode('.', $archive['name'])[0];
if ($flag == 'done') {
Expand All @@ -564,7 +565,7 @@ private function findSegmentForArchive(&$archive)
return $this->segmentArchiving->isAutoArchivingEnabledFor($storedSegment);
}

private function getPluginNameForArchiveIfAny($archive)
private function getPluginNameForArchiveIfAny(array $archive): ?string
{
$name = $archive['name'];
if (strpos($name, '.') === false) {
Expand All @@ -575,17 +576,17 @@ private function getPluginNameForArchiveIfAny($archive)
return $parts[1];
}

public function ignoreIdInvalidation($idinvalidation)
public function ignoreIdInvalidation($idinvalidation): void
{
$this->invalidationsToExclude[$idinvalidation] = $idinvalidation;
}

public function skipToNextSite()
public function skipToNextSite(): void
{
$this->idSite = null;
}

private function addInvalidationToExclude(array $invalidatedArchive)
private function addInvalidationToExclude(array $invalidatedArchive): void
{
$id = $invalidatedArchive['idinvalidation'];
if (empty($this->invalidationsToExclude[$id])) {
Expand All @@ -598,7 +599,7 @@ private function getNextIdSiteToArchive()
return $this->websiteIdArchiveList->getNextSiteId();
}

private function getInvalidationDescription(array $invalidatedArchive)
private function getInvalidationDescription(array $invalidatedArchive): string
{
return sprintf(
"[idinvalidation = %s, idsite = %s, period = %s(%s - %s), name = %s, segment = %s]",
Expand All @@ -613,7 +614,7 @@ private function getInvalidationDescription(array $invalidatedArchive)
}

// public for test
public function usableArchiveExists(array $invalidatedArchive)
public function usableArchiveExists(array $invalidatedArchive): array
{
$site = new Site($invalidatedArchive['idsite']);

Expand Down

0 comments on commit c841fb2

Please sign in to comment.