diff --git a/.changes/unreleased/Removed-20260603-135200.yaml b/.changes/unreleased/Removed-20260603-135200.yaml new file mode 100644 index 00000000..340c7d85 --- /dev/null +++ b/.changes/unreleased/Removed-20260603-135200.yaml @@ -0,0 +1,2 @@ +kind: Removed +body: Remove deprecated `Overtrue\PHPLint\Client`. diff --git a/docs/assets/linter-uml-diagram.svg b/docs/assets/linter-uml-diagram.svg index 36853f20..cf623b4d 100644 --- a/docs/assets/linter-uml-diagram.svg +++ b/docs/assets/linter-uml-diagram.svg @@ -1,28 +1,28 @@ - - - + + cluster_0 - -Overtrue\PHPLint + +Overtrue\PHPLint Overtrue\\PHPLint\\Linter - - - -Linter - - -+ __construct(configResolver : Overtrue\PHPLint\Configuration\Resolver, dispatcher : Symfony\Component\EventDispatcher\EventDispatcherInterface, client : Overtrue\PHPLint\Client = «unknown», helperSet : Symfony\Component\Console\Helper\HelperSet = «unknown», output : Symfony\Component\Console\Output\OutputInterface = «unknown») -+ lintFiles(finder : Symfony\Component\Finder\Finder, startTime : float = «unknown») : Overtrue\PHPLint\Output\LinterOutput + + + +Linter + + ++ __construct(configResolver : Overtrue\PHPLint\Configuration\Resolver, dispatcher : Symfony\Component\EventDispatcher\EventDispatcherInterface, contextDefaults : array = [], helperSet : Symfony\Component\Console\Helper\HelperSet = «unknown», output : Symfony\Component\Console\Output\OutputInterface = «unknown») ++ lintFiles(finder : Symfony\Component\Finder\Finder, startTime : float = «unknown») : Overtrue\PHPLint\Output\LinterOutput diff --git a/src/Client.php b/src/Client.php deleted file mode 100644 index a7136e63..00000000 --- a/src/Client.php +++ /dev/null @@ -1,31 +0,0 @@ -application; - } -} diff --git a/src/Command/LintCommand.php b/src/Command/LintCommand.php index 39966b27..0cf7780e 100644 --- a/src/Command/LintCommand.php +++ b/src/Command/LintCommand.php @@ -13,7 +13,6 @@ namespace Overtrue\PHPLint\Command; -use Overtrue\PHPLint\Client; use Overtrue\PHPLint\Configuration\ConsoleOptionsResolver; use Overtrue\PHPLint\Configuration\FileOptionsResolver; use Overtrue\PHPLint\Configuration\OptionDefinition; @@ -87,7 +86,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $linter = new Linter( $configResolver, $this->dispatcher, - new Client($this->getApplication()), + [ + 'application_version' => [ + 'long' => $this->getApplication()->getLongVersion(), + 'short' => $this->getApplication()->getVersion(), + ], + ], $this->getHelperSet(), $output ); diff --git a/src/Linter.php b/src/Linter.php index cf2e798c..3a7db575 100644 --- a/src/Linter.php +++ b/src/Linter.php @@ -60,7 +60,7 @@ final class Linter public function __construct( Resolver $configResolver, EventDispatcherInterface $dispatcher, - private readonly ?Client $client = null, + private readonly array $contextDefaults = [], ?HelperSet $helperSet = null, ?OutputInterface $output = null, ) { @@ -118,16 +118,8 @@ public function lintFiles(Finder $finder, ?float $startTime = null): LinterOutpu $results = []; } - if (null !== $this->client) { - $default = [ - 'application_version' => [ - 'long' => $this->client->getApplication()->getLongVersion(), - 'short' => $this->client->getApplication()->getVersion(), - ] - ]; - } $finalResults = new LinterOutput($results, $finder); - $finalResults->setContext($this->configResolver, $startTime, $processCount, $default ?? []); + $finalResults->setContext($this->configResolver, $startTime, $processCount, $this->contextDefaults); $this->cache->prune(); diff --git a/tests/EndToEnd/LintCommandTest.php b/tests/EndToEnd/LintCommandTest.php index fb9cb430..0331cf57 100644 --- a/tests/EndToEnd/LintCommandTest.php +++ b/tests/EndToEnd/LintCommandTest.php @@ -70,6 +70,15 @@ public function testLintDirectoryWithoutConfigurationAndCache(): void 2, $this->command->getResults()->getMisses() ); + + $this->assertSame( + $this->command->getApplication()?->getVersion(), + $this->command->getResults()->getContext()['application_version']['short'] + ); + $this->assertSame( + $this->command->getApplication()?->getLongVersion(), + $this->command->getResults()->getContext()['application_version']['long'] + ); } public function testLintSyntaxErrorFileWithoutConfigurationAndCache(): void