Skip to content

Commit

Permalink
[Config] dont catch instances of Error
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Feb 3, 2020
1 parent 6abc18b commit 03328d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Resource/ClassExistenceResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public function isFresh($timestamp)
}
} catch (\Throwable $e) {
$exists[1] = $e->getMessage();

throw $e;
} finally {
self::$autoloadedClass = $autoloadedClass;
if (!--self::$autoloadLevel) {
Expand Down
7 changes: 7 additions & 0 deletions Tests/Fixtures/ParseError.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Symfony\Component\Config\Tests\Fixtures;

class ParseError
{
// missing closing bracket
12 changes: 12 additions & 0 deletions Tests/Resource/ClassExistenceResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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
Expand Down Expand Up @@ -115,4 +116,15 @@ public function testConditionalClass()

$this->assertFalse($res->isFresh(0));
}

/**
* @requires PHP 7
*/
public function testParseError()
{
$this->expectException('ParseError');

$res = new ClassExistenceResource(ParseError::class, false);
$res->isFresh(0);
}
}

0 comments on commit 03328d6

Please sign in to comment.