Skip to content

Commit 20d6a1b

Browse files
Updates
1 parent a59a137 commit 20d6a1b

24 files changed

+270
-104
lines changed

.github/SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Supported Versions
44

55
After each new major release, the previous release will be supported for no
6-
less than 2 years, unless explictly stated otherwise. This may mean that there
6+
less than 2 years, unless explicitly stated otherwise. This may mean that there
77
are multiple supported versions at any given time.
88

99
## Reporting a Vulnerability

.github/workflows/static.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
phpstan:
99
name: PHPStan
10-
runs-on: ubuntu-22.04
10+
runs-on: ubuntu-24.04
1111

1212
steps:
1313
- name: Checkout code
@@ -16,21 +16,21 @@ jobs:
1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.3'
19+
php-version: '8.4'
2020
tools: composer:v2
2121
coverage: none
2222
env:
2323
update: true
2424

2525
- name: Install Dependencies
26-
uses: nick-invision/retry@v2
26+
uses: nick-invision/retry@v3
2727
with:
2828
timeout_minutes: 5
2929
max_attempts: 5
3030
command: composer update --no-interaction --no-progress
3131

3232
- name: Install PHPStan
33-
uses: nick-invision/retry@v2
33+
uses: nick-invision/retry@v3
3434
with:
3535
timeout_minutes: 5
3636
max_attempts: 5
@@ -41,7 +41,7 @@ jobs:
4141

4242
psalm:
4343
name: Psalm
44-
runs-on: ubuntu-22.04
44+
runs-on: ubuntu-24.04
4545

4646
steps:
4747
- name: Checkout code
@@ -50,21 +50,21 @@ jobs:
5050
- name: Setup PHP
5151
uses: shivammathur/setup-php@v2
5252
with:
53-
php-version: '8.3'
53+
php-version: '8.4'
5454
tools: composer:v2
5555
coverage: none
5656
env:
5757
update: true
5858

5959
- name: Install Dependencies
60-
uses: nick-invision/retry@v2
60+
uses: nick-invision/retry@v3
6161
with:
6262
timeout_minutes: 5
6363
max_attempts: 5
6464
command: composer update --no-interaction --no-progress
6565

6666
- name: Install Psalm
67-
uses: nick-invision/retry@v2
67+
uses: nick-invision/retry@v3
6868
with:
6969
timeout_minutes: 5
7070
max_attempts: 5

.github/workflows/tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
jobs:
88
latest:
99
name: PHP ${{ matrix.php }} Latest
10-
runs-on: ubuntu-22.04
10+
runs-on: ubuntu-24.04
1111

1212
strategy:
1313
matrix:
@@ -28,7 +28,7 @@ jobs:
2828
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
2929

3030
- name: Install Latest Dependencies
31-
uses: nick-invision/retry@v2
31+
uses: nick-invision/retry@v3
3232
with:
3333
timeout_minutes: 5
3434
max_attempts: 5
@@ -39,7 +39,7 @@ jobs:
3939

4040
lowest:
4141
name: PHP ${{ matrix.php }} Lowest
42-
runs-on: ubuntu-22.04
42+
runs-on: ubuntu-24.04
4343

4444
strategy:
4545
matrix:
@@ -60,7 +60,7 @@ jobs:
6060
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
6161

6262
- name: Install Lowest Dependencies
63-
uses: nick-invision/retry@v2
63+
uses: nick-invision/retry@v3
6464
with:
6565
timeout_minutes: 5
6666
max_attempts: 5

Makefile

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
install:
2-
@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
3-
@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
2+
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.4-base update
3+
@docker run -it -w /data -v ${PWD}:/data:delegated -v ~/.composer:/root/.composer:delegated --entrypoint composer --rm registry.gitlab.com/grahamcampbell/php:8.4-base bin all update
44

55
phpunit:
6-
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:8.3-cli
6+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpunit --rm registry.gitlab.com/grahamcampbell/php:8.4-cli
77

88
phpstan-analyze:
9-
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.3-cli analyze
9+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.4-cli analyze
1010

1111
phpstan-baseline:
12-
@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
12+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/phpstan --rm registry.gitlab.com/grahamcampbell/php:8.4-cli analyze --generate-baseline
1313

1414
psalm-analyze:
15-
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.3-cli
15+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.4-cli
1616

1717
psalm-baseline:
18-
@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
18+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.4-cli --set-baseline=psalm-baseline.xml
1919

2020
psalm-show-info:
21-
@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
21+
@docker run -it -w /data -v ${PWD}:/data:delegated --entrypoint vendor/bin/psalm.phar --rm registry.gitlab.com/grahamcampbell/php:8.4-cli --show-info=true
2222

2323
test: phpunit phpstan-analyze psalm-analyze
2424

phpstan-baseline.neon

