Page MenuHomePhabricator

Wikimedia::TestingAccessWrapper raises a deprecation warning in PHP 8.3
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • In a fresh directory, run composer require wikimedia/testing-access-wrapper
  • Create the following test file:
<?php

use Wikimedia\TestingAccessWrapper;

require './vendor/autoload.php';

error_reporting( E_ALL );

class Foo {
    private static $staticField;
}

$wrapper = TestingAccessWrapper::newFromClass( Foo::class );
$wrapper->staticField = true;
  • Run the test file with PHP 8.3.

What happens?:

PHP Deprecated:  Calling ReflectionProperty::setValue() with a 1st argument which is not null or an object is deprecated in /tmp/test/vendor/wikimedia/testing-access-wrapper/src/TestingAccessWrapper.php on line 114

What should have happened instead?:

No output.

Software version (skip for WMF-hosted wikis like Wikipedia):

wikimedia/testing-access-wrapper 2.0.0

Other information (browser name/version, screenshots, etc.):

N/A

Event Timeline

Change 977830 had a related patch set uploaded (by Ammarpad; author: Ammarpad):

[testing-access-wrapper@master] Avoid deprecation warning for static properties

https://gerrit.wikimedia.org/r/977830

Change 977830 merged by jenkins-bot:

[testing-access-wrapper@master] Avoid deprecation warning for static properties

https://gerrit.wikimedia.org/r/977830

Jdforrester-WMF subscribed.

CI is still not going to be voting on 8.3 (or 8.2) due to T325321, but thank you!

CI is still not going to be voting on 8.3 (or 8.2) due to T325321, but thank you!

I've used TestingAccessWrapper in a few projects outside of MediaWiki, since it makes using reflection in tests less boilerplate-y. I hope a release of the package comes soon so we can start our own testing with 8.3, this is the only blocker we have left.

  NODES