Skip to content

Commit

Permalink
Merge branch refs/heads/1.11.x into 1.12.x
Browse files Browse the repository at this point in the history
  • Loading branch information
phpstan-bot authored Jul 14, 2024
2 parents c1e2e96 + 76464ee commit 87d2bec
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions conf/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -2106,6 +2106,8 @@ services:

phpstanDiagnoseExtension:
class: PHPStan\Diagnose\PHPStanDiagnoseExtension
arguments:
composerAutoloaderProjectPaths: %composerAutoloaderProjectPaths%
autowired: false

# Error formatters
Expand Down
31 changes: 30 additions & 1 deletion src/Diagnose/PHPStanDiagnoseExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,28 @@

namespace PHPStan\Diagnose;

use Phar;
use PHPStan\Command\Output;
use PHPStan\ExtensionInstaller\GeneratedConfig;
use PHPStan\Internal\ComposerHelper;
use PHPStan\Php\PhpVersion;
use function class_exists;
use function count;
use function dirname;
use function is_file;
use function sprintf;
use const PHP_VERSION_ID;

class PHPStanDiagnoseExtension implements DiagnoseExtension
{

public function __construct(private PhpVersion $phpVersion)
/**
* @param string[] $composerAutoloaderProjectPaths
*/
public function __construct(
private PhpVersion $phpVersion,
private array $composerAutoloaderProjectPaths,
)
{
}

Expand All @@ -30,11 +39,25 @@ public function print(Output $output): void
$this->phpVersion->getVersionString(),
$this->phpVersion->getSourceLabel(),
));
$output->writeLineFormatted('');

$output->writeLineFormatted(sprintf(
'<info>PHPStan version:</info> %s',
ComposerHelper::getPhpStanVersion(),
));
$output->writeLineFormatted('<info>PHPStan running from:</info>');
$pharRunning = Phar::running(false);
if ($pharRunning !== '') {
$output->writeLineFormatted(dirname($pharRunning));
} else {
if (isset($_SERVER['argv'][0]) && is_file($_SERVER['argv'][0])) {
$output->writeLineFormatted($_SERVER['argv'][0]);
} else {
$output->writeLineFormatted('Unknown');
}
}
$output->writeLineFormatted('');

if (class_exists('PHPStan\ExtensionInstaller\GeneratedConfig')) {
$output->writeLineFormatted('<info>Extension installer:</info>');
if (count(GeneratedConfig::EXTENSIONS) === 0) {
Expand All @@ -47,6 +70,12 @@ public function print(Output $output): void
$output->writeLineFormatted('<info>Extension installer:</info> Not installed');
}
$output->writeLineFormatted('');

$output->writeLineFormatted('<info>Discovered Composer project roots:</info>');
foreach ($this->composerAutoloaderProjectPaths as $composerAutoloaderProjectPath) {
$output->writeLineFormatted($composerAutoloaderProjectPath);
}
$output->writeLineFormatted('');
}

}

0 comments on commit 87d2bec

Please sign in to comment.