Skip to content

Commit e909a07

Browse files
committed
DiagnoseExtension
1 parent 1bd7c33 commit e909a07

4 files changed

+39
-1
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"require": {
1616
"php": "^7.2 || ^8.0",
1717
"ext-simplexml": "*",
18-
"phpstan/phpstan": "^1.11"
18+
"phpstan/phpstan": "^1.11.7"
1919
},
2020
"conflict": {
2121
"symfony/framework-bundle": "<3.0"

extension.neon

+4
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,10 @@ services:
322322
class: PHPStan\Symfony\PasswordAuthenticatedUserStubFilesExtension
323323
tags:
324324
- phpstan.stubFilesExtension
325+
-
326+
class: PHPStan\Symfony\SymfonyDiagnoseExtension
327+
tags:
328+
- phpstan.diagnoseExtension
325329

326330
# FormInterface::getErrors() return type
327331
-

src/Symfony/ConsoleApplicationResolver.php

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ public function __construct(Configuration $configuration)
2727
$this->consoleApplicationLoader = $configuration->getConsoleApplicationLoader();
2828
}
2929

30+
public function hasConsoleApplicationLoader(): bool
31+
{
32+
return $this->consoleApplicationLoader !== null;
33+
}
34+
3035
private function getConsoleApplication(): ?Application
3136
{
3237
if ($this->consoleApplicationLoader === null) {
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace PHPStan\Symfony;
4+
5+
use PHPStan\Command\Output;
6+
use PHPStan\Diagnose\DiagnoseExtension;
7+
use function sprintf;
8+
9+
class SymfonyDiagnoseExtension implements DiagnoseExtension
10+
{
11+
12+
/** @var ConsoleApplicationResolver */
13+
private $consoleApplicationResolver;
14+
15+
public function __construct(ConsoleApplicationResolver $consoleApplicationResolver)
16+
{
17+
$this->consoleApplicationResolver = $consoleApplicationResolver;
18+
}
19+
20+
public function print(Output $output): void
21+
{
22+
$output->writeLineFormatted(sprintf(
23+
'<info>Symfony\'s consoleApplicationLoader:</info> %s',
24+
$this->consoleApplicationResolver->hasConsoleApplicationLoader() ? 'In use' : 'No'
25+
));
26+
$output->writeLineFormatted('');
27+
}
28+
29+
}

0 commit comments

Comments
 (0)