bug #38713 [DI] Fix Preloader exception when preloading a class with an unknown parent/interface (rgeraads)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[DI] Fix Preloader exception when preloading a class with an unknown parent/interface

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #38693
| License       | MIT

Fixes Preloader exception when preloading a class with an unknown parent/interface.

Commits
-------

b6ae4858b9 [DI] Fix Preloader exception when preloading a class with an unknown parent/interface
This commit is contained in:
Nicolas Grekas 2020-10-27 11:05:49 +01:00
commit 19804e1a02
3 changed files with 31 additions and 1 deletions

View File

@ -87,7 +87,7 @@ class Preloader
self::preloadType($m->getReturnType(), $preloaded);
}
} catch (\ReflectionException $e) {
} catch (\Throwable $e) {
// ignore missing classes
}
}

View File

@ -34,6 +34,20 @@ class PreloaderTest extends TestCase
self::assertTrue(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\C', false));
}
/**
* @requires PHP 7.4
*/
public function testPreloadSkipsNonExistingInterface()
{
$r = new \ReflectionMethod(Preloader::class, 'doPreload');
$r->setAccessible(true);
$preloaded = [];
$r->invokeArgs(null, ['Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\DummyWithInterface', &$preloaded]);
self::assertFalse(class_exists('Symfony\Component\DependencyInjection\Tests\Fixtures\Preload\DummyWithInterface', false));
}
/**
* @requires PHP 8
*/

View File

@ -0,0 +1,16 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\DependencyInjection\Tests\Fixtures\Preload;
final class DummyWithInterface implements \NonExistentDummyInterface
{
}