diff --git a/models/ColorSettings.php b/models/ColorSettings.php index de804be..6eaf860 100644 --- a/models/ColorSettings.php +++ b/models/ColorSettings.php @@ -81,7 +81,14 @@ protected function additonalColorSaving(string $color, ?string $value): void protected function getColorFallBack(string $color): string { - $value = (new \ReflectionClass($this))->getProperty($color)->getDefaultValue(); + // compatiblity with PHP 7.4 will be removed in next version + if (version_compare(phpversion(), '8.0.0', '<')) { + $value = (new \ReflectionProperty($this))->getDeclaringClass()->getDefaultProperties()[$color] ?? null; + } else { + // min PHP 8.0 + $value = (new \ReflectionClass($this))->getProperty($color)->getDefaultValue(); + } + if (empty($value)) { $theme_var = str_replace('_', '-', $color); $value = ThemeHelper::getThemeByName(self::BASE_THEME)->variable(static::PREFIX . $theme_var); diff --git a/models/DarkColorSettings.php b/models/DarkColorSettings.php index a876d73..1bacffa 100644 --- a/models/DarkColorSettings.php +++ b/models/DarkColorSettings.php @@ -114,7 +114,14 @@ public function attributeHints(): array protected function getColorFallBack(string $color): string { - $value = (new \ReflectionClass($this))->getProperty($color)->getDefaultValue(); + // compatiblity with PHP 7.4 will be removed in next version + if (version_compare(phpversion(), '8.0.0', '<')) { + $value = (new \ReflectionProperty($this))->getDeclaringClass()->getDefaultProperties()[$color] ?? null; + } else { + // min PHP 8.0 + $value = (new \ReflectionClass($this))->getProperty($color)->getDefaultValue(); + } + if (empty($value)) {// only main colors can be empty! if (!isset($lightColors)) { $lightColors = (new ColorSettings())->getColors();