Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove Debug component leftovers #46614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 7, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use PHPUnit\Metadata\Api\Groups;
use PHPUnit\Util\Test;
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor;
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use Symfony\Component\ErrorHandler\DebugClassLoader;

class_exists(Groups::class);
Expand Down Expand Up @@ -81,7 +80,7 @@ public function __construct($message, array $trace, $file)
}

if ('trigger_error' === $trace[$j]['function'] && !isset($trace[$j]['class'])) {
if (\in_array($trace[1 + $j]['class'], [DebugClassLoader::class, LegacyDebugClassLoader::class], true)) {
if (DebugClassLoader::class === $trace[1 + $j]['class']) {
$class = $trace[1 + $j]['args'][0];
$this->triggeringFile = isset($trace[1 + $j]['args'][1]) ? realpath($trace[1 + $j]['args'][1]) : (new \ReflectionClass($class))->getFileName();
$this->getOriginalFilesStack();
Expand Down Expand Up @@ -323,9 +322,6 @@ private static function getVendors()
if (class_exists(DebugClassLoader::class, false)) {
self::$vendors[] = \dirname((new \ReflectionClass(DebugClassLoader::class))->getFileName());
}
if (class_exists(LegacyDebugClassLoader::class, false)) {
self::$vendors[] = \dirname((new \ReflectionClass(LegacyDebugClassLoader::class))->getFileName());
}
foreach (get_declared_classes() as $class) {
if ('C' === $class[0] && 0 === strpos($class, 'ComposerAutoloaderInit')) {
$r = new \ReflectionClass($class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Bridge\PhpUnit\DnsMock;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use Symfony\Component\ErrorHandler\DebugClassLoader;

/**
Expand Down Expand Up @@ -61,7 +60,7 @@ public function __construct(array $mockedNamespaces = [])
Blacklist::$blacklistedClassNames[__CLASS__] = 2;
}

$enableDebugClassLoader = class_exists(DebugClassLoader::class) || class_exists(LegacyDebugClassLoader::class);
$enableDebugClassLoader = class_exists(DebugClassLoader::class);

foreach ($mockedNamespaces as $type => $namespaces) {
if (!\is_array($namespaces)) {
Expand All @@ -82,11 +81,7 @@ public function __construct(array $mockedNamespaces = [])
}
}
if ($enableDebugClassLoader) {
if (class_exists(DebugClassLoader::class)) {
DebugClassLoader::enable();
} else {
LegacyDebugClassLoader::enable();
}
DebugClassLoader::enable();
}
if (self::$globallyEnabled) {
$this->state = -2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\DependencyInjection\Dumper;

use Composer\Autoload\ClassLoader;
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use Symfony\Component\DependencyInjection\Argument\AbstractArgument;
use Symfony\Component\DependencyInjection\Argument\ArgumentInterface;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
Expand Down Expand Up @@ -2193,7 +2192,7 @@ private function getAutoloadFile(): ?string
continue;
}

if ($autoloader[0] instanceof DebugClassLoader || $autoloader[0] instanceof LegacyDebugClassLoader) {
if ($autoloader[0] instanceof DebugClassLoader) {
$autoloader = $autoloader[0]->getClassLoader();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\HttpKernel\DependencyInjection;

use Composer\Autoload\ClassLoader;
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\ErrorHandler\DebugClassLoader;
Expand Down Expand Up @@ -93,7 +92,7 @@ private function getClassesInComposerClassMaps(): array
continue;
}

if ($function[0] instanceof DebugClassLoader || $function[0] instanceof LegacyDebugClassLoader) {
if ($function[0] instanceof DebugClassLoader) {
$function = $function[0]->getClassLoader();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Symfony\Component\HttpKernel\EventListener;

use Psr\Log\LoggerInterface;
use Symfony\Component\Debug\Exception\FlattenException as LegacyFlattenException;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -126,7 +125,7 @@ public function onControllerArguments(ControllerArgumentsEvent $event)
$r = new \ReflectionFunction($event->getController()(...));
$r = $r->getParameters()[$k] ?? null;

if ($r && (!($r = $r->getType()) instanceof \ReflectionNamedType || \in_array($r->getName(), [FlattenException::class, LegacyFlattenException::class], true))) {
if ($r && (!($r = $r->getType()) instanceof \ReflectionNamedType || FlattenException::class === $r->getName())) {
$arguments = $event->getArguments();
$arguments[$k] = FlattenException::createFromThrowable($e);
$event->setArguments($arguments);
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -513,7 +512,7 @@ protected function initializeContainer()

// Remove frames added by DebugClassLoader.
for ($i = \count($backtrace) - 2; 0 < $i; --$i) {
if (\in_array($backtrace[$i]['class'] ?? null, [DebugClassLoader::class, LegacyDebugClassLoader::class], true)) {
if (DebugClassLoader::class === ($backtrace[$i]['class'] ?? null)) {
$backtrace = [$backtrace[$i + 1]];
break;
}
Expand Down