Skip to content

Commit a20cb39

Browse files
Merge pull request #16 from a-menshchikov/3.x
Fix auditor errors
2 parents c4d0cb8 + cdfaa06 commit a20cb39

15 files changed

Lines changed: 95 additions & 87 deletions

.github/workflows/audit.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,12 @@ jobs:
77
name: Audit
88
strategy:
99
matrix:
10-
php-version: [ '8.2', '8.3' ]
10+
php-version: [ '8.2', '8.3', '8.4' ]
1111
fail-fast: false
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Checkout (Push)
14+
- name: Checkout
1515
uses: actions/checkout@v4
16-
if: github.event_name == 'push'
17-
with:
18-
fetch-depth: 0
19-
20-
- name: Checkout (PR)
21-
uses: actions/checkout@v4
22-
if: github.event_name == 'pull_request'
23-
with:
24-
ref: ${{ github.event.pull_request.head.ref }}
25-
fetch-depth: 0
2616

2717
- name: Setup PHP
2818
uses: shivammathur/setup-php@v2
@@ -54,13 +44,13 @@ jobs:
5444
echo "::endgroup::"
5545
5646
- name: Auditor
57-
uses: docker://nbgrp/auditor:0.23.1
47+
uses: docker://nbgrp/auditor:0.29.0
5848

5949
- name: Tests
6050
run: vendor/bin/simple-phpunit
6151

6252
- name: Codecov
63-
uses: codecov/codecov-action@v3
53+
uses: codecov/codecov-action@v5
6454
with:
6555
token: ${{ secrets.CODECOV_TOKEN }}
6656
files: ./clover.xml

