bug #38169 [PhpUnitBridge] Internal classes are not legacy (derrabus)

This PR was submitted for the master branch but it was merged into the 4.4 branch instead.

Discussion
----------

[PhpUnitBridge] Internal classes are not legacy

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #37564
| License       | MIT
| Doc PR        | N/A

This change works around the issue that we can observe in the failed Travis build of #38103.

We must not call PHPUnit's internal `Test::getGroups()` method with a built-in class, otherwise we will run into a TypeError. This won't be fixed on PHPUnit's side, so we need to prevent that call. Our DeprecationErrorHander might run into this case if a deprecation is triggered while autoloading a class.

And forgive me, I've had a really hard time trying to craft a test case for that. 🙈

Commits
-------

7d55e0c065 Internal classes are not legacy.
This commit is contained in:
Fabien Potencier 2020-09-13 06:54:39 +02:00
commit efb255ce5c

View File

@ -143,6 +143,10 @@ class Deprecation
public function isLegacy()
{
$class = $this->originatingClass();
if ((new \ReflectionClass($class))->isInternal()) {
return false;
}
$method = $this->originatingMethod();
return 0 === strpos($method, 'testLegacy')