diff --git a/composer.json b/composer.json index 7d8298c..df2c929 100644 --- a/composer.json +++ b/composer.json @@ -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" } } diff --git a/src/DotEnv.php b/src/DotEnv.php index 01868f8..671bbec 100644 --- a/src/DotEnv.php +++ b/src/DotEnv.php @@ -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);