+146-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,163 @@
11
parameters:
22
ignoreErrors:
33
-
4-
message: "#^Parameter \\#2 \\$callback of function array_reduce expects callable\\(GrahamCampbell\\\\ResultType\\\\Result\\<array\\{Dotenv\\\\Parser\\\\Value, int\\}, mixed\\>\\|GrahamCampbell\\\\ResultType\\\\Result\\<array\\{mixed, int\\}, string\\>, string\\)\\: \\(GrahamCampbell\\\\ResultType\\\\Result\\<array\\{Dotenv\\\\Parser\\\\Value, int\\}, mixed\\>\\|GrahamCampbell\\\\ResultType\\\\Result\\<array\\{mixed, int\\}, string\\>\\), Closure\\(GrahamCampbell\\\\ResultType\\\\Result, string\\)\\: GrahamCampbell\\\\ResultType\\\\Result\\<array\\{Dotenv\\\\Parser\\\\Value, int\\}, string\\> given\\.$#"
4+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<Dotenv\\Parser\\Value\> is not subtype of type PhpOption\\Option\<Dotenv\\Parser\\Value\|null\>\.$#'
5+
identifier: varTag.type
6+
count: 1
7+
path: src/Parser/Entry.php
8+
9+
-
10+
message: '#^Anonymous function should return GrahamCampbell\\ResultType\\Result\<mixed, string\> but returns GrahamCampbell\\ResultType\\Result\<Dotenv\\Parser\\Entry, string\>\.$#'
11+
identifier: return.type
12+
count: 1
13+
path: src/Parser/EntryParser.php
14+
15+
-
16+
message: '#^Method Dotenv\\Parser\\EntryParser\:\:parse\(\) should return GrahamCampbell\\ResultType\\Result\<Dotenv\\Parser\\Entry, string\> but returns GrahamCampbell\\ResultType\\Result\<mixed, string\>\.$#'
17+
identifier: return.type
518
count: 1
619
path: src/Parser/EntryParser.php
720

821
-
9-
message: "#^Only booleans are allowed in a negated boolean, int\\|false given\\.$#"
22+
message: '#^PHPDoc tag @var with type GrahamCampbell\\ResultType\\Result\<Dotenv\\Parser\\Value\|null, string\> is not subtype of type GrahamCampbell\\ResultType\\Result\<Dotenv\\Parser\\Value, string\>\|GrahamCampbell\\ResultType\\Result\<null, mixed\>\.$#'
23+
identifier: varTag.type
24+
count: 1
25+
path: src/Parser/EntryParser.php
26+
27+
-
28+
message: '#^Parameter \#2 \$callback of function array_reduce expects callable\(GrahamCampbell\\ResultType\\Result\<array\{Dotenv\\Parser\\Value, int\}, mixed\>\|GrahamCampbell\\ResultType\\Result\<array\{mixed, int\}, string\>, string\)\: \(GrahamCampbell\\ResultType\\Result\<array\{Dotenv\\Parser\\Value, int\}, mixed\>\|GrahamCampbell\\ResultType\\Result\<array\{mixed, int\}, string\>\), Closure\(GrahamCampbell\\ResultType\\Result, string\)\: GrahamCampbell\\ResultType\\Result\<array\{Dotenv\\Parser\\Value, int\}, string\> given\.$#'
29+
identifier: argument.type
30+
count: 1
31+
path: src/Parser/EntryParser.php
32+
33+
-
34+
message: '#^Only booleans are allowed in a negated boolean, int\|false given\.$#'
35+
identifier: booleanNot.exprNotBoolean
36+
count: 1
37+
path: src/Parser/Lexer.php
38+
39+
-
40+
message: '#^Parameter \#1 \$pattern of function preg_match expects string, mixed given\.$#'
41+
identifier: argument.type
1042
count: 1
1143
path: src/Parser/Lexer.php
1244

