8000 [Debug] Remove false-positive check in DebugClassLoader by nicolas-grekas · Pull Request #23989 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
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
6 changes: 4 additions & 2 deletions src/Symfony/Component/Debug/DebugClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class DebugClassLoader
{
private $classLoader;
private $isFinder;
private $loaded = array();
private $wasFinder;
private static $caseCheck;
private static $deprecated = array();
Expand Down Expand Up @@ -164,9 +165,10 @@ public function loadClass($class)
ErrorHandler::stackErrors();

try {
if ($this->isFinder) {
if ($this->isFinder && !isset($this->loaded[$class])) {
$this->loaded[$class] = true;
if ($file = $this->classLoader[0]->findFile($class)) {
require_once $file;
require $file;
}
} else {
call_user_func($this->classLoader, $class);
Expand Down
19 changes: 19 additions & 0 deletions src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,23 @@ public function testIdempotence()
$this->fail('DebugClassLoader did not register');
}

/**
* @expectedException \Exception
* @expectedExceptionMessage boo
*/
public function testThrowingClass()
{
try {
class_exists(__NAMESPACE__.'\Fixtures\Throwing');
$this->fail('Exception expected');
} catch (\Exception $e) {
$this->assertSame('boo', $e->getMessage());
}

// the second call also should throw
class_exists(__NAMESPACE__.'\Fixtures\Throwing');
}

public function testUnsilencing()
{
if (\PHP_VERSION_ID >= 70000) {
Expand Down Expand Up @@ -128,6 +145,7 @@ class ChildTestingStacking extends TestingStacking { function foo($bar) {} }

/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Case mismatch between loaded and declared class names
*/
public function testNameCaseMismatch()
{
Expand All @@ -149,6 +167,7 @@ class_exists(__NAMESPACE__.'\Fixtures\CaseMismatch', true);

/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Case mismatch between loaded and declared class names
*/
public function testPsr4CaseMismatch()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

throw new \Exception('boo');
0