Skip to content

Commit

Permalink
Drop PHP 7.1 and support PHP 8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Nov 12, 2023
1 parent 1a7ea2a commit f1f4ca5
Show file tree
Hide file tree
Showing 17 changed files with 109 additions and 125 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 11 additions & 39 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,54 +37,24 @@ 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
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
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -54,7 +54,7 @@
"forward-command": true
},
"branch-alias": {
"dev-master": "5.5-dev"
"dev-master": "5.6-dev"
}
}
}
21 changes: 21 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
parameters:
ignoreErrors:
-
message: "#^Anonymous function should return GrahamCampbell\\\\ResultType\\\\Result\\<array\\{mixed, mixed\\}, string\\> but returns GrahamCampbell\\\\ResultType\\\\Result\\<array\\{Dotenv\\\\Parser\\\\Value, mixed\\}, string\\>\\.$#"
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\\<Dotenv\\\\Repository\\\\Adapter\\\\ReaderInterface\\>, array\\<Dotenv\\\\Repository\\\\Adapter\\\\ReaderInterface\\|S\\> given\\.$#"
count: 2
path: src/Repository/RepositoryBuilder.php

-
message: "#^Parameter \\#2 \\$writers of class Dotenv\\\\Repository\\\\RepositoryBuilder constructor expects array\\<Dotenv\\\\Repository\\\\Adapter\\\\WriterInterface\\>, array\\<Dotenv\\\\Repository\\\\Adapter\\\\WriterInterface\\|S\\> given\\.$#"
count: 2
path: src/Repository/RepositoryBuilder.php
7 changes: 7 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
includes:
- phpstan-baseline.neon

parameters:
level: max
paths:
- src
7 changes: 0 additions & 7 deletions phpstan.src.neon.dist

This file was deleted.

6 changes: 0 additions & 6 deletions phpstan.tests.neon.dist

This file was deleted.

38 changes: 11 additions & 27 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
bootstrap="vendor/autoload.php"
colors="true"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
failOnRisky="true"
failOnWarning="false"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
verbose="true"
>
<testsuites>
<testsuite name="PHP Dotenv Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" beStrictAboutTestsThatDoNotTestAnything="true" beStrictAboutOutputDuringTests="true" bootstrap="vendor/autoload.php" colors="true" failOnRisky="true" failOnWarning="true" processIsolation="false" stopOnError="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd">
<testsuites>
<testsuite name="PHP Dotenv Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
20 changes: 14 additions & 6 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.x-dev@">
<files psalm-version="5.15.0@5c774aca4746caf3d239d9c8cadb9f882ca29352">
<file src="src/Repository/Adapter/EnvConstAdapter.php">
<RedundantConditionGivenDocblockType>
<code>\is_scalar($value)</code>
</RedundantConditionGivenDocblockType>
</file>
<file src="src/Repository/RepositoryBuilder.php">
<InvalidStringClass occurrences="3">
<InvalidStringClass>
<code>$adapter::create()</code>
<code>$reader::create()</code>
<code>$writer::create()</code>
</InvalidStringClass>
<MissingClosureReturnType occurrences="3">
<MissingClosureReturnType>
<code>static function ($adapter) {</code>
<code>static function ($reader) {</code>
<code>static function ($writer) {</code>
</MissingClosureReturnType>
</file>
<file src="src/Util/Regex.php">
<UndefinedFunction occurrences="1">
<code>\preg_last_error_msg()</code>
</UndefinedFunction>
<ArgumentTypeCoercion>
<code>$pattern</code>
<code>$pattern</code>
<code>$pattern</code>
<code>$pattern</code>
</ArgumentTypeCoercion>
</file>
</files>
2 changes: 1 addition & 1 deletion tests/Dotenv/Loader/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testLoaderWithGarbage()
/**
* @return array<int,\Dotenv\Repository\Adapter\AdapterInterface|string>[]
*/
public function providesAdapters()
public static function providesAdapters()
{
return [
[ArrayAdapter::create()->get()],
Expand Down
2 changes: 1 addition & 1 deletion tests/Dotenv/Parser/LexerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class LexerTest extends TestCase
/**
* @return array{string,string[]}[]
*/
public function provideLexCases()
public static function provideLexCases()
{
return [
['', []],
Expand Down
8 changes: 4 additions & 4 deletions tests/Dotenv/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function testDotenvStringOfSpacesConsideredEmpty()
*
* @return string[][]
*/
public function validBooleanValuesDataProvider()
public static function validBooleanValuesDataProvider()
{
return [
['VALID_EXPLICIT_LOWERCASE_TRUE'],
Expand Down Expand Up @@ -263,7 +263,7 @@ public function testCanValidateBooleansIfPresent(string $boolean)
*
* @return string[][]
*/
public function invalidBooleanValuesDataProvider()
public static function invalidBooleanValuesDataProvider()
{
return [
['INVALID_SOMETHING'],
Expand Down Expand Up @@ -332,7 +332,7 @@ public function testIfPresentBooleanNonExist()
*
* @return string[][]
*/
public function validIntegerValuesDataProvider()
public static function validIntegerValuesDataProvider()
{
return [
['VALID_ZERO'],
Expand Down Expand Up @@ -370,7 +370,7 @@ public function testCanValidateIntegersIfPresent(string $integer)
*
* @return string[][]
*/
public function invalidIntegerValuesDataProvider()
public static function invalidIntegerValuesDataProvider()
{
return [
['INVALID_SOMETHING'],
Expand Down
Loading

0 comments on commit f1f4ca5

Please sign in to comment.