phpstan 2.0 upgrade and fixes

This commit is contained in:
2024-11-18 20:10:09 +09:00
parent b9feacaded
commit a7ade86485
2 changed files with 8 additions and 3 deletions

View File

@@ -27,7 +27,9 @@
},
"require-dev": {
"phpunit/phpunit": "^9",
"phpstan/phpstan": "^1.10",
"phan/phan": "^5.4"
"phan/phan": "^5.4",
"phpstan/phpstan": "^2.0",
"phpstan/phpdoc-parser": "^2.0",
"phpstan/phpstan-deprecation-rules": "^2.0"
}
}

View File

@@ -60,7 +60,7 @@ class DotEnv
$block = false;
$var = '';
$prefix_name = '';
while ($line = fgets($fp)) {
while (($line = fgets($fp)) !== false) {
// [] block must be a single line, or it will be ignored
if (preg_match("/^\s*\[([\w_.\s]+)\]/", $line, $matches)) {
$prefix_name = preg_replace("/\s+/", "_", $matches[1]) . ".";
@@ -104,6 +104,9 @@ class DotEnv
// just be sure it is init before we fill
if (!isset($_ENV[$var])) {
$_ENV[$var] = '';
} elseif (!is_string($_ENV[$var])) {
// if this is not string, skip
continue;
}
// strip line of slashes
$_ENV[$var] .= stripslashes($line);