From 62005ddb550f8b1c69c955c8683a8a632a44f482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Wed, 2 Aug 2023 12:29:43 +0200 Subject: [PATCH] [TASK] Avoid php deprecation in FrameworkState With PHP8.3 the `ReflectionProperty->setValue()` method emits a E_DEPRECATED if a value should be set to a class and the context is not set as first argument. For instanciated classes the class needs to be provided, which is not possible for a static class or property. The solution for this is to use `null` as first argument as context object. That avoids the deprecation and keeps the backward compatibility. The testing-framework provides a tool to keep and handle static Framework state, which uses reflection under the hood and therefore needs the null context for `setValue()`. Releases: main, 7, 6 --- Classes/Core/Functional/Framework/FrameworkState.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Classes/Core/Functional/Framework/FrameworkState.php b/Classes/Core/Functional/Framework/FrameworkState.php index bcb3bea0..a2fc6598 100644 --- a/Classes/Core/Functional/Framework/FrameworkState.php +++ b/Classes/Core/Functional/Framework/FrameworkState.php @@ -89,7 +89,7 @@ public static function reset() $generalUtilityReflection = new \ReflectionClass(GeneralUtility::class); $generalUtilityIndpEnvCache = $generalUtilityReflection->getProperty('indpEnvCache'); $generalUtilityIndpEnvCache->setAccessible(true); - $generalUtilityIndpEnvCache->setValue([]); + $generalUtilityIndpEnvCache->setValue(null, []); GeneralUtility::resetSingletonInstances([]); @@ -126,19 +126,19 @@ public static function pop() $generalUtilityReflection = new \ReflectionClass(GeneralUtility::class); $generalUtilityIndpEnvCache = $generalUtilityReflection->getProperty('indpEnvCache'); $generalUtilityIndpEnvCache->setAccessible(true); - $generalUtilityIndpEnvCache->setValue($state['generalUtilityIndpEnvCache']); + $generalUtilityIndpEnvCache->setValue(null, $state['generalUtilityIndpEnvCache']); GeneralUtility::resetSingletonInstances($state['generalUtilitySingletonInstances']); $rootlineUtilityReflection = new \ReflectionClass(RootlineUtility::class); $rootlineUtilityLocalCache = $rootlineUtilityReflection->getProperty('localCache'); $rootlineUtilityLocalCache->setAccessible(true); - $rootlineUtilityLocalCache->setValue($state['rootlineUtilityLocalCache']); + $rootlineUtilityLocalCache->setValue(null, $state['rootlineUtilityLocalCache']); $rootlineUtilityRootlineFields = $rootlineUtilityReflection->getProperty('rootlineFields'); $rootlineUtilityRootlineFields->setAccessible(true); - $rootlineUtilityRootlineFields->setValue($state['rootlineUtilityRootlineFields']); + $rootlineUtilityRootlineFields->setValue(null, $state['rootlineUtilityRootlineFields']); $rootlineUtilityPageRecordCache = $rootlineUtilityReflection->getProperty('pageRecordCache'); $rootlineUtilityPageRecordCache->setAccessible(true); - $rootlineUtilityPageRecordCache->setValue($state['rootlineUtilityPageRecordCache']); + $rootlineUtilityPageRecordCache->setValue(null, $state['rootlineUtilityPageRecordCache']); } }