File tree Expand file tree Collapse file tree 7 files changed +44
-8
lines changed
Expand file tree Collapse file tree 7 files changed +44
-8
lines changed Original file line number Diff line number Diff line change 11name : CI
22
3- on : [push, pull_request]
3+ on :
4+ push :
5+ branches :
6+ - main
7+ pull_request :
8+ branches :
9+ - ' *'
410
511jobs :
612 testsuite :
Original file line number Diff line number Diff line change @@ -17,13 +17,16 @@ jobs:
1717 - name : Setup PHP
1818 uses : shivammathur/setup-php@v2
1919 with :
20- php-version : ' 8.2 '
20+ php-version : ' 8.4 '
2121 extensions : json, fileinfo
2222 tools : composer
2323
2424 - name : Install dependencies
2525 run : composer install --no-dev --optimize-autoloader
2626
27+ - name : Inject version from tag
28+ run : sed -i "s/public const VERSION = .*/public const VERSION = '\${{ github.ref_name }}';/" src/Application.php
29+
2730 - name : Build PHAR
2831 run : composer build-phar
2932
Original file line number Diff line number Diff line change 1010.env
1111infection.log
1212phive.phar
13- cognitive-analysis .phar
13+ phpcca .phar
Original file line number Diff line number Diff line change 11{
2- "main": "./ bin/phpcca",
2+ "main": "bin/phpcca",
33 "compression": "GZ",
44 "output": "phpcca.phar",
55 "force-autodiscovery": true,
6+ "compactors": [
7+ "KevinGH\\Box\\Compactor\\Json",
8+ "KevinGH\\Box\\Compactor\\Php",
9+ "KevinGH\\Box\\Compactor\\PhpScoper"
10+ ],
611 "files": [
712 "config.yml",
813 "composer.json",
Original file line number Diff line number Diff line change 1+ # Get the latest tag reachable from the previous commit
2+ TAG=$( git describe --tags --abbrev=0 HEAD^ 2> /dev/null)
3+
4+ if [ -n " $TAG " ]; then
5+ sed -i " s/public const VERSION = .*/public const VERSION = '$TAG ';/" src/Application.php
6+ git add src/Application.php
7+ echo " Version set to $TAG "
8+ else
9+ echo " No previous tag found."
10+ fi
Original file line number Diff line number Diff line change 4949 */
5050class Application
5151{
52+ public const VERSION = '1.3.0 ' ;
53+
5254 private ContainerBuilder $ containerBuilder ;
5355
5456 public function __construct ()
@@ -231,6 +233,10 @@ private function registerCommands(): void
231233 private function configureApplication (): void
232234 {
233235 $ this ->containerBuilder ->register (SymfonyApplication::class, SymfonyApplication::class)
236+ ->setArguments ([
237+ 'Cognitive Code Analysis ' ,
238+ self ::VERSION
239+ ])
234240 ->setPublic (true )
235241 ->addMethodCall ('add ' , [new Reference (CognitiveMetricsCommand::class)])
236242 ->addMethodCall ('add ' , [new Reference (ChurnCommand::class)]);
Original file line number Diff line number Diff line change @@ -25,10 +25,7 @@ public function __construct(
2525
2626 public function __invoke (SourceFilesFound |FileProcessed $ event ): void
2727 {
28- if (
29- $ this ->input ->hasOption (CognitiveMetricsCommand::OPTION_DEBUG )
30- && $ this ->input ->getOption (CognitiveMetricsCommand::OPTION_DEBUG ) === false
31- ) {
28+ if (!$ this ->isDebugEnabled ()) {
3229 return ;
3330 }
3431
@@ -62,4 +59,13 @@ private function formatBytes(int $size): string
6259
6360 return round ($ size , 2 ) . ' ' . $ units [$ index ];
6461 }
62+
63+ /**
64+ * @return bool
65+ */
66+ public function isDebugEnabled (): bool
67+ {
68+ return $ this ->input ->hasOption (CognitiveMetricsCommand::OPTION_DEBUG )
69+ && $ this ->input ->getOption (CognitiveMetricsCommand::OPTION_DEBUG ) === false ;
70+ }
6571}
You can’t perform that action at this time.
0 commit comments