fix(compat): preserve PHP 8.0 support without changing control guards
Tests / test (push) Successful in 59s

Replace trait constants and array_is_list usage with equivalent PHP 8.0 constructs. Add strict list/expiry regressions and make isolated reflection tests PHP 8.0 compatible. No control activation, threshold or configuration change.
This commit is contained in:
dh
2026-10-08 07:24:19 +00:00
parent d42cfb3342
commit 86834bb8aa
10 changed files with 152 additions and 11 deletions
+14 -6
View File
@@ -12,8 +12,16 @@ require_once __DIR__ . '/NetzfahrplanV4Regeltest.php';
/** Locally approved, time-boxed operation of validated V4 shadow plans on a test plant. */
trait ManagerNetzfahrplanV4AktivtestTrait
{
private const V4_AKTIVTEST_DAUER_SEKUNDEN = 172800;
private const V4_AKTIVTEST_WATCHDOG_VERZICHT = 'explicit_test_plant_watchdog_waiver';
// Trait constants require PHP 8.2; keep these fixed values compatible with PHP 8.0.
private static function v4AktivtestDauerSekunden(): int
{
return 172800;
}
private static function v4AktivtestWatchdogVerzicht(): string
{
return 'explicit_test_plant_watchdog_waiver';
}
private function registriereV4ManagerAktivtest(): void
{
@@ -78,12 +86,12 @@ trait ManagerNetzfahrplanV4AktivtestTrait
$until = $this->ReadAttributeInteger('NetzfahrplanV4AktivtestEnde');
if ($start === 0 && $until === 0) {
$start = $now;
$until = $now + self::V4_AKTIVTEST_DAUER_SEKUNDEN;
$until = $now + self::v4AktivtestDauerSekunden();
$this->WriteAttributeInteger('NetzfahrplanV4AktivtestBeginn', $start);
$this->WriteAttributeInteger('NetzfahrplanV4AktivtestEnde', $until);
}
if ($start <= 0 || $until <= $now
|| $until - $start > self::V4_AKTIVTEST_DAUER_SEKUNDEN) {
|| $until - $start > self::v4AktivtestDauerSekunden()) {
throw new RuntimeException('Die einmalige 48-Stunden-Aktivtestfreigabe ist abgelaufen.');
}
@@ -103,7 +111,7 @@ trait ManagerNetzfahrplanV4AktivtestTrait
'maxChargeW' => $maxChargeW,
'maxDischargeW' => $maxDischargeW,
'watchdogWaived' => true,
'actuatorWatchdogEvidenceId' => self::V4_AKTIVTEST_WATCHDOG_VERZICHT,
'actuatorWatchdogEvidenceId' => self::v4AktivtestWatchdogVerzicht(),
'feedbackConfigHash' => $operation['localFeedback'][$asset['ID']]['configHash'] ?? '',
'gridLimits' => NetzfahrplanV4Planpruefung::kontext($operation)['limits'],
'sequence' => 1,
@@ -206,7 +214,7 @@ trait ManagerNetzfahrplanV4AktivtestTrait
'maxChargeW' => $session['maxChargeW'],
'maxDischargeW' => $session['maxDischargeW'],
'accountingEvidenceId' => $quality['accountingEvidenceId'] ?? null,
'actuatorWatchdogEvidenceId' => self::V4_AKTIVTEST_WATCHDOG_VERZICHT,
'actuatorWatchdogEvidenceId' => self::v4AktivtestWatchdogVerzicht(),
'acceptEstimatedPeak' => true,
'controlContext' => $plan['controlContext'] ?? null,
];
+1 -1
View File
@@ -128,7 +128,7 @@ trait ManagerSDLTrait
);
}
$alt = json_decode(IPS_GetProperty($instanzID, 'Config'), true, 512, JSON_THROW_ON_ERROR);
if (!is_array($alt) || !array_is_list($alt)) {
if (!is_array($alt) || array_keys($alt) !== array_keys(array_values($alt))) {
throw new RuntimeException('Die bestehende Energiefluss-Konfiguration ist keine Liste.');
}
$neu = [];
+2 -2
View File
@@ -18,7 +18,7 @@ final class NetzfahrplanV4Rueckmeldung
private static function ordered(array $v): array
{
if (!array_is_list($v)) ksort($v, SORT_STRING);
if (array_keys($v) !== array_keys(array_values($v))) ksort($v, SORT_STRING);
foreach ($v as &$x) if (is_array($x)) $x=self::ordered($x);
unset($x);return $v;
}
@@ -40,7 +40,7 @@ final class NetzfahrplanV4Rueckmeldung
}
$c['idleToleranceW']=self::number($c['idleToleranceW'],0,100);
$c['trackingToleranceW']=self::number($c['trackingToleranceW'],0,500);
if (!is_array($c['sources']) || !array_is_list($c['sources']) || count($c['sources'])<2 || count($c['sources'])>40) throw new InvalidArgumentException('feedback_sources_invalid');
if (!is_array($c['sources']) || array_keys($c['sources']) !== array_keys(array_values($c['sources'])) || count($c['sources'])<2 || count($c['sources'])>40) throw new InvalidArgumentException('feedback_sources_invalid');
$ids=[];$names=[];$roles=[];
foreach ($c['sources'] as &$s) {
$fields=['key','role','variableId','parentId','ident','factorToW'];