Skip to content

Commit 1f0abfc

Browse files
committed
emit warnings when xdebug is not used according th cli-flags
1 parent 4434674 commit 1f0abfc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/Command/CommandHelper.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,27 @@ public static function begin(
9191
bool $cleanupContainerCache = true,
9292
): InceptionResult
9393
{
94-
if (!$allowXdebug) {
95-
$xdebug = new XdebugHandler('phpstan');
96-
$xdebug->setPersistent();
97-
$xdebug->check();
98-
unset($xdebug);
99-
}
100-
10194
$stdOutput = new SymfonyOutput($output, new SymfonyStyle(new ErrorsConsoleStyle($input, $output)));
10295

10396
/** @var Output $errorOutput */
10497
$errorOutput = (static function () use ($input, $output): Output {
10598
$symfonyErrorOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
10699
return new SymfonyOutput($symfonyErrorOutput, new SymfonyStyle(new ErrorsConsoleStyle($input, $symfonyErrorOutput)));
107100
})();
101+
102+
if ($allowXdebug && !XdebugHandler::isXdebugActive()) {
103+
$errorOutput->getStyle()->note('You are running with "--xdebug" enabled, but the Xdebug PHP extension is not active. The process will not halt at breakpoints.');
104+
} elseif (!$allowXdebug && XdebugHandler::isXdebugActive()) {
105+
$errorOutput->getStyle()->note('The Xdebug PHP extension is active, but "--xdebug" is not used. This may slow down performance and the process will not halt at breakpoints.');
106+
}
107+
108+
if (!$allowXdebug) {
109+
$xdebug = new XdebugHandler('phpstan');
110+
$xdebug->setPersistent();
111+
$xdebug->check();
112+
unset($xdebug);
113+
}
114+
108115
if ($memoryLimit !== null) {
109116
if (Strings::match($memoryLimit, '#^-?\d+[kMG]?$#i') === null) {
110117
$errorOutput->writeLineFormatted(sprintf('Invalid memory limit format "%s".', $memoryLimit));

0 commit comments

Comments
 (0)