Skip to content

Commit

Permalink
fix feature #213
Browse files Browse the repository at this point in the history
  • Loading branch information
llaville committed Oct 7, 2024
1 parent 2a62d84 commit fc32b73
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 146 deletions.
18 changes: 0 additions & 18 deletions .php-cs-fixer.release.php

This file was deleted.

10 changes: 2 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"ext-dom": "*",
"ext-json": "*",
"ext-mbstring": "*",
"composer-runtime-api": "^2.0",
"symfony/cache": "^6.4 || ^7.0",
"symfony/console": "^6.4 || ^7.0",
"symfony/event-dispatcher": "^6.4 || ^7.0",
Expand Down Expand Up @@ -59,13 +60,10 @@
"pre-commit": [
"composer style:fix",
"composer code:check"
],
"pre-push": [
"composer qa:check"
]
},
"branch-alias": {
"dev-main": "9.4.x-dev"
"dev-main": "9.5.x-dev"
}
},
"scripts": {
Expand All @@ -81,8 +79,6 @@
"@composer bin all install --ansi"
],
"cghooks": "vendor/bin/cghooks",
"qa:check": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.release.php --using-cache=no --verbose --ansi --diff --dry-run",
"qa:fix": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.release.php --using-cache=no --verbose --ansi",
"style:check": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --using-cache=no --verbose --ansi --diff --dry-run",
"style:fix": "vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.dist.php --using-cache=no --verbose --ansi",
"tests:unit": "vendor/bin/phpunit --testsuite=cache,configuration,finder",
Expand All @@ -94,8 +90,6 @@
"minimum-stability": "dev",
"prefer-stable": true,
"scripts-descriptions": {
"qa:check": "Run QA style checks before pushing new tag and releasing a new version (only dry run - no fixing!).",
"qa:fix": "Run QA style checks and fix violations.",
"style:check": "Run style checks (only dry run - no fixing!).",
"style:fix": "Run style checks and fix violations.",
"tests:unit": "Run unit tests on following components: cache, configuration, finder",
Expand Down
37 changes: 35 additions & 2 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Overtrue\PHPLint\Console;

use Composer\InstalledVersions;
use OutOfBoundsException;
use Overtrue\PHPLint\Helper\DebugFormatterHelper;
use Overtrue\PHPLint\Helper\ProcessHelper;
use Overtrue\PHPLint\Output\ConsoleOutput;
Expand All @@ -26,6 +28,7 @@

use function array_keys;
use function in_array;
use function sprintf;

use const STDOUT;

Expand All @@ -36,11 +39,12 @@
final class Application extends BaseApplication
{
public const NAME = 'phplint';
public const VERSION = '9.5.0-dev';

private const PACKAGE_NAME = 'overtrue/phplint';

public function __construct()
{
parent::__construct(self::NAME, self::VERSION);
parent::__construct(self::NAME, self::getPrettyVersion());
}

public function run(InputInterface $input = null, OutputInterface $output = null): int
Expand Down Expand Up @@ -69,4 +73,33 @@ protected function getCommandName(InputInterface $input): ?string
$name = parent::getCommandName($input);
return in_array($name, array_keys(parent::all())) ? $name : null;
}

private static function getPrettyVersion(): string
{
foreach (InstalledVersions::getAllRawData() as $installed) {
if (!isset($installed['versions'][self::PACKAGE_NAME])) {
continue;
}

$version = $installed['versions'][self::PACKAGE_NAME]['pretty_version']
?? $installed['versions'][self::PACKAGE_NAME]['version']
?? 'dev'
;

$aliases = $installed['versions'][self::PACKAGE_NAME]['aliases'] ?? [];

$reference = $installed['versions'][self::PACKAGE_NAME]['reference'];
if (null === $reference) {
return sprintf('%s', $aliases[0] ?? $version);
}

return sprintf(
'%s@%s',
$aliases[0] ?? $version,
substr($reference, 0, 7)
);
}

throw new OutOfBoundsException(sprintf('Package "%s" is not installed', self::PACKAGE_NAME));
}
}
118 changes: 0 additions & 118 deletions vendor-bin/php-cs-fixer/src/ApplicationVersionFixer.php

This file was deleted.

0 comments on commit fc32b73

Please sign in to comment.