From f1e2a35e53abe9322f0ab9ada689967e30055d40 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 2 Oct 2021 20:02:17 +0100 Subject: [PATCH] Added support for PHP 8.1 (#496) --- .github/workflows/tests.yml | 13 ++----------- .gitignore | 1 + composer.json | 8 +++----- phpunit.xml.dist | 3 ++- src/Loader.php | 12 ++++++++---- tests/Dotenv/DotenvTest.php | 5 ++++- tests/Dotenv/LoaderTest.php | 5 ++++- tests/Dotenv/ValidatorBooleanTest.php | 5 ++++- 8 files changed, 28 insertions(+), 24 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ef29302b..a818cfc6 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,7 +11,7 @@ jobs: strategy: matrix: - php: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] + php: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] steps: - name: Checkout Code @@ -27,21 +27,12 @@ jobs: - name: Setup Problem Matchers run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Install PHP 5/7 Dependencies + - name: Install Dependencies uses: nick-invision/retry@v1 with: timeout_minutes: 5 max_attempts: 5 command: composer update --no-interaction --no-progress - if: "matrix.php < 8" - - - name: Install PHP 8 Dependencies - uses: nick-invision/retry@v1 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --no-interaction --no-progress --ignore-platform-req=php - if: "matrix.php >= 8" - name: Execute PHPUnit run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 81b92580..f973ee0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.phpunit.result.cache composer.lock phpunit.xml vendor diff --git a/composer.json b/composer.json index c869cc09..f2293e68 100644 --- a/composer.json +++ b/composer.json @@ -6,13 +6,11 @@ "authors": [ { "name": "Graham Campbell", - "email": "graham@alt-three.com", - "homepage": "https://gjcampbell.co.uk/" + "email": "hello@gjcampbell.co.uk" }, { "name": "Vance Lucas", - "email": "vance@vancelucas.com", - "homepage": "https://vancelucas.com/" + "email": "vance@vancelucas.com" } ], "require": { @@ -22,7 +20,7 @@ "require-dev": { "ext-filter": "*", "ext-pcre": "*", - "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20" + "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.21" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ae4683a6..340f19a4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,11 +5,12 @@ beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true" + convertDeprecationsToExceptions="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" failOnRisky="true" - failOnWarning="true" + failOnWarning="false" processIsolation="false" stopOnError="false" stopOnFailure="false" diff --git a/src/Loader.php b/src/Loader.php index 496ce75c..dccb5452 100644 --- a/src/Loader.php +++ b/src/Loader.php @@ -117,8 +117,8 @@ protected function ensureFileIsReadable() * - cleaning the name of quotes, * - resolving nested variables. * - * @param string $name - * @param string $value + * @param string $name + * @param string|null $value * * @throws \Dotenv\Exception\InvalidFileException * @@ -138,8 +138,8 @@ protected function normaliseEnvironmentVariable($name, $value) * * Called from `normaliseEnvironmentVariable` and the `VariableFactory`, passed as a callback in `$this->loadFromFile()`. * - * @param string $name - * @param string $value + * @param string $name + * @param string|null $value * * @throws \Dotenv\Exception\InvalidFileException * @@ -147,6 +147,10 @@ protected function normaliseEnvironmentVariable($name, $value) */ public function processFilters($name, $value) { + if ($value === null) { + $value = ''; + } + list($name, $value) = $this->splitCompoundStringIntoParts($name, $value); list($name, $value) = $this->sanitiseVariableName($name, $value); list($name, $value) = $this->sanitiseVariableValue($name, $value); diff --git a/tests/Dotenv/DotenvTest.php b/tests/Dotenv/DotenvTest.php index 8c11d0a3..50f44d0f 100644 --- a/tests/Dotenv/DotenvTest.php +++ b/tests/Dotenv/DotenvTest.php @@ -10,7 +10,10 @@ class DotenvTest extends TestCase */ private $fixturesFolder; - public function setUp() + /** + * @before + */ + public function setUpTest() { $this->fixturesFolder = dirname(__DIR__).'/fixtures/env'; } diff --git a/tests/Dotenv/LoaderTest.php b/tests/Dotenv/LoaderTest.php index c52011d6..d7dcd222 100644 --- a/tests/Dotenv/LoaderTest.php +++ b/tests/Dotenv/LoaderTest.php @@ -15,7 +15,10 @@ class LoaderTest extends TestCase */ private $mutableLoader; - public function setUp() + /** + * @before + */ + public function setUpTest() { $folder = dirname(__DIR__).'/fixtures/env'; diff --git a/tests/Dotenv/ValidatorBooleanTest.php b/tests/Dotenv/ValidatorBooleanTest.php index 1188e293..1963ba06 100644 --- a/tests/Dotenv/ValidatorBooleanTest.php +++ b/tests/Dotenv/ValidatorBooleanTest.php @@ -10,7 +10,10 @@ class ValidatorBooleanTest extends TestCase */ private $fixturesFolder; - public function setUp() + /** + * @before + */ + public function setUpTest() { $this->fixturesFolder = dirname(__DIR__).'/fixtures/env'; }