1
0
Fork 0

Add handling for dir, file and class magic constants when loading plugins, fixes #4975

pull/4977/head
Jordi Boggiano 2016-02-29 13:49:36 +00:00
parent 070ee50693
commit 49b0bd75b3
1 changed files with 5 additions and 1 deletions

View File

@ -169,8 +169,12 @@ class PluginManager
foreach ($classes as $class) {
if (class_exists($class, false)) {
$code = file_get_contents($classLoader->findFile($class));
$path = $classLoader->findFile($class);
$code = file_get_contents($path);
$code = preg_replace('{^((?:final\s+)?(?:\s*))class\s+(\S+)}mi', '$1class $2_composer_tmp'.self::$classCounter, $code);
$code = str_replace('__FILE__', "'$path'", $code);
$code = str_replace('__DIR__', "'".dirname($path)."'", $code);
$code = str_replace('__CLASS__', "'$class'", $code);
eval('?>'.$code);
$class .= '_composer_tmp'.self::$classCounter;
self::$classCounter++;