Skip to content

Commit b682095

Browse files
authored
Merge pull request #540 from wp-cli/fix/php85-tests
Avoid `setAccessible` deprecation warnings
2 parents 8d3751a + c75fe8b commit b682095

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/User_Session_Command.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ public function list_( $args, $assoc_args ) {
173173
protected function get_all_sessions( WP_Session_Tokens $manager ) {
174174
// Make the private session data accessible to WP-CLI
175175
$get_sessions = new ReflectionMethod( $manager, 'get_sessions' );
176-
$get_sessions->setAccessible( true );
176+
if ( PHP_VERSION_ID < 80100 ) {
177+
$get_sessions->setAccessible( true );
178+
}
177179

178180
/**
179181
* @var array<array{token: string|int, login_time: string, login: int, expiration_time: string, expiration: int}> $sessions
@@ -194,7 +196,9 @@ function ( &$session, $token ) {
194196

195197
protected function destroy_session( WP_Session_Tokens $manager, $token ) {
196198
$update_session = new ReflectionMethod( $manager, 'update_session' );
197-
$update_session->setAccessible( true );
199+
if ( PHP_VERSION_ID < 80100 ) {
200+
$update_session->setAccessible( true );
201+
}
198202
return $update_session->invoke( $manager, $token, null );
199203
}
200204

0 commit comments

Comments
 (0)