From e5fc919082d4bccf8bea6ec69438138e5d633eb1 Mon Sep 17 00:00:00 2001 From: Roberto B Date: Tue, 12 Oct 2021 22:13:36 +0200 Subject: [PATCH] autodetect phpstan.neon and use it in the workflow close #107 --- app/Console/Commands/GenerateWorkflow.php | 2 ++ app/Objects/GuesserFiles.php | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/Console/Commands/GenerateWorkflow.php b/app/Console/Commands/GenerateWorkflow.php index cbf7cdc..dfb0347 100644 --- a/app/Console/Commands/GenerateWorkflow.php +++ b/app/Console/Commands/GenerateWorkflow.php @@ -92,12 +92,14 @@ public function handle() $generator->stepExecuteStaticAnalysis = true; $generator->stepInstallStaticAnalysis = false; $generator->stepToolStaticAnalysis = "larastan"; + $generator->stepPhpstanUseNeon = $guesserFiles->phpstanNeonExists(); } else { $phpstan = Arr::get($devPackages, "phpstan/phpstan", ""); if ($phpstan !== "") { $generator->stepExecuteStaticAnalysis = true; $generator->stepInstallStaticAnalysis = false; $generator->stepToolStaticAnalysis = "phpstan"; + $generator->stepPhpstanUseNeon = $guesserFiles->phpstanNeonExists(); } } $generator->stepDusk = false; diff --git a/app/Objects/GuesserFiles.php b/app/Objects/GuesserFiles.php index 1411a86..bfb37d4 100644 --- a/app/Objects/GuesserFiles.php +++ b/app/Objects/GuesserFiles.php @@ -13,6 +13,7 @@ class GuesserFiles public const NVMRC_FILE = ".nvmrc"; public const PACKAGE_FILE = "package.json"; public const ARTISAN_FILE = "artisan"; + public const PHPSTANNEON_FILE = "phpstan.neon"; public const MIGRATIONS_DIR = "database" . DIRECTORY_SEPARATOR . "migrations"; public const COMPOSER_VAR = "composerFile"; @@ -22,6 +23,8 @@ class GuesserFiles public const NVMRC_VAR = "nvmrcFile"; public const PACKAGE_VAR = "packageFile"; public const ARTISAN_VAR = "artisanFile"; + public const PHPSTANNEON_VAR = "phpstanNeonFile"; + public array $filePaths = []; @@ -35,6 +38,7 @@ public function pathFiles(string $projectDir, string $optionEnvWorkflowFile = se self::PACKAGE_VAR => self::PACKAGE_FILE, self::ARTISAN_VAR => self::ARTISAN_FILE, self::MIGRATIONS_VAR => self::MIGRATIONS_DIR, + self::PHPSTANNEON_VAR => self::PHPSTANNEON_FILE, ]; foreach ($arrayFiles as $variable => $file) { $this->filePaths[$variable] = base_path($file); @@ -105,6 +109,15 @@ public function artisanExists(): bool return $this->somethingExists("getArtisanPath"); } + public function getPhpstanNeonPath(): string + { + return Arr::get($this->filePaths, self::PHPSTANNEON_VAR, ""); + } + public function phpstanNeonExists(): bool + { + return $this->somethingExists("getPhpstanNeonPath"); + } + public function getMigrationsPath(): string {