.php-cs-fixer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
],
3232
'comment_to_phpdoc' => [
3333
'ignored_tags' => [
34+
'codeCoverageIgnoreStart',
35+
'codeCoverageIgnoreEnd',
36+
'codeCoverageIgnore',
3437
'phan-suppress-current-line',
3538
'phan-suppress-next-line',
3639
'see',

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"symfony/http-kernel": "^7"
2525
},
2626
"require-dev": {
27+
"phpunit/phpunit": "^11.5",
2728
"roave/security-advisories": "dev-latest",
2829
"symfony/phpunit-bridge": "^7"
2930
},

grumphp.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ grumphp:
77
enabled: false
88

99
tasks:
10+
composer:
11+
strict: true
12+
1013
composer_normalize:
1114
indent_size: 4
1215
indent_style: 'space'
@@ -32,4 +35,4 @@ grumphp:
3235
no_cache: true
3336
show_info: true
3437

35-
securitychecker_local: ~
38+
securitychecker_composeraudit: ~

phpcs.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<element value="private methods" />
6262
</property>
6363
</properties>
64+
<exclude-pattern>*/tests/*</exclude-pattern>
6465
</rule>
6566
<rule ref="SlevomatCodingStandard.Classes.MethodSpacing" />
6667
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference" />
@@ -185,14 +186,17 @@
185186

186187
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
187188
<properties>
188-
<property name="linesCountBeforeDeclare" value="0" />
189+
<property name="linesCountBeforeDeclare" value="1" />
189190
<property name="linesCountAfterDeclare" value="1" />
190191
<property name="spacesCountAroundEqualsSign" value="0" />
191192
</properties>
192193
</rule>
193194
<rule ref="SlevomatCodingStandard.TypeHints.DisallowArrayTypeHintSyntax">
194195
<properties>
195-
<property name="traversableTypeHints" value="true" />
196+
<property name="traversableTypeHints" type="array">
197+
<element value="Traversable" />
198+
<element value="\ArrayIterator" />
199+
</property>
196200
</properties>
197201
</rule>
198202
<rule ref="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" />
@@ -204,9 +208,9 @@
204208
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
205209
</rule>
206210
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing" />
207-
<rule ref="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat">
211+
<rule ref="SlevomatCodingStandard.TypeHints.DNFTypeHintFormat">
208212
<properties>
209-
<property name="withSpaces" value="no" />
213+
<property name="withSpacesAroundOperators" value="no" />
210214
<property name="shortNullable" value="yes" />
211215
<property name="nullPosition" value="last" />
212216
</properties>

phpstan.neon

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ parameters:
33
paths:
44
- src
55
- tests
6-
bootstrapFiles:
7-
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
8-
9-
checkMissingIterableValueType: false
106

117
ignoreErrors:
128
-
139
message: '/Cannot cast mixed to (int|float|string)/'
1410
path: 'src/ArrayCastEnvVarProcessor.php'
11+
-
12+
identifier: missingType.iterableValue
13+
-
14+
identifier: phpDoc.parseError

phpunit.xml.dist

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="vendor/bin/.phpunit/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
54
colors="true"
65
bootstrap="vendor/autoload.php"
7-
>
6+
cacheDirectory=".phpunit.cache"
7+
requireCoverageMetadata="true"
8+
beStrictAboutCoverageMetadata="true"
9+
beStrictAboutOutputDuringTests="true"
10+
displayDetailsOnPhpunitDeprecations="true"
11+
failOnPhpunitDeprecation="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
>
815

916
<php>
1017
<ini name="error_reporting" value="-1" />
11-
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
12-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[indirect]=1" />
18+
<server name="SYMFONY_PHPUNIT_VERSION" value="11.5" />
19+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[total]=13&amp;max[indirect]=6" />
1320
</php>
1421

1522
<testsuites>
1623
<testsuite name="NbgroupEnvBundle Test Suite">
17-
<directory>./tests/</directory>
24+
<directory>tests</directory>
1825
</testsuite>
1926
</testsuites>
2027

21-
<coverage cacheDirectory=".phpunit.cache/code-coverage"
22-
processUncoveredFiles="true"
28+
<source ignoreIndirectDeprecations="true"
29+
restrictNotices="true"
30+
restrictWarnings="true"
2331
>
2432
<include>
25-
<directory suffix=".php">src</directory>
33+
<directory>src</directory>
2634
</include>
27-
<exclude>
28-
<file>src/CsvEnvVarProcessor.php</file>
29-
<file>src/NbgroupEnvBundle.php</file>
30-
</exclude>
35+
</source>
36+
37+
<coverage>
3138
<report>
3239
<clover outputFile="clover.xml" />
3340
</report>

psalm.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,12 @@
1717
</projectFiles>
1818

1919
<issueHandlers>
20-
<UndefinedClass>
21-
<errorLevel type="suppress">
22-
<directory name="tests" />
23-
<file name=".php-cs-fixer.php" />
24-
</errorLevel>
25-
</UndefinedClass>
26-
2720
<!-- PHPUnit -->
2821
<PropertyNotSetInConstructor>
2922
<errorLevel type="suppress">
3023
<directory name="tests" />
3124
</errorLevel>
3225
</PropertyNotSetInConstructor>
33-
<MissingDependency>
34-
<errorLevel type="suppress">
35-
<directory name="tests" />
36-
</errorLevel>
37-
</MissingDependency>
3826
</issueHandlers>
3927

4028
<plugins>

src/ArrayCastEnvVarProcessor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
final class ArrayCastEnvVarProcessor implements EnvVarProcessorInterface
1212
{
13+
#[\Override]
1314
public static function getProvidedTypes(): array
1415
{
1516
return [
@@ -27,6 +28,7 @@ public static function getProvidedTypes(): array
2728
*
2829
* @psalm-suppress MixedReturnTypeCoercion
2930
*/
31+
#[\Override]
3032
public function getEnv(string $prefix, string $name, \Closure $getEnv): array
3133
{
3234
$env = (array) $getEnv($name);
@@ -46,6 +48,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv): array
4648
*/
4749
private static function getBooleanMapper(): callable
4850
{
51+
/** @psalm-suppress RiskyTruthyFalsyComparison */
4952
return static fn (mixed $value): bool => (bool) (filter_var($value, \FILTER_VALIDATE_BOOLEAN, ['flags' => \FILTER_NULL_ON_FAILURE]) ?? filter_var($value, \FILTER_VALIDATE_INT) ?: filter_var($value, \FILTER_VALIDATE_FLOAT));
5053
}
5154

@@ -55,6 +58,7 @@ private static function getBooleanMapper(): callable
5558
private static function getIntegerMapper(string $name): callable
5659
{
5760
return static function (mixed $value) use ($name): int {
61+
/** @psalm-suppress RiskyTruthyFalsyComparison */
5862
if ((filter_var($value, \FILTER_VALIDATE_INT) ?: filter_var($value, \FILTER_VALIDATE_FLOAT)) === false) {
5963
throw new RuntimeException('Non-numeric member of environment variable "'.$name.'" cannot be cast to int.');
6064
}

src/CsvEnvVarProcessor.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
1010
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1111

12+
// @codeCoverageIgnoreStart
1213
if (class_exists(CsvEnvVarProcessor::class, false)) {
1314
return;
1415
}
16+
// @codeCoverageIgnoreEnd
1517

1618
final class CsvEnvVarProcessor implements EnvVarProcessorInterface
1719
{
@@ -26,6 +28,7 @@ public function __construct(array $delimiterMap)
2628
$this->delimiterMap = $delimiterMap;
2729
}
2830

31+
#[\Override]
2932
public static function getProvidedTypes(): array
3033
{
3134
// NB
@@ -36,6 +39,7 @@ public static function getProvidedTypes(): array
3639
/**
3740
* @return non-empty-list<string|null>
3841
*/
42+
#[\Override]
3943
public function getEnv(string $prefix, string $name, \Closure $getEnv): array
4044
{
4145
if (\array_key_exists($prefix, $this->delimiterMap) === false) {
@@ -49,6 +53,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv): array
4953
throw new RuntimeException('Environment variable "'.$name.'" should be a string.');
5054
}
5155

56+
// @phpstan-ignore greaterOrEqual.alwaysTrue
5257
return str_getcsv($env, $delimiter, '"', \PHP_VERSION_ID >= 70400 ? '' : '\\');
5358
}
5459
}

0 commit comments

Comments
 (0)