bug #35557 [Config] dont catch instances of Error (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[Config] dont catch instances of Error

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #35445, fix #35256
| License       | MIT
| Doc PR        | -

Commits
-------

e94c3fb87d [Config] dont catch instances of Error
This commit is contained in:
Nicolas Grekas 2020-02-03 09:12:41 +01:00
commit 78641e0e88
3 changed files with 21 additions and 0 deletions

View File

@ -92,6 +92,8 @@ class ClassExistenceResource implements SelfCheckingResourceInterface, \Serializ
}
} catch (\Throwable $e) {
$exists[1] = $e->getMessage();
throw $e;
} finally {
self::$autoloadedClass = $autoloadedClass;
if (!--self::$autoloadLevel) {

View File

@ -0,0 +1,7 @@
<?php
namespace Symfony\Component\Config\Tests\Fixtures;
class ParseError
{
// missing closing bracket

View File

@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\ClassExistenceResource;
use Symfony\Component\Config\Tests\Fixtures\BadFileName;
use Symfony\Component\Config\Tests\Fixtures\BadParent;
use Symfony\Component\Config\Tests\Fixtures\ParseError;
use Symfony\Component\Config\Tests\Fixtures\Resource\ConditionalClass;
class ClassExistenceResourceTest extends TestCase
@ -115,4 +116,15 @@ EOF
$this->assertFalse($res->isFresh(0));
}
/**
* @requires PHP 7
*/
public function testParseError()
{
$this->expectException('ParseError');
$res = new ClassExistenceResource(ParseError::class, false);
$res->isFresh(0);
}
}