Skip to content

Commit

Permalink
Fixed the DebugClassLoader compatibility with eval()'d code on Darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
skalpa authored and nicolas-grekas committed Feb 24, 2019
1 parent 9202d9e commit 6c2aa24
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Symfony/Component/Debug/DebugClassLoader.php
Expand Up @@ -390,6 +390,11 @@ private function darwinRealpath($real)

$dirFiles = self::$darwinCache[$kDir][1];

if (!isset($dirFiles[$file]) && ') : eval()\'d code' === substr($file, -17)) {
// Get the file name from "file_name.php(123) : eval()'d code"
$file = substr($file, 0, strrpos($file, '(', -17));
}

if (isset($dirFiles[$file])) {
return $real .= $dirFiles[$file];
}
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/Component/Debug/Tests/DebugClassLoaderTest.php
Expand Up @@ -385,6 +385,11 @@ class_exists('Test\\'.__NAMESPACE__.'\\UseTraitWithInternalMethod', true);

$this->assertSame([], $deprecations);
}

public function testEvaluatedCode()
{
$this->assertTrue(class_exists(__NAMESPACE__.'\Fixtures\DefinitionInEvaluatedCode', true));
}
}

class ClassLoader
Expand Down
@@ -0,0 +1,11 @@
<?php

namespace Symfony\Component\Debug\Tests\Fixtures;

eval('
namespace Symfony\Component\Debug\Tests\Fixtures;
class DefinitionInEvaluatedCode
{
}
');

0 comments on commit 6c2aa24

Please sign in to comment.