Skip to content

Commit

Permalink
Make function a variable instead
Browse files Browse the repository at this point in the history
  • Loading branch information
loevgaard committed May 25, 2021
1 parent c817a61 commit ee19e59
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/task/dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,20 @@
$table->render();
};

$evalEnv = static function (string $envContents): array {
/** @var array<string, scalar> $res */
$res = eval('?>' . $envContents);
Assert::isArray($res);
Assert::allScalar($res);

return $res;
};

/**
* We want two arrays to begin with. This allows us to easily compare the two arrays later on
* when the $variables may have been changed by the user
*/
$variables = $initialVariables = evalEnv(run('cat {{release_path}}/.env.local.php'));
$variables = $initialVariables = $evalEnv(run('cat {{release_path}}/.env.local.php'));

while (true) {
$outputVariablesFunction($output, $variables);
Expand Down Expand Up @@ -143,16 +152,3 @@
invoke('dotenv:generate');
}
})->desc('Allows the user to update environment variables');

/**
* @return array<string, scalar>
*/
function evalEnv(string $envContents): array
{
/** @var array<string, scalar> $res */
$res = eval('?>' . $envContents);
Assert::isArray($res);
Assert::allScalar($res);

return $res;
}

0 comments on commit ee19e59

Please sign in to comment.