1345
-
14-
message: "#^Parameter \\#1 \\$readers of class Dotenv\\\\Repository\\\\RepositoryBuilder constructor expects array\\<Dotenv\\\\Repository\\\\Adapter\\\\ReaderInterface\\>, array\\<Dotenv\\\\Repository\\\\Adapter\\\\ReaderInterface\\|S\\> given\\.$#"
46+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<Dotenv\\Repository\\Adapter\\AdapterInterface\> is not subtype of type PhpOption\\Some\<Dotenv\\Repository\\Adapter\\ApacheAdapter\>\.$#'
47+
identifier: varTag.type
48+
count: 1
49+
path: src/Repository/Adapter/ApacheAdapter.php
50+
51+
-
52+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<string\> is not subtype of type PhpOption\\Option\<string\|false\|null\>\.$#'
53+
identifier: varTag.type
54+
count: 1
55+
path: src/Repository/Adapter/ApacheAdapter.php
56+
57+
-
58+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<Dotenv\\Repository\\Adapter\\AdapterInterface\> is not subtype of type PhpOption\\Some\<Dotenv\\Repository\\Adapter\\ArrayAdapter\>\.$#'
59+
identifier: varTag.type
60+
count: 1
61+
path: src/Repository/Adapter/ArrayAdapter.php
62+
63+
-
64+
message: '#^Cannot cast mixed to string\.$#'
65+
identifier: cast.string
66+
count: 1
67+
path: src/Repository/Adapter/EnvConstAdapter.php
68+
69+
-
70+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<Dotenv\\Repository\\Adapter\\AdapterInterface\> is not subtype of type PhpOption\\Some\<Dotenv\\Repository\\Adapter\\EnvConstAdapter\>\.$#'
71+
identifier: varTag.type
72+
count: 1
73+
path: src/Repository/Adapter/EnvConstAdapter.php
74+
75+
-
76+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<Dotenv\\Repository\\Adapter\\AdapterInterface\> is not subtype of type PhpOption\\Some\<Dotenv\\Repository\\Adapter\\PutenvAdapter\>\.$#'
77+
identifier: varTag.type
78+
count: 1
79+
path: src/Repository/Adapter/PutenvAdapter.php
80+
81+
-
82+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<string\> is not subtype of type PhpOption\\Option\<string\|false\>\.$#'
83+
identifier: varTag.type
84+
count: 1
85+
path: src/Repository/Adapter/PutenvAdapter.php
86+
87+
-
88+
message: '#^Cannot cast mixed to string\.$#'
89+
identifier: cast.string
90+
count: 1
91+
path: src/Repository/Adapter/ServerConstAdapter.php
92+
93+
-
94+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<Dotenv\\Repository\\Adapter\\AdapterInterface\> is not subtype of type PhpOption\\Some\<Dotenv\\Repository\\Adapter\\ServerConstAdapter\>\.$#'
95+
identifier: varTag.type
96+
count: 1
97+
path: src/Repository/Adapter/ServerConstAdapter.php
98+
99+
-
100+
message: '#^Parameter \#1 \$callable of method PhpOption\\Some\<Dotenv\\Repository\\Adapter\\AdapterInterface\|string\>\:\:flatMap\(\) expects callable\(Dotenv\\Repository\\Adapter\\AdapterInterface\|string\)\: PhpOption\\Option\<S\>, Closure\(mixed\)\: mixed given\.$#'
101+
identifier: argument.type
102+
count: 1
103+
path: src/Repository/RepositoryBuilder.php
104+
105+
-
106+
message: '#^Parameter \#1 \$callable of method PhpOption\\Some\<Dotenv\\Repository\\Adapter\\ReaderInterface\|string\>\:\:flatMap\(\) expects callable\(Dotenv\\Repository\\Adapter\\ReaderInterface\|string\)\: PhpOption\\Option\<S\>, Closure\(mixed\)\: mixed given\.$#'
107+
identifier: argument.type
108+
count: 1
109+
path: src/Repository/RepositoryBuilder.php
110+
111+
-
112+
message: '#^Parameter \#1 \$callable of method PhpOption\\Some\<Dotenv\\Repository\\Adapter\\WriterInterface\|string\>\:\:flatMap\(\) expects callable\(Dotenv\\Repository\\Adapter\\WriterInterface\|string\)\: PhpOption\\Option\<S\>, Closure\(mixed\)\: mixed given\.$#'
113+
identifier: argument.type
114+
count: 1
115+
path: src/Repository/RepositoryBuilder.php
116+
117+
-
118+
message: '#^Parameter \#1 \$readers of class Dotenv\\Repository\\RepositoryBuilder constructor expects array\<Dotenv\\Repository\\Adapter\\ReaderInterface\>, array\<Dotenv\\Repository\\Adapter\\ReaderInterface\|S\> given\.$#'
119+
identifier: argument.type
15120
count: 2
16121
path: src/Repository/RepositoryBuilder.php
17122

