Skip to content

Commit

Permalink
Merge pull request #108 from Hi-Folks/features/107-auto-phpstanconf
Browse files Browse the repository at this point in the history
autodetect phpstan.neon and use it in the workflow
  • Loading branch information
roberto-butti authored Oct 12, 2021
2 parents c63aa2a + e5fc919 commit 7282023
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/Console/Commands/GenerateWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 13 additions & 0 deletions app/Objects/GuesserFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 = [];

Expand All @@ -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);
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 7282023

Please sign in to comment.