Skip to content

Commit 754e795

Browse files
committed
[TASK] Ensure compatibility with PHP 8.1, references #350
1 parent 6a0ec07 commit 754e795

File tree

7 files changed

+23
-17
lines changed

7 files changed

+23
-17
lines changed

Classes/Domain/Model/Log.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class Log extends AbstractEntity
2828
/**
2929
* @var int Run status (based on FlashMessage codes)
3030
*/
31-
protected int $status = ContextualFeedbackSeverity::NOTICE->value;
31+
// TODO: switch when support for PHP 8.1 is dropped (or get rid of that class entirely)
32+
// protected int $status = ContextualFeedbackSeverity::NOTICE->value;
33+
protected int $status = -2;
3234

3335
/**
3436
* @var \DateTime|null Run date and time

Classes/Handler/ArrayHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function handleData($rawData, Importer $importer): array
8181
'Using arrayPath property (value %s) returned an empty set',
8282
$generalConfiguration['arrayPath']
8383
),
84-
ContextualFeedbackSeverity::WARNING->value
84+
ContextualFeedbackSeverity::WARNING
8585
);
8686
return [];
8787
}

Classes/Handler/XmlHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function handleData($rawData, Importer $importer): array
7575
} catch (\Exception $e) {
7676
$importer->addMessage(
7777
$e->getMessage(),
78-
ContextualFeedbackSeverity::WARNING->value
78+
ContextualFeedbackSeverity::WARNING
7979
);
8080
}
8181
} else {

Classes/Importer.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public function synchronize(string $table, $index): array
265265
$e->getMessage(),
266266
]
267267
),
268-
ContextualFeedbackSeverity::WARNING->value
268+
ContextualFeedbackSeverity::WARNING
269269
);
270270
} catch (NoConfigurationException $e) {
271271
$this->addMessage(
@@ -401,7 +401,7 @@ public function runSteps(): void
401401
'LLL:EXT:external_import/Resources/Private/Language/ExternalImport.xlf:importAborted',
402402
'external_import'
403403
),
404-
ContextualFeedbackSeverity::WARNING->value
404+
ContextualFeedbackSeverity::WARNING
405405
);
406406
}
407407
$this->currentData = $step->getData();
@@ -532,12 +532,12 @@ public function debug(string $message, int $severity = 0, $data = null): void
532532
* when the synchronization is complete.
533533
*
534534
* @param string $text The message itself
535-
* @param int $status Status of the message. Expected is "success", "warning" or "error"
535+
* @param ContextualFeedbackSeverity $status Status of the message
536536
*/
537-
public function addMessage(string $text, int $status = ContextualFeedbackSeverity::ERROR->value): void
537+
public function addMessage(string $text, ContextualFeedbackSeverity $status = ContextualFeedbackSeverity::ERROR): void
538538
{
539539
if (!empty($text)) {
540-
$this->messages[$status][] = $text;
540+
$this->messages[$status->value][] = $text;
541541
}
542542
}
543543

@@ -559,6 +559,8 @@ public function resetMessages(): void
559559
$this->messages = [
560560
ContextualFeedbackSeverity::ERROR->value => [],
561561
ContextualFeedbackSeverity::WARNING->value => [],
562+
ContextualFeedbackSeverity::INFO->value => [],
563+
ContextualFeedbackSeverity::NOTICE->value => [],
562564
ContextualFeedbackSeverity::OK->value => [],
563565
];
564566
}

Classes/Step/StoreDataStep.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -518,31 +518,31 @@ public function run(): void
518518
null,
519519
[$inserts]
520520
),
521-
ContextualFeedbackSeverity::OK->value
521+
ContextualFeedbackSeverity::OK
522522
);
523523
$this->importer->addMessage(
524524
LocalizationUtility::translate(
525525
'LLL:EXT:external_import/Resources/Private/Language/ExternalImport.xlf:records_updated',
526526
null,
527527
[$updates]
528528
),
529-
ContextualFeedbackSeverity::OK->value
529+
ContextualFeedbackSeverity::OK
530530
);
531531
$this->importer->addMessage(
532532
LocalizationUtility::translate(
533533
'LLL:EXT:external_import/Resources/Private/Language/ExternalImport.xlf:records_deleted',
534534
null,
535535
[$deletes]
536536
),
537-
ContextualFeedbackSeverity::OK->value
537+
ContextualFeedbackSeverity::OK
538538
);
539539
$this->importer->addMessage(
540540
LocalizationUtility::translate(
541541
'LLL:EXT:external_import/Resources/Private/Language/ExternalImport.xlf:records_moved',
542542
null,
543543
[$moves]
544544
),
545-
ContextualFeedbackSeverity::OK->value
545+
ContextualFeedbackSeverity::OK
546546
);
547547
// Store the number of operations in the reporting utility
548548
$this->importer->getReportingUtility()->setValueForStep(
@@ -1053,7 +1053,7 @@ protected function reportTceErrors(array $errorLog): void
10531053
LocalizationUtility::translate(
10541054
'LLL:EXT:external_import/Resources/Private/Language/ExternalImport.xlf:things_happened'
10551055
),
1056-
ContextualFeedbackSeverity::WARNING->value
1056+
ContextualFeedbackSeverity::WARNING
10571057
);
10581058
}
10591059
}

Classes/Utility/SlugUtility.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function generateSlug(string $table, string $field, array $fieldConfigura
123123
$e->getMessage(),
124124
$e->getCode()
125125
),
126-
ContextualFeedbackSeverity::NOTICE->value
126+
ContextualFeedbackSeverity::NOTICE
127127
);
128128
}
129129
} elseif (GeneralUtility::inList('uniqueInPid', $fieldConfiguration['eval'] ?? '')) {
@@ -152,7 +152,7 @@ public function generateSlug(string $table, string $field, array $fieldConfigura
152152
$e->getMessage(),
153153
$e->getCode()
154154
),
155-
ContextualFeedbackSeverity::NOTICE->value
155+
ContextualFeedbackSeverity::NOTICE
156156
);
157157
}
158158
} else {

Tests/Unit/ImporterTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function getMessagesInitiallyReturnsEmptyStructure(): void
104104
*/
105105
public function addMessagesAddsMessage(): void
106106
{
107-
$this->subject->addMessage('foo', ContextualFeedbackSeverity::WARNING->value);
107+
$this->subject->addMessage('foo', ContextualFeedbackSeverity::WARNING);
108108
self::assertCount(
109109
1,
110110
$this->subject->getMessages()[ContextualFeedbackSeverity::WARNING->value]
@@ -116,12 +116,14 @@ public function addMessagesAddsMessage(): void
116116
*/
117117
public function resetMessagesInitiallyPreparesEmptyStructure(): void
118118
{
119-
$this->subject->addMessage('foo', ContextualFeedbackSeverity::WARNING->value);
119+
$this->subject->addMessage('foo', ContextualFeedbackSeverity::WARNING);
120120
$this->subject->resetMessages();
121121
self::assertSame(
122122
[
123123
ContextualFeedbackSeverity::ERROR->value => [],
124124
ContextualFeedbackSeverity::WARNING->value => [],
125+
ContextualFeedbackSeverity::INFO->value => [],
126+
ContextualFeedbackSeverity::NOTICE->value => [],
125127
ContextualFeedbackSeverity::OK->value => [],
126128
],
127129
$this->subject->getMessages()

0 commit comments

Comments
 (0)