From f1f4ca570735af96e7fb1c173f0fe71d9229b75c Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sun, 12 Nov 2023 22:39:50 +0000 Subject: [PATCH] Drop PHP 7.1 and support PHP 8.3 --- .gitattributes | 4 +-- .github/workflows/static.yml | 50 +++++++----------------------- .github/workflows/tests.yml | 8 ++--- Makefile | 22 ++++++------- UPGRADING.md | 6 ++++ composer.json | 18 +++++------ phpstan-baseline.neon | 21 +++++++++++++ phpstan.neon.dist | 7 +++++ phpstan.src.neon.dist | 7 ----- phpstan.tests.neon.dist | 6 ---- phpunit.xml.dist | 38 +++++++---------------- psalm-baseline.xml | 20 ++++++++---- tests/Dotenv/Loader/LoaderTest.php | 2 +- tests/Dotenv/Parser/LexerTest.php | 2 +- tests/Dotenv/ValidatorTest.php | 8 ++--- vendor-bin/phpstan/composer.json | 11 +++---- vendor-bin/psalm/composer.json | 4 +-- 17 files changed, 109 insertions(+), 125 deletions(-) create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon.dist delete mode 100644 phpstan.src.neon.dist delete mode 100644 phpstan.tests.neon.dist diff --git a/.gitattributes b/.gitattributes index 4c05913c..7f1a1cee 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,8 +7,8 @@ /.gitignore export-ignore /.github export-ignore /Makefile export-ignore -/phpstan.src.neon.dist export-ignore -/phpstan.tests.neon.dist export-ignore +/phpstan-baseline.neon export-ignore +/phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore /psalm-baseline.xml export-ignore /psalm.xml export-ignore diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index c650ce8d..3fb07123 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -5,20 +5,22 @@ on: pull_request: jobs: - phpstan_src: - name: PHPStan Source + phpstan: + name: PHPStan runs-on: ubuntu-22.04 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: '8.3' tools: composer:v2 coverage: none + env: + update: true - name: Install Dependencies uses: nick-invision/retry@v2 @@ -35,39 +37,7 @@ jobs: command: composer bin phpstan update --no-interaction --no-progress - name: Execute PHPStan - run: vendor/bin/phpstan analyze src -c phpstan.src.neon.dist --no-progress - - phpstan_tests: - name: PHPStan Tests - runs-on: ubuntu-22.04 - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - tools: composer:v2 - coverage: none - - - name: Install Dependencies - uses: nick-invision/retry@v2 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer update --no-interaction --no-progress - - - name: Install PHPStan - uses: nick-invision/retry@v2 - with: - timeout_minutes: 5 - max_attempts: 5 - command: composer bin phpstan update --no-interaction --no-progress - - - name: Execute PHPStan - run: vendor/bin/phpstan analyze tests -c phpstan.tests.neon.dist --no-progress + run: vendor/bin/phpstan analyze --no-progress psalm: name: Psalm @@ -75,14 +45,16 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.2 + php-version: '8.3' tools: composer:v2 coverage: none + env: + update: true - name: Install Dependencies uses: nick-invision/retry@v2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0a42671b..f3e30e15 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -11,11 +11,11 @@ jobs: strategy: matrix: - php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -43,11 +43,11 @@ jobs: strategy: matrix: - php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/Makefile b/Makefile index 4978c94a..07abb41d 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,26 @@ install: - @docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.2-base update - @docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.2-base bin all update + @docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.3-base update + @docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.3-base bin all update phpunit: - @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:8.2-cli + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:8.3-cli -phpstan-analyze-src: - @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.2-cli analyze src -c phpstan.src.neon.dist +phpstan-analyze: + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.3-cli analyze -phpstan-analyze-tests: - @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.2-cli analyze tests -c phpstan.tests.neon.dist +phpstan-baseline: + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.3-cli analyze --generate-baseline psalm-analyze: - @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.2-cli + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.3-cli psalm-baseline: - @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:7.4-cli --set-baseline=psalm-baseline.xml + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.3-cli --set-baseline=psalm-baseline.xml psalm-show-info: - @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.2-cli --show-info=true + @docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.3-cli --show-info=true -test: phpunit phpstan-analyze-src phpstan-analyze-tests psalm-analyze +test: phpunit phpstan-analyze psalm-analyze clean: @rm -rf .phpunit.result.cache composer.lock vendor vendor-bin/*/composer.lock vendor-bin/*/vendor diff --git a/UPGRADING.md b/UPGRADING.md index 757f666f..77d96db0 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -1,5 +1,11 @@ # Upgrading Guide +## V5.5 to V5.6 + +Bumping the minimum required PHP version is not a breaking change, however it is notable. Since version 5.6.0, we now require PHP 7.2.5 or higher. Installation metrics show that for some time, PHP 7.1 has represented only around 0.1% of installs of V5. + +Release notes for 5.6.0 are available [here](https://github.com/vlucas/phpdotenv/releases/tag/v5.6.0). + ## V4 to V5 ### Introduction diff --git a/composer.json b/composer.json index 46fdbafd..fb972d75 100644 --- a/composer.json +++ b/composer.json @@ -16,18 +16,18 @@ } ], "require": { - "php": "^7.1.3 || ^8.0", + "php": "^7.2.5 || ^8.0", "ext-pcre": "*", - "graham-campbell/result-type": "^1.0.2", - "phpoption/phpoption": "^1.8", - "symfony/polyfill-ctype": "^1.23", - "symfony/polyfill-mbstring": "^1.23.1", - "symfony/polyfill-php80": "^1.23.1" + "graham-campbell/result-type": "^1.1.2", + "phpoption/phpoption": "^1.9.2", + "symfony/polyfill-ctype": "^1.24", + "symfony/polyfill-mbstring": "^1.24", + "symfony/polyfill-php80": "^1.24" }, "require-dev": { "ext-filter": "*", - "bamarni/composer-bin-plugin": "^1.4.1", - "phpunit/phpunit": "^7.5.20 || ^8.5.30 || ^9.5.25" + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit":"^8.5.34 || ^9.6.13 || ^10.4.2" }, "autoload": { "psr-4": { @@ -54,7 +54,7 @@ "forward-command": true }, "branch-alias": { - "dev-master": "5.5-dev" + "dev-master": "5.6-dev" } } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 00000000..ae965032 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,21 @@ +parameters: + ignoreErrors: + - + message: "#^Anonymous function should return GrahamCampbell\\\\ResultType\\\\Result\\ but returns GrahamCampbell\\\\ResultType\\\\Result\\\\.$#" + count: 1 + path: src/Parser/EntryParser.php + + - + message: "#^Only booleans are allowed in a negated boolean, int\\|false given\\.$#" + count: 1 + path: src/Parser/Lexer.php + + - + message: "#^Parameter \\#1 \\$readers of class Dotenv\\\\Repository\\\\RepositoryBuilder constructor expects array\\, array\\ given\\.$#" + count: 2 + path: src/Repository/RepositoryBuilder.php + + - + message: "#^Parameter \\#2 \\$writers of class Dotenv\\\\Repository\\\\RepositoryBuilder constructor expects array\\, array\\ given\\.$#" + count: 2 + path: src/Repository/RepositoryBuilder.php diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..6f8227f5 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,7 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: max + paths: + - src diff --git a/phpstan.src.neon.dist b/phpstan.src.neon.dist deleted file mode 100644 index b4ac901a..00000000 --- a/phpstan.src.neon.dist +++ /dev/null @@ -1,7 +0,0 @@ -parameters: - level: max - ignoreErrors: - - '#Only booleans are allowed in a negated boolean, int\|false given.#' - - '#Anonymous function should return GrahamCampbell\\ResultType\\Result\ but returns GrahamCampbell\\ResultType\\Result\.#' - - '#Parameter \#1 \$readers of class Dotenv\\Repository\\RepositoryBuilder constructor expects array\, array\ given\.#' - - '#Parameter \#2 \$writers of class Dotenv\\Repository\\RepositoryBuilder constructor expects array\, array\ given\.#' diff --git a/phpstan.tests.neon.dist b/phpstan.tests.neon.dist deleted file mode 100644 index 81a78295..00000000 --- a/phpstan.tests.neon.dist +++ /dev/null @@ -1,6 +0,0 @@ -parameters: - level: max - ignoreErrors: - - '#Parameter \#1 \$name of method Dotenv\\Repository\\RepositoryInterface::[a-z]+\(\) expects string, null given.#' - - '#Method Dotenv\\Tests\\[a-zA-Z\\]+Test::test[a-zA-Z0-9]+\(\) has no return type specified.#' - - '#Call to static method PHPUnit\\Framework\\Assert::assert(InstanceOf|IsArray)\(\) with .+ will always evaluate to true.#' diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 340f19a4..5c1fa16e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,29 +1,13 @@ - - - - ./tests - - - - - ./src - - + + + + ./tests + + + + + ./src + + diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 7270a15f..a86b8ae0 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,20 +1,28 @@ - + + + + \is_scalar($value) + + - + $adapter::create() $reader::create() $writer::create() - + static function ($adapter) { static function ($reader) { static function ($writer) { - - \preg_last_error_msg() - + + $pattern + $pattern + $pattern + $pattern + diff --git a/tests/Dotenv/Loader/LoaderTest.php b/tests/Dotenv/Loader/LoaderTest.php index 216155f4..76ba8e9e 100644 --- a/tests/Dotenv/Loader/LoaderTest.php +++ b/tests/Dotenv/Loader/LoaderTest.php @@ -59,7 +59,7 @@ public function testLoaderWithGarbage() /** * @return array[] */ - public function providesAdapters() + public static function providesAdapters() { return [ [ArrayAdapter::create()->get()], diff --git a/tests/Dotenv/Parser/LexerTest.php b/tests/Dotenv/Parser/LexerTest.php index 4a9599ba..fabc36e0 100644 --- a/tests/Dotenv/Parser/LexerTest.php +++ b/tests/Dotenv/Parser/LexerTest.php @@ -12,7 +12,7 @@ final class LexerTest extends TestCase /** * @return array{string,string[]}[] */ - public function provideLexCases() + public static function provideLexCases() { return [ ['', []], diff --git a/tests/Dotenv/ValidatorTest.php b/tests/Dotenv/ValidatorTest.php index 4bcf9409..dd5bcf9b 100644 --- a/tests/Dotenv/ValidatorTest.php +++ b/tests/Dotenv/ValidatorTest.php @@ -207,7 +207,7 @@ public function testDotenvStringOfSpacesConsideredEmpty() * * @return string[][] */ - public function validBooleanValuesDataProvider() + public static function validBooleanValuesDataProvider() { return [ ['VALID_EXPLICIT_LOWERCASE_TRUE'], @@ -263,7 +263,7 @@ public function testCanValidateBooleansIfPresent(string $boolean) * * @return string[][] */ - public function invalidBooleanValuesDataProvider() + public static function invalidBooleanValuesDataProvider() { return [ ['INVALID_SOMETHING'], @@ -332,7 +332,7 @@ public function testIfPresentBooleanNonExist() * * @return string[][] */ - public function validIntegerValuesDataProvider() + public static function validIntegerValuesDataProvider() { return [ ['VALID_ZERO'], @@ -370,7 +370,7 @@ public function testCanValidateIntegersIfPresent(string $integer) * * @return string[][] */ - public function invalidIntegerValuesDataProvider() + public static function invalidIntegerValuesDataProvider() { return [ ['INVALID_SOMETHING'], diff --git a/vendor-bin/phpstan/composer.json b/vendor-bin/phpstan/composer.json index ab97b1f9..5889256c 100644 --- a/vendor-bin/phpstan/composer.json +++ b/vendor-bin/phpstan/composer.json @@ -1,11 +1,10 @@ { "require": { - "php": "^8.2", - "phpstan/phpstan": "1.8.9", - "phpstan/extension-installer": "1.1.0", - "phpstan/phpstan-deprecation-rules": "1.0.0", - "phpstan/phpstan-phpunit": "1.1.1", - "phpstan/phpstan-strict-rules": "1.4.4", + "php": "^8.3", + "phpstan/phpstan": "1.10.41", + "phpstan/extension-installer": "1.3.1", + "phpstan/phpstan-deprecation-rules": "1.1.4", + "phpstan/phpstan-strict-rules": "1.5.2", "thecodingmachine/phpstan-strict-rules": "1.0.0" }, "config": { diff --git a/vendor-bin/psalm/composer.json b/vendor-bin/psalm/composer.json index 24ea34a9..e76dd540 100644 --- a/vendor-bin/psalm/composer.json +++ b/vendor-bin/psalm/composer.json @@ -1,7 +1,7 @@ { "require": { - "php": "^8.2", - "psalm/phar": "4.29.0" + "php": "^8.3", + "psalm/phar": "5.15.0" }, "config": { "preferred-install": "dist"