Skip to content

Commit

Permalink
Merge pull request #83 from p0lemic/allow-arguments-with-variables-in…
Browse files Browse the repository at this point in the history
…-services-definition

Allow arguments with variables in services definition
  • Loading branch information
p0lemic authored Aug 5, 2019
2 parents 42aac85 + 49df52e commit e8244ea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Sifo/DependencyInjector.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ private function getSetterInjectionsCalls($declaration, $compiled_services)

private function isAVariableArgument($argument): bool
{
return !is_array($argument) && strpos($argument, '%') !== 0;
return !is_array($argument) && preg_match('/%([^%\s]+)%/', $argument);
}

private function isALiteralArgument($argument): bool
Expand All @@ -470,9 +470,9 @@ private function isAnArray($dependency)

private function getVariableArgumentCompilation($argument): string
{
$variable_name = trim('%', $argument);
$variable_name = trim($argument, '%');

return $_ENV[$variable_name] ?? '';
return $_ENV[$variable_name] ? "\x20\x20\x20\x20\x20\x20\x20\x20'" . $_ENV[$variable_name] . "'" : '';
}

private function getLiteralArgumentCompilation($argument)
Expand Down

0 comments on commit e8244ea

Please sign in to comment.