Skip to content

Commit

Permalink
DiagnoseExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 16, 2024
1 parent 1bd7c33 commit e909a07
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"require": {
"php": "^7.2 || ^8.0",
"ext-simplexml": "*",
"phpstan/phpstan": "^1.11"
"phpstan/phpstan": "^1.11.7"
},
"conflict": {
"symfony/framework-bundle": "<3.0"
Expand Down
4 changes: 4 additions & 0 deletions extension.neon
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ services:
class: PHPStan\Symfony\PasswordAuthenticatedUserStubFilesExtension
tags:
- phpstan.stubFilesExtension
-
class: PHPStan\Symfony\SymfonyDiagnoseExtension
tags:
- phpstan.diagnoseExtension

# FormInterface::getErrors() return type
-
Expand Down
5 changes: 5 additions & 0 deletions src/Symfony/ConsoleApplicationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public function __construct(Configuration $configuration)
$this->consoleApplicationLoader = $configuration->getConsoleApplicationLoader();
}

public function hasConsoleApplicationLoader(): bool
{
return $this->consoleApplicationLoader !== null;
}

private function getConsoleApplication(): ?Application
{
if ($this->consoleApplicationLoader === null) {
Expand Down
29 changes: 29 additions & 0 deletions src/Symfony/SymfonyDiagnoseExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php declare(strict_types = 1);

namespace PHPStan\Symfony;

use PHPStan\Command\Output;
use PHPStan\Diagnose\DiagnoseExtension;
use function sprintf;

class SymfonyDiagnoseExtension implements DiagnoseExtension
{

/** @var ConsoleApplicationResolver */
private $consoleApplicationResolver;

public function __construct(ConsoleApplicationResolver $consoleApplicationResolver)
{
$this->consoleApplicationResolver = $consoleApplicationResolver;
}

public function print(Output $output): void
{
$output->writeLineFormatted(sprintf(
'<info>Symfony\'s consoleApplicationLoader:</info> %s',
$this->consoleApplicationResolver->hasConsoleApplicationLoader() ? 'In use' : 'No'
));
$output->writeLineFormatted('');
}

}

0 comments on commit e909a07

Please sign in to comment.