[DI] Fix Preloader exception when preloading a class with an unknown parent/interface
This commit is contained in:
parent
3e5cc2f75d
commit
b6ae4858b9
@ -87,7 +87,7 @@ class Preloader
|
||||
|
||||
self::preloadType($m->getReturnType(), $preloaded);
|
||||
}
|
||||
} catch (\ReflectionException $e) {
|
||||
} catch (\Throwable $e) {
|
||||
// ignore missing classes
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user