@@ -21,7 +21,9 @@ public function set_up() {
2121
2222 // Save and set logger.
2323 $ class_wp_cli_logger = new \ReflectionProperty ( 'WP_CLI ' , 'logger ' );
24- $ class_wp_cli_logger ->setAccessible ( true );
24+ if ( PHP_VERSION_ID < 80100 ) {
25+ $ class_wp_cli_logger ->setAccessible ( true );
26+ }
2527 $ this ->prev_logger = $ class_wp_cli_logger ->getValue ();
2628
2729 $ this ->logger = new Execution ();
@@ -30,7 +32,9 @@ public function set_up() {
3032 // Enable exit exception.
3133
3234 $ class_wp_cli_capture_exit = new \ReflectionProperty ( 'WP_CLI ' , 'capture_exit ' );
33- $ class_wp_cli_capture_exit ->setAccessible ( true );
35+ if ( PHP_VERSION_ID < 80100 ) {
36+ $ class_wp_cli_capture_exit ->setAccessible ( true );
37+ }
3438 $ class_wp_cli_capture_exit ->setValue ( null , true );
3539
3640 $ this ->temp_dir = Utils \get_temp_dir () . uniqid ( 'wp-cli-test-package-composer-json- ' , true ) . '/ ' ;
@@ -43,7 +47,9 @@ public function tear_down() {
4347
4448 // Restore exit exception.
4549 $ class_wp_cli_capture_exit = new \ReflectionProperty ( 'WP_CLI ' , 'capture_exit ' );
46- $ class_wp_cli_capture_exit ->setAccessible ( true );
50+ if ( PHP_VERSION_ID < 80100 ) {
51+ $ class_wp_cli_capture_exit ->setAccessible ( true );
52+ }
4753 $ class_wp_cli_capture_exit ->setValue ( null , $ this ->prev_capture_exit );
4854
4955 rmdir ( $ this ->temp_dir );
@@ -53,7 +59,9 @@ public function tear_down() {
5359
5460 public function test_create_default_composer_json () {
5561 $ create_default_composer_json = new \ReflectionMethod ( 'Package_Command ' , 'create_default_composer_json ' );
56- $ create_default_composer_json ->setAccessible ( true );
62+ if ( PHP_VERSION_ID < 80100 ) {
63+ $ create_default_composer_json ->setAccessible ( true );
64+ }
5765
5866 $ package = new Package_Command ();
5967
@@ -84,7 +92,9 @@ public function test_get_composer_json_path() {
8492 $ env_wp_cli_packages_dir = getenv ( 'WP_CLI_PACKAGES_DIR ' );
8593
8694 $ get_composer_json_path = new \ReflectionMethod ( 'Package_Command ' , 'get_composer_json_path ' );
87- $ get_composer_json_path ->setAccessible ( true );
95+ if ( PHP_VERSION_ID < 80100 ) {
96+ $ get_composer_json_path ->setAccessible ( true );
97+ }
8898
8999 $ package = new Package_Command ();
90100
@@ -134,7 +144,9 @@ public function test_get_composer_json_path_backup_decoded() {
134144 putenv ( 'WP_CLI_PACKAGES_DIR= ' . $ this ->temp_dir . 'packages ' );
135145
136146 $ get_composer_json_path_backup_decoded = new \ReflectionMethod ( 'Package_Command ' , 'get_composer_json_path_backup_decoded ' );
137- $ get_composer_json_path_backup_decoded ->setAccessible ( true );
147+ if ( PHP_VERSION_ID < 80100 ) {
148+ $ get_composer_json_path_backup_decoded ->setAccessible ( true );
149+ }
138150
139151 $ package = new Package_Command ();
140152
0 commit comments