File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -245,9 +245,19 @@ private function reset_php_codesniffer_config() {
245245 */
246246 $ reflected_phpcs_config = new \ReflectionClass ( Config::class );
247247 $ overridden_defaults = $ reflected_phpcs_config ->getProperty ( 'overriddenDefaults ' );
248- $ overridden_defaults ->setAccessible ( true );
248+
249+ /*
250+ * The setAccessible function has no effect in PHP >= 8.1, and it is marked as deprecated in PHP 8.5.
251+ * Since the tests are also run on PHP 7.4 and 8.0, we can only call the function if the php version is lower than 8.1.
252+ */
253+ if ( version_compare ( PHP_VERSION , '8.1.0 ' , '< ' ) ) {
254+ $ overridden_defaults ->setAccessible ( true );
255+ }
249256 $ overridden_defaults ->setValue ( $ reflected_phpcs_config , array () );
250- $ overridden_defaults ->setAccessible ( false );
257+
258+ if ( version_compare ( PHP_VERSION , '8.1.0 ' , '< ' ) ) {
259+ $ overridden_defaults ->setAccessible ( false );
260+ }
251261 }
252262 }
253263}
You can’t perform that action at this time.
0 commit comments