@@ -27,13 +27,13 @@ final class LintApplication extends BaseApplication
2727 /**
2828 * @var string
2929 */
30- public const VERSION = '0.3.1 ' ;
30+ public const VERSION = '0.3 ' ;
3131
3232 public function __construct (
3333 LintCommand $ lintCommand ,
3434 LintInitCommand $ lintInitCommand ,
3535 ) {
36- parent ::__construct (self ::NAME , self ::VERSION );
36+ parent ::__construct (self ::NAME , self ::vendorVersion () );
3737
3838 $ this ->add ($ lintCommand );
3939 $ this ->add ($ lintInitCommand );
@@ -53,7 +53,7 @@ public static function runExceptionally(Throwable $throwable, ?OutputInterface $
5353 $ symfonyStyle = new SymfonyStyle ($ argvInput , $ output );
5454
5555 $ symfonyStyle ->writeln ('> ' . implode (' ' , $ argv ));
56- $ symfonyStyle ->writeln ('<fg=blue;options=bold>PHP</><fg=yellow;options=bold>Lint</> ' . self ::VERSION );
56+ $ symfonyStyle ->writeln ('<fg=blue;options=bold>PHP</><fg=yellow;options=bold>Lint</> ' . self ::vendorVersion () );
5757 $ symfonyStyle ->newLine ();
5858
5959 $ symfonyStyle ->error ($ throwable ->getMessage ());
@@ -62,6 +62,33 @@ public static function runExceptionally(Throwable $throwable, ?OutputInterface $
6262 return Command::FAILURE ;
6363 }
6464
65+ public static function vendorVersion (): string
66+ {
67+ $ version = self ::VERSION ;
68+ $ vendorInstallJson = getcwd () . DIRECTORY_SEPARATOR . 'vendor/composer/installed.json ' ;
69+
70+ $ fileContent = file_get_contents ($ vendorInstallJson );
71+ if ($ fileContent === false ) {
72+ return $ version ;
73+ }
74+
75+ $ composerJson = json_decode ($ fileContent , true );
76+ if (! is_array ($ composerJson )) {
77+ return $ version ;
78+ }
79+
80+ $ packages = $ composerJson ['packages ' ] ?? [];
81+
82+ foreach ($ packages as $ package ) {
83+ if ($ package ['name ' ] === 'wundii/phplint ' ) {
84+ $ version = $ package ['version ' ];
85+ break ;
86+ }
87+ }
88+
89+ return $ version ;
90+ }
91+
6592 private function getInputDefinition (): InputDefinition
6693 {
6794 return new InputDefinition ([
0 commit comments