services: Do not use deprecated ReflectionType::__toString() in tests
authorMáté Szabó <mszabo@wikia-inc.com>
Mon, 16 Sep 2019 19:14:07 +0000 (21:14 +0200)
committerMáté Szabó <mszabo@wikia-inc.com>
Mon, 16 Sep 2019 19:14:07 +0000 (21:14 +0200)
commiteafbacb43ca433141c72c81558ed44ad5ff52694
tree0bb229032e298e559f4ec8425cf1389af1787956
parent6ebfe8578c8a14913df2426583a68b2a0803e6d2
services: Do not use deprecated ReflectionType::__toString() in tests

The \MediaWikiServicesTest::provideGetService() PHPUnit data provider
method uses the ReflectionType::__toString() method to obtain the
return type of service instantiator callables as a string.

In PHP 7.4, calling this method generates an E_DEPRECATED notice.
The solution is to use ReflectionType::getName() instead, available
since PHP 7.1.[1]

This patch updates the method to use ReflectionType::getName()
if it is available, and fall back to ReflectionType::__toString()
otherwise.

---
[1] https://github.com/php/php-src/blob/php-7.4.0RC1/UPGRADING#L395

Bug: T233012
Change-Id: I69b97f75795e6c4e005bf1a23fb798f7e52da2fd
tests/phpunit/includes/MediaWikiServicesTest.php