Skip to content

Commit

Permalink
Merge pull request #7239 from DeyV/master
Browse files Browse the repository at this point in the history
Move from deprecated Composer 1 to Composer 2 runtime api
  • Loading branch information
orklah committed Jan 2, 2022
2 parents 216cf6c + 7172f4b commit 33628ca
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -22,9 +22,9 @@
"ext-libxml": "*",
"ext-mbstring": "*",
"ext-tokenizer": "*",
"composer-runtime-api": "^2.0.0",
"amphp/amp": "^2.4.2",
"amphp/byte-stream": "^1.5",
"composer/package-versions-deprecated": "^1.8.0",
"composer/semver": "^1.4 || ^2.0 || ^3.0",
"composer/xdebug-handler": "^1.1 || ^2.0 || ^3.0",
"dnoegel/php-xdg-base-dir": "^0.1.1",
Expand All @@ -49,7 +49,7 @@
"phpmyadmin/sql-parser": "5.1.0||dev-master",
"phpspec/prophecy": ">=1.9.0",
"phpunit/phpunit": "^9.0",
"psalm/plugin-phpunit": "^0.16",
"psalm/plugin-phpunit": "^0.16.1",
"slevomat/coding-standard": "^7.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/process": "^4.3 || ^5.0 || ^6.0",
Expand Down
1 change: 0 additions & 1 deletion psalm.xml.dist
Expand Up @@ -58,7 +58,6 @@
</DeprecatedMethod>
<DeprecatedClass>
<errorLevel type="suppress">
<referencedClass name="PackageVersions\Versions"/>
<referencedClass name="Psalm\Plugin\Hook\*" />
</errorLevel>
</DeprecatedClass>
Expand Down
7 changes: 7 additions & 0 deletions scoper.inc.php
Expand Up @@ -27,6 +27,13 @@ function ($filePath, $prefix, $contents) {
$contents
);
},
function ($filePath, $prefix, $contents) {
return str_replace(
'\\'.$prefix.'\Composer\InstalledVersions',
'\Composer\InstalledVersions',
$contents
);
},
function ($filePath, $prefix, $contents) {
if (strpos($filePath, 'src/Psalm') === 0) {
return str_replace(
Expand Down
11 changes: 9 additions & 2 deletions src/Psalm/Internal/Cli/Plugin.php
Expand Up @@ -2,7 +2,8 @@

namespace Psalm\Internal\Cli;

use PackageVersions\Versions;
use Composer\InstalledVersions;
use OutOfBoundsException;
use Psalm\Internal\CliUtils;
use Psalm\Internal\PluginManager\Command\DisableCommand;
use Psalm\Internal\PluginManager\Command\EnableCommand;
Expand All @@ -29,7 +30,13 @@ public static function run(): void
$vendor_dir = CliUtils::getVendorDir($current_dir);
CliUtils::requireAutoloaders($current_dir, false, $vendor_dir);

$app = new Application('psalm-plugin', Versions::getVersion('vimeo/psalm'));
$version = null;
try {
$version = InstalledVersions::getVersion('vimeo/psalm') ;
} catch (OutOfBoundsException $e) {
}

$app = new Application('psalm-plugin', $version ?? 'UNKNOWN');

$psalm_root = dirname(__DIR__, 4) . DIRECTORY_SEPARATOR;

Expand Down
14 changes: 10 additions & 4 deletions src/Psalm/Internal/CliUtils.php
Expand Up @@ -3,14 +3,14 @@
namespace Psalm\Internal;

use Composer\Autoload\ClassLoader;
use PackageVersions\Versions;
use Composer\InstalledVersions;
use OutOfBoundsException;
use Phar;
use Psalm\Config;
use Psalm\Config\Creator;
use Psalm\Exception\ConfigException;
use Psalm\Exception\ConfigNotFoundException;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\Composer;
use Psalm\Report;

use function array_slice;
Expand Down Expand Up @@ -147,8 +147,14 @@ public static function requireAutoloaders(
exit(1);
}

define('PSALM_VERSION', Versions::getVersion('vimeo/psalm'));
define('PHP_PARSER_VERSION', Versions::getVersion('nikic/php-parser'));
$version = null;
try {
$version = InstalledVersions::getVersion('vimeo/psalm') ;
} catch (OutOfBoundsException $e) {
}

define('PSALM_VERSION', $version ?? 'UNKNOWN');
define('PHP_PARSER_VERSION', InstalledVersions::getVersion('nikic/php-parser'));

return $first_autoloader;
}
Expand Down

0 comments on commit 33628ca

Please sign in to comment.