8000 [DI] Fix Preloader exception when preloading a class with an unknown parent/interface by rgeraads · Pull Request #38713 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[DI] Fix Preloader exception when preloading a class with an unknown …
…parent/interface
  • Loading branch information
Randy Geraads authored and nicolas-grekas committed Oct 27, 2020
commit b6ae4858b91342f0b3186f0885d60a7540138bf3
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private static function doPreload(string $class, array &$preloaded): void

self::preloadType($m->getReturnType(), $preloaded);
}
} catch (\ReflectionException $e) {
} catch (\Throwable $e) {
// ignore missing classes
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ public function testPreload()
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
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
}
0