diff --git a/psalm.xml b/psalm.xml index 7adea97..bafa3e7 100644 --- a/psalm.xml +++ b/psalm.xml @@ -3,16 +3,38 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" - findUnusedVariablesAndParams="false" - findUnusedPsalmSuppress="false" - findUnusedCode="false" findUnusedBaselineEntry="false" - errorLevel="1" + findUnusedCode="false" + findUnusedPsalmSuppress="false" + findUnusedVariablesAndParams="false" + errorLevel="2" > + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/recipe/setono_dotenv.php b/src/recipe/setono_dotenv.php index 20edb22..06d6e89 100644 --- a/src/recipe/setono_dotenv.php +++ b/src/recipe/setono_dotenv.php @@ -6,23 +6,9 @@ use function Deployer\after; use function Deployer\before; -use Deployer\Deployer; -require_once __DIR__ . '/../task/setono_dotenv.php'; +require_once 'task/setono_dotenv.php'; after('deploy:update_code', 'dotenv:prepare'); - -$deployer = Deployer::get(); - -/** - * The task deploy:cache:clear is defined in Symfony related recipes and both the cache clear - * and cache warmup tasks sometimes depend on environment variables. Therefore, it's a good idea - * to have environment variables defined before running these tasks. - */ -if ($deployer->tasks->has('deploy:cache:clear')) { - before('deploy:cache:clear', 'dotenv:update'); -} else { - before('deploy:symlink', 'dotenv:update'); -} - +after('deploy:vendors', 'dotenv:update'); before('dotenv:update', 'dotenv:generate'); diff --git a/src/task/setono_dotenv.php b/src/task/setono_dotenv.php index bfc7186..6b001a2 100644 --- a/src/task/setono_dotenv.php +++ b/src/task/setono_dotenv.php @@ -85,6 +85,13 @@ break; } + if (!preg_match('/^[a-zA-Z_]\w*=.+$/', $newValue)) { + output()->writeln('Invalid input. Please provide a valid environment variable and value (ENV_VAR=value)'); + + continue; + } + + /** @psalm-suppress PossiblyUndefinedArrayOffset */ [$key, $val] = explode('=', $newValue, 2); // Here we add/overwrite the value from the user @@ -206,8 +213,6 @@ function evaluatePhpEnvFile(string $path): array /** @var array $res */ $res = eval('?>' . $data); - Assert::isArray($res); - Assert::allScalar($res); return $res; }