Skip to content

Commit 04a087d

Browse files
committed
Merge branch 'master' into 3.0
2 parents 114bb0e + 45987c9 commit 04a087d

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

src/Console/Application.php

+27-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use PhpCsFixer\Console\SelfUpdate\NewVersionChecker;
2525
use PhpCsFixer\PharChecker;
2626
use PhpCsFixer\ToolInfo;
27+
use PhpCsFixer\Utils;
2728
use Symfony\Component\Console\Application as BaseApplication;
2829
use Symfony\Component\Console\Command\ListCommand;
2930
use Symfony\Component\Console\Input\InputInterface;
@@ -78,16 +79,39 @@ public function doRun(InputInterface $input, OutputInterface $output): int
7879
? $output->getErrorOutput()
7980
: ($input->hasParameterOption('--format', true) && 'txt' !== $input->getParameterOption('--format', null, true) ? null : $output)
8081
;
82+
8183
if (null !== $stdErr) {
8284
$warningsDetector = new WarningsDetector($this->toolInfo);
8385
$warningsDetector->detectOldVendor();
8486
$warningsDetector->detectOldMajor();
85-
foreach ($warningsDetector->getWarnings() as $warning) {
86-
$stdErr->writeln(sprintf($stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s', $warning));
87+
$warnings = $warningsDetector->getWarnings();
88+
89+
if ($warnings) {
90+
foreach ($warnings as $warning) {
91+
$stdErr->writeln(sprintf($stdErr->isDecorated() ? '<bg=yellow;fg=black;>%s</>' : '%s', $warning));
92+
}
93+
$stdErr->writeln('');
94+
}
95+
}
96+
97+
$result = parent::doRun($input, $output);
98+
99+
if (
100+
null !== $stdErr
101+
&& $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE
102+
) {
103+
$triggeredDeprecations = array_unique(Utils::getTriggeredDeprecations());
104+
sort($triggeredDeprecations);
105+
if ($triggeredDeprecations) {
106+
$stdErr->writeln('');
107+
$stdErr->writeln($stdErr->isDecorated() ? '<bg=yellow;fg=black;>Detected deprecations in use:</>' : 'Detected deprecations in use:');
108+
foreach ($triggeredDeprecations as $deprecation) {
109+
$stdErr->writeln(sprintf('- %s', $deprecation));
110+
}
87111
}
88112
}
89113

90-
return parent::doRun($input, $output);
114+
return $result;
91115
}
92116

93117
/**

src/Utils.php

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
*/
2727
final class Utils
2828
{
29+
private static $deprecations = [];
30+
2931
/**
3032
* Converts a camel cased string to a snake cased string.
3133
*/
@@ -161,6 +163,12 @@ public static function triggerDeprecation(string $message, string $exceptionClas
161163
throw new $exceptionClass("{$message} This check was performed as `PHP_CS_FIXER_FUTURE_MODE` env var is set.");
162164
}
163165

166+
self::$deprecations[] = $message;
164167
@trigger_error($message, E_USER_DEPRECATED);
165168
}
169+
170+
public static function getTriggeredDeprecations(): array
171+
{
172+
return self::$deprecations;
173+
}
166174
}

0 commit comments

Comments
 (0)