Skip to content

Commit

Permalink
Use Composer InstalledVersions
Browse files Browse the repository at this point in the history
  • Loading branch information
herndlm committed Aug 10, 2022
1 parent 43de398 commit 1ebd2c3
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 101 deletions.
3 changes: 1 addition & 2 deletions bin/phpstan
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env php
<?php declare(strict_types=1);

use PackageVersions\Versions;
use PHPStan\Command\AnalyseCommand;
use PHPStan\Command\ClearResultCacheCommand;
use PHPStan\Command\FixerWorkerCommand;
Expand Down Expand Up @@ -155,7 +154,7 @@ use Symfony\Component\Console\Helper\ProgressBar;

$version = 'Version unknown';
try {
$version = explode('@', Versions::getVersion('phpstan/phpstan'))[0] ?: $version;
$version = \Composer\InstalledVersions::getPrettyVersion('phpstan/phpstan') ?: $version;
} catch (\OutOfBoundsException $e) {

}
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
],
"require": {
"php": "^8.0",
"composer-runtime-api": "^2.0",
"clue/block-react": "^1.4",
"clue/ndjson-react": "^1.0",
"composer/ca-bundle": "^1.2",
"composer/package-versions-deprecated": "1.11.99.5",
"composer/xdebug-handler": "^3.0.3",
"hoa/compiler": "3.17.08.08",
"hoa/exception": "^1.0",
Expand Down Expand Up @@ -68,7 +68,6 @@
"platform-check": false,
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"vaimo/composer-patches": true
}
},
Expand Down
78 changes: 3 additions & 75 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ parameters:
count: 1
path: src/Analyser/NodeScopeResolver.php

-
message: """
#^Call to method getVersion\\(\\) of deprecated class PackageVersions\\\\Versions\\:
in favor of the Composer\\\\InstalledVersions class provided by Composer 2\\. Require composer\\-runtime\\-api\\:\\^2 to ensure it is present\\.$#
"""
count: 1
path: src/Analyser/ResultCache/ResultCacheManager.php

-
message: "#^Template type TNodeType is declared as covariant, but occurs in contravariant position in parameter node of method PHPStan\\\\Collectors\\\\Collector\\:\\:processNode\\(\\)\\.$#"
count: 1
Expand Down Expand Up @@ -121,14 +113,6 @@ parameters:
count: 1
path: src/Command/FixerApplication.php

-
message: """
#^Call to method getVersion\\(\\) of deprecated class PackageVersions\\\\Versions\\:
in favor of the Composer\\\\InstalledVersions class provided by Composer 2\\. Require composer\\-runtime\\-api\\:\\^2 to ensure it is present\\.$#
"""
count: 1
path: src/Command/FixerApplication.php

-
message: "#^Parameter \\#1 \\$arg of function escapeshellarg expects string, string\\|false given\\.$#"
count: 1
Expand Down
5 changes: 2 additions & 3 deletions src/Analyser/ResultCache/ResultCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace PHPStan\Analyser\ResultCache;

use Composer\InstalledVersions;
use Nette\DI\Definitions\Statement;
use Nette\Neon\Neon;
use OutOfBoundsException;
use PackageVersions\Versions;
use PHPStan\Analyser\AnalyserResult;
use PHPStan\Analyser\Error;
use PHPStan\Collectors\CollectedData;
Expand All @@ -29,7 +29,6 @@
use function array_unique;
use function array_values;
use function count;
use function explode;
use function get_loaded_extensions;
use function is_array;
use function is_file;
Expand Down Expand Up @@ -809,7 +808,7 @@ private function getExecutedFileHashes(): array
private function getPhpStanVersion(): string
{
try {
return explode('@', Versions::getVersion('phpstan/phpstan'))[0];
return InstalledVersions::getPrettyVersion('phpstan/phpstan') ?? '';
} catch (OutOfBoundsException) {
return 'Version unknown';
}
Expand Down
5 changes: 2 additions & 3 deletions src/Command/FixerApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use Clue\React\NDJson\Decoder;
use Clue\React\NDJson\Encoder;
use Composer\CaBundle\CaBundle;
use Composer\InstalledVersions;
use DateTime;
use DateTimeImmutable;
use DateTimeZone;
use Nette\Utils\Json;
use OutOfBoundsException;
use PackageVersions\Versions;
use Phar;
use PHPStan\Analyser\AnalyserResult;
use PHPStan\Analyser\Error;
Expand Down Expand Up @@ -52,7 +52,6 @@
use function count;
use function defined;
use function escapeshellarg;
use function explode;
use function fclose;
use function fopen;
use function fwrite;
Expand Down Expand Up @@ -561,7 +560,7 @@ private function reanalyseAfterFileChanges(
private function getPhpstanVersion(): string
{
try {
return explode('@', Versions::getVersion('phpstan/phpstan'))[0];
return InstalledVersions::getPrettyVersion('phpstan/phpstan') ?? '';
} catch (OutOfBoundsException) {
return 'Version unknown';
}
Expand Down

0 comments on commit 1ebd2c3

Please sign in to comment.