Skip to content

Commit

Permalink
Remove polyfills from Yaml and Dotenv
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander M. Turek <[email protected]>
  • Loading branch information
derrabus committed Jul 27, 2021
1 parent 51791c2 commit 2b078ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Dotenv.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function populate(array $values, bool $overrideExistingVars = false): voi
$loadedVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? ''));

foreach ($values as $name => $value) {
$notHttpName = !str_starts_with($name, 'HTTP_');
$notHttpName = 0 !== strpos($name, 'HTTP_');
// don't check existence with getenv() because of thread safety issues
if (!isset($loadedVars[$name]) && (!$overrideExistingVars && (isset($_ENV[$name]) || (isset($_SERVER[$name]) && $notHttpName)))) {
continue;
Expand Down Expand Up @@ -372,7 +372,7 @@ private function skipEmptyLines()

private function resolveCommands(string $value, array $loadedVars): string
{
if (!str_contains($value, '$')) {
if (false === strpos($value, '$')) {
return $value;
}

Expand Down Expand Up @@ -408,7 +408,7 @@ private function resolveCommands(string $value, array $loadedVars): string

$env = [];
foreach ($this->values as $name => $value) {
if (isset($loadedVars[$name]) || (!isset($_ENV[$name]) && !(isset($_SERVER[$name]) && !str_starts_with($name, 'HTTP_')))) {
if (isset($loadedVars[$name]) || (!isset($_ENV[$name]) && !(isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')))) {
$env[$name] = $value;
}
}
Expand All @@ -426,7 +426,7 @@ private function resolveCommands(string $value, array $loadedVars): string

private function resolveVariables(string $value, array $loadedVars): string
{
if (!str_contains($value, '$')) {
if (false === strpos($value, '$')) {
return $value;
}

Expand Down Expand Up @@ -461,7 +461,7 @@ private function resolveVariables(string $value, array $loadedVars): string
$value = $this->values[$name];
} elseif (isset($_ENV[$name])) {
$value = $_ENV[$name];
} elseif (isset($_SERVER[$name]) && !str_starts_with($name, 'HTTP_')) {
} elseif (isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')) {
$value = $_SERVER[$name];
} elseif (isset($this->values[$name])) {
$value = $this->values[$name];
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
}
],
"require": {
"php": ">=7.1.3",
"symfony/polyfill-php80": "^1.16"
"php": ">=7.1.3"
},
"require-dev": {
"symfony/process": "^3.4.2|^4.0|^5.0"
Expand Down

0 comments on commit 2b078ef

Please sign in to comment.