Skip to content

Commit ba338c4

Browse files
committed
feat: Added support for dependency analysis with new commands and execution improvements.
Signed-off-by: Felipe Sayão Lobato Abreu <github@mentordosnerds.com>
1 parent a7749a8 commit ba338c4

File tree

4 files changed

+147
-614
lines changed

4 files changed

+147
-614
lines changed

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,21 @@
3636
"friendsofphp/php-cs-fixer": "^3.94",
3737
"icanhazstring/composer-unused": "^0.9.6",
3838
"jolicode/jolinotif": "^3.3",
39+
"nikic/php-parser": "^5.7",
3940
"phpdocumentor/shim": "^3.9",
4041
"phpro/grumphp": "^2.19",
42+
"phpspec/prophecy": "^1.26",
4143
"phpspec/prophecy-phpunit": "^2.5",
4244
"phpunit/phpunit": "^12.5",
45+
"psr/log": "^3.0",
4346
"pyrech/composer-changelogs": "^2.2",
4447
"rector/rector": "^2.3",
4548
"saggre/phpdocumentor-markdown": "^1.0",
4649
"shipmonk/composer-dependency-analyser": "^1.8.4",
50+
"symfony/console": "^7.3",
51+
"symfony/filesystem": "^7.4",
52+
"symfony/finder": "^7.4",
53+
"symfony/process": "^7.4",
4754
"symfony/var-dumper": "^7.4",
4855
"symfony/var-exporter": "^7.4",
4956
"symplify/easy-coding-standard": "^13.0",

src/Command/AbstractCommand.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -64,42 +64,36 @@ public function __construct(?Filesystem $filesystem = null)
6464
*
6565
* @param Process $command the configured process instance to run
6666
* @param OutputInterface $output the output interface to log warnings or results
67+
* @param bool $tty
6768
*
6869
* @return int the status code of the command execution
6970
*/
70-
protected function runProcess(Process $command, OutputInterface $output): int
71+
protected function runProcess(Process $command, OutputInterface $output, bool $tty = true): int
7172
{
7273
/** @var ProcessHelper $processHelper */
7374
$processHelper = $this->getHelper('process');
7475

7576
$command = $command->setWorkingDirectory($this->getCurrentWorkingDirectory());
7677
$callback = null;
7778

78-
if (Process::isTtySupported()) {
79-
$command->setTty(true);
80-
} else {
79+
try {
80+
$command->setTty($tty);
81+
} catch (RuntimeException) {
8182
$output->writeln(
8283
'<comment>Warning: TTY is not supported. The command may not display output as expected.</comment>'
8384
);
85+
$tty = false;
86+
}
8487

88+
if (! $tty) {
8589
$callback = function (string $type, string $buffer) use ($output): void {
8690
$output->write($buffer);
8791
};
8892
}
8993

9094
$process = $processHelper->run(output: $output, cmd: $command, callback: $callback);
9195

92-
if (! $process->isSuccessful()) {
93-
$output->writeln(\sprintf(
94-
'<error>Command "%s" failed with exit code %d. Please check the output above for details.</error>',
95-
$command->getCommandLine(),
96-
$command->getExitCode()
97-
));
98-
99-
return self::FAILURE;
100-
}
101-
102-
return self::SUCCESS;
96+
return $process->isSuccessful() ? self::SUCCESS : self::FAILURE;
10397
}
10498

10599
/**

0 commit comments

Comments
 (0)