Skip to content

THRIFT-5934: Fix deprecated usage of ReflectionProperty::setAccessible() in PHP tests#3352

Merged
Jens-G merged 1 commit intoapache:masterfrom
pkvach:fix-THRIFT-5934
Mar 24, 2026
Merged

THRIFT-5934: Fix deprecated usage of ReflectionProperty::setAccessible() in PHP tests#3352
Jens-G merged 1 commit intoapache:masterfrom
pkvach:fix-THRIFT-5934

Conversation

@pkvach
Copy link
Contributor

@pkvach pkvach commented Mar 21, 2026

Running PHPUnit tests on PHP 8.5 produces deprecation warnings related to usage of ReflectionProperty::setAccessible().

Example failure:

PHP Deprecated: Method `ReflectionProperty::setAccessible()` is deprecated since 8.5, as it has no effect since PHP 8.1

According to official PHP documentation, ReflectionProperty::setAccessible() is deprecated as of PHP 8.5 and has had no effect since PHP 8.1, where all properties are accessible by default.
https://www.php.net/manual/en/reflectionproperty.setaccessible.php

Note

This will not affect earlier PHP versions, meaning the changes are backward compatible.

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes)
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

@sveneld
Copy link
Contributor

sveneld commented Mar 22, 2026

LGTM.

@Jens-G
Copy link
Member

Jens-G commented Mar 22, 2026

Run vendor/bin/phpunit -c lib/php/phpunit.xml
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

........E

Time: 633 ms, Memory: 12.00 MB

There was 1 error:

1) Test\Thrift\Unit\Lib\Factory\TBinaryProtocolFactoryTest::testGetProtocol with data set "allTrue" (true, true)
TypeError: Argument 1 passed to Test\Thrift\Unit\Lib\Factory\TBinaryProtocolFactoryTest::getPropertyValue() must be an instance of Test\Thrift\Unit\Lib\object, instance of Thrift\Protocol\TBinaryProtocol given, called in /home/runner/work/thrift/thrift/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php on line 50

/home/runner/work/thrift/thrift/lib/php/test/Unit/Lib/ReflectionHelper.php:53
/home/runner/work/thrift/thrift/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php:50

ERRORS!
Tests: 9, Assertions: 25, Errors: 1.

@pkvach
Copy link
Contributor Author

pkvach commented Mar 22, 2026

Run vendor/bin/phpunit -c lib/php/phpunit.xml
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

........E

Time: 633 ms, Memory: 12.00 MB

There was 1 error:

1) Test\Thrift\Unit\Lib\Factory\TBinaryProtocolFactoryTest::testGetProtocol with data set "allTrue" (true, true)
TypeError: Argument 1 passed to Test\Thrift\Unit\Lib\Factory\TBinaryProtocolFactoryTest::getPropertyValue() must be an instance of Test\Thrift\Unit\Lib\object, instance of Thrift\Protocol\TBinaryProtocol given, called in /home/runner/work/thrift/thrift/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php on line 50

/home/runner/work/thrift/thrift/lib/php/test/Unit/Lib/ReflectionHelper.php:53
/home/runner/work/thrift/thrift/lib/php/test/Unit/Lib/Factory/TBinaryProtocolFactoryTest.php:50

ERRORS!
Tests: 9, Assertions: 25, Errors: 1.

Fixed the test failure in the latest commit, thanks!

@Jens-G Jens-G merged commit 9f1fb7a into apache:master Mar 24, 2026
136 of 137 checks passed
@pkvach pkvach deleted the fix-THRIFT-5934 branch March 25, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants