@@ -84,7 +84,9 @@ public static function create(string $class, array $data = [])
8484 // Make sure the Result is initialized
8585 $ reflectionClass = new \ReflectionClass (Result::class);
8686 $ initializedProperty = $ reflectionClass ->getProperty ('initialized ' );
87- $ initializedProperty ->setAccessible (true );
87+ if (\PHP_VERSION_ID < 80100 ) {
88+ $ initializedProperty ->setAccessible (true );
89+ }
8890
8991 /** @psalm-var \ReflectionClass<T> $reflectionClass */
9092 $ reflectionClass = new \ReflectionClass ($ class );
@@ -116,7 +118,9 @@ public static function create(string $class, array $data = [])
116118 $ property = $ reflectionClass ->getProperty ($ propertyName );
117119 }
118120 }
119- $ property ->setAccessible (true );
121+ if (\PHP_VERSION_ID < 80100 ) {
122+ $ property ->setAccessible (true );
123+ }
120124 $ property ->setValue ($ object , $ propertyValue );
121125 }
122126
@@ -151,10 +155,14 @@ public static function waiter(string $class, string $finalState)
151155
152156 $ reflectionClass = new \ReflectionClass (Waiter::class);
153157 $ propertyResponse = $ reflectionClass ->getProperty ('response ' );
154- $ propertyResponse ->setAccessible (true );
158+ if (\PHP_VERSION_ID < 80100 ) {
159+ $ propertyResponse ->setAccessible (true );
160+ }
155161
156162 $ propertyState = $ reflectionClass ->getProperty ('finalState ' );
157- $ propertyState ->setAccessible (true );
163+ if (\PHP_VERSION_ID < 80100 ) {
164+ $ propertyState ->setAccessible (true );
165+ }
158166
159167 /** @psalm-var \ReflectionClass<T> $reflectionClass */
160168 $ reflectionClass = new \ReflectionClass ($ class );
@@ -217,7 +225,9 @@ private static function addUndefinedProperties(\ReflectionClass $reflectionClass
217225 }
218226
219227 if (null !== $ propertyValue ) {
220- $ property ->setAccessible (true );
228+ if (\PHP_VERSION_ID < 80100 ) {
229+ $ property ->setAccessible (true );
230+ }
221231 $ property ->setValue ($ object , $ propertyValue );
222232 }
223233 }
@@ -260,14 +270,18 @@ private static function addPropertiesOnResult(\ReflectionClass $reflectionClass,
260270 if (class_exists ($ awsClientClass )) {
261271 $ awsClientMock = (new \ReflectionClass ($ awsClientClass ))->newInstanceWithoutConstructor ();
262272 $ property = $ reflectionClass ->getProperty ('awsClient ' );
263- $ property ->setAccessible (true );
273+ if (\PHP_VERSION_ID < 80100 ) {
274+ $ property ->setAccessible (true );
275+ }
264276 $ property ->setValue ($ object , $ awsClientMock );
265277 }
266278
267279 if (class_exists ($ inputClass )) {
268280 $ inputMock = (new \ReflectionClass ($ inputClass ))->newInstanceWithoutConstructor ();
269281 $ property = $ reflectionClass ->getProperty ('input ' );
270- $ property ->setAccessible (true );
282+ if (\PHP_VERSION_ID < 80100 ) {
283+ $ property ->setAccessible (true );
284+ }
271285 $ property ->setValue ($ object , $ inputMock );
272286 }
273287 }
@@ -278,15 +292,21 @@ private static function getResponseObject(): Response
278292 $ response = $ reflectionClass ->newInstanceWithoutConstructor ();
279293
280294 $ property = $ reflectionClass ->getProperty ('resolveResult ' );
281- $ property ->setAccessible (true );
295+ if (\PHP_VERSION_ID < 80100 ) {
296+ $ property ->setAccessible (true );
297+ }
282298 $ property ->setValue ($ response , true );
283299
284300 $ property = $ reflectionClass ->getProperty ('bodyDownloaded ' );
285- $ property ->setAccessible (true );
301+ if (\PHP_VERSION_ID < 80100 ) {
302+ $ property ->setAccessible (true );
303+ }
286304 $ property ->setValue ($ response , true );
287305
288306 $ property = $ reflectionClass ->getProperty ('httpResponse ' );
289- $ property ->setAccessible (true );
307+ if (\PHP_VERSION_ID < 80100 ) {
308+ $ property ->setAccessible (true );
309+ }
290310 $ property ->setValue ($ response , new SimpleMockedResponse ());
291311
292312 return $ response ;
0 commit comments