18123
-
19-
message: "#^Parameter \\#2 \\$writers of class Dotenv\\\\Repository\\\\RepositoryBuilder constructor expects array\\<Dotenv\\\\Repository\\\\Adapter\\\\WriterInterface\\>, array\\<Dotenv\\\\Repository\\\\Adapter\\\\WriterInterface\\|S\\> given\\.$#"
124+
message: '#^Parameter \#2 \$writers of class Dotenv\\Repository\\RepositoryBuilder constructor expects array\<Dotenv\\Repository\\Adapter\\WriterInterface\>, array\<Dotenv\\Repository\\Adapter\\WriterInterface\|S\> given\.$#'
125+
identifier: argument.type
20126
count: 2
21127
path: src/Repository/RepositoryBuilder.php
128+
129+
-
130+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<string\> is not subtype of type PhpOption\\Option\<string\|false\>\.$#'
131+
identifier: varTag.type
132+
count: 1
133+
path: src/Store/File/Reader.php
134+
135+
-
136+
message: '#^Method Dotenv\\Util\\Regex\:\:occurrences\(\) should return GrahamCampbell\\ResultType\\Result\<int, string\> but returns GrahamCampbell\\ResultType\\Result\<int\<0, max\>, string\>\.$#'
137+
identifier: return.type
138+
count: 1
139+
path: src/Util/Regex.php
140+
141+
-
142+
message: '#^Call to function is_string\(\) with string will always evaluate to true\.$#'
143+
identifier: function.alreadyNarrowedType
144+
count: 1
145+
path: src/Util/Str.php
146+
147+
-
148+
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
149+
identifier: equal.notAllowed
150+
count: 1
151+
path: src/Util/Str.php
152+
153+
-
154+
message: '#^PHPDoc tag @var with type GrahamCampbell\\ResultType\\Result\<string, string\> is not subtype of type GrahamCampbell\\ResultType\\Result\<mixed, non\-falsy\-string\>\.$#'
155+
identifier: varTag.type
156+
count: 2
157+
path: src/Util/Str.php
158+
159+
-
160+
message: '#^PHPDoc tag @var with type PhpOption\\Option\<int\> is not subtype of type PhpOption\\Option\<int\<0, max\>\|false\>\.$#'
161+
identifier: varTag.type
162+
count: 1
163+
path: src/Util/Str.php

psalm-baseline.xml

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505">
2+
<files psalm-version="6.10.0@9c0add4eb88d4b169ac04acb7c679918cbb9c252">
3+
<file src="src/Dotenv.php">
4+
<ClassMustBeFinal>
5+
<code><![CDATA[Dotenv]]></code>
6+
</ClassMustBeFinal>
7+
</file>
8+
<file src="src/Parser/EntryParser.php">
9+
<PossiblyFalseArgument>
10+
<code><![CDATA[\strtok($subject, "\n")]]></code>
11+
</PossiblyFalseArgument>
12+
</file>
313
<file src="src/Repository/Adapter/EnvConstAdapter.php">
414
<RedundantConditionGivenDocblockType>
515
<code><![CDATA[\is_scalar($value)]]></code>
@@ -30,7 +40,12 @@
3040
}, $subject)]]></code>
3141
</InvalidReturnStatement>
3242
<InvalidReturnType>
33-
<code><![CDATA[\GrahamCampbell\ResultType\Result<int,string>]]></code>
43+
<code><![CDATA[\GrahamCampbell\ResultType\Result<int, string>]]></code>
3444
</InvalidReturnType>
3545
</file>
46+
<file src="src/Validator.php">
47+
<ClassMustBeFinal>
48+
<code><![CDATA[Validator]]></code>
49+
</ClassMustBeFinal>
50+
</file>
3651
</files>

psalm.xml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
errorBaseline="psalm-baseline.xml"
99
findUnusedBaselineEntry="true"
1010
findUnusedCode="false"
11+
ensureOverrideAttribute="false"
1112
>
1213
<projectFiles>
1314
<directory name="src" />

src/Dotenv.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public static function createArrayBacked($paths, $names = null, bool $shortCircu
199199
*
200200
* @throws \Dotenv\Exception\InvalidFileException
201201
*
202-
* @return array<string,string|null>
202+
* @return array<string, string|null>
203203
*/
204204
public static function parse(string $content)
205205
{
@@ -215,7 +215,7 @@ public static function parse(string $content)
215215
*
216216
* @throws \Dotenv\Exception\InvalidPathException|\Dotenv\Exception\InvalidEncodingException|\Dotenv\Exception\InvalidFileException
217217
*
218-
* @return array<string,string|null>
218+
* @return array<string, string|null>
219219
*/
220220
public function load()
221221
{
@@ -229,7 +229,7 @@ public function load()
229229
*
230230
* @throws \Dotenv\Exception\InvalidEncodingException|\Dotenv\Exception\InvalidFileException
231231
*
232-
* @return array<string,string|null>
232+
* @return array<string, string|null>
233233
*/
234234
public function safeLoad()
235235
{

src/Loader/Loader.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ final class Loader implements LoaderInterface
1919
* @param \Dotenv\Repository\RepositoryInterface $repository
2020
* @param \Dotenv\Parser\Entry[] $entries
2121
*
22-
* @return array<string,string|null>
22+
* @return array<string, string|null>
2323
*/
2424
public function load(RepositoryInterface $repository, array $entries)
2525
{
26+
/** @var array<string, string|null> */
2627
return \array_reduce($entries, static function (array $vars, Entry $entry) use ($repository) {
2728
$name = $entry->getName();
2829

0 commit comments

Comments
 (0)