Skip to content

Commit f0fcb34

Browse files
Merge branch '4.4' into 5.2
* 4.4: Leverage str_contains/str_starts_with Leverage str_ends_with
2 parents 99a18c2 + 51791c2 commit f0fcb34

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Dotenv.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function populate(array $values, bool $overrideExistingVars = false): voi
190190
$loadedVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? ''));
191191

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

428428
private function resolveCommands(string $value, array $loadedVars): string
429429
{
430-
if (false === strpos($value, '$')) {
430+
if (!str_contains($value, '$')) {
431431
return $value;
432432
}
433433

@@ -463,7 +463,7 @@ private function resolveCommands(string $value, array $loadedVars): string
463463

464464
$env = [];
465465
foreach ($this->values as $name => $value) {
466-
if (isset($loadedVars[$name]) || (!isset($_ENV[$name]) && !(isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')))) {
466+
if (isset($loadedVars[$name]) || (!isset($_ENV[$name]) && !(isset($_SERVER[$name]) && !str_starts_with($name, 'HTTP_')))) {
467467
$env[$name] = $value;
468468
}
469469
}
@@ -481,7 +481,7 @@ private function resolveCommands(string $value, array $loadedVars): string
481481

482482
private function resolveVariables(string $value, array $loadedVars): string
483483
{
484-
if (false === strpos($value, '$')) {
484+
if (!str_contains($value, '$')) {
485485
return $value;
486486
}
487487

@@ -516,7 +516,7 @@ private function resolveVariables(string $value, array $loadedVars): string
516516
$value = $this->values[$name];
517517
} elseif (isset($_ENV[$name])) {
518518
$value = $_ENV[$name];
519-
} elseif (isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')) {
519+
} elseif (isset($_SERVER[$name]) && !str_starts_with($name, 'HTTP_')) {
520520
$value = $_SERVER[$name];
521521
} elseif (isset($this->values[$name])) {
522522
$value = $this->values[$name];

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"require": {
1919
"php": ">=7.2.5",
20-
"symfony/deprecation-contracts": "^2.1"
20+
"symfony/deprecation-contracts": "^2.1",
21+
"symfony/polyfill-php80": "^1.16"
2122
},
2223
"require-dev": {
2324
"symfony/process": "^4.4|^5.0"

0 commit comments

Comments
 (0)