From a7ade8648594c937ca24adb758eb5a702529cf70 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 18 Nov 2024 20:10:09 +0900 Subject: [PATCH] phpstan 2.0 upgrade and fixes --- composer.json | 6 ++++-- src/DotEnv.php | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) 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);