Skip to content

Commit c2a3225

Browse files
committed
Improve PHPStan situation
1 parent 71daf73 commit c2a3225

2 files changed

Lines changed: 4 additions & 28 deletions

File tree

Classes/TestingFramework.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function assertPHPDataSet(string $filePath): void
6868
// Unset already asserted record to only keep unexpected records.
6969
unset($records[$result]);
7070

71-
// Increase assertion counter
71+
// @phpstan-ignore staticMethod.alreadyNarrowedType (We want to increase assertion counter, but there is no public API)
7272
self::assertTrue(true);
7373
}
7474

@@ -100,6 +100,7 @@ private function getDataSet(string $filePath): array
100100
throw new \RuntimeException('Given file did not return an array: ' . $filePath, 1760942255);
101101
}
102102

103+
// @phpstan-ignore return.type (We don't want to validate the whole structure)
103104
return $dataSet;
104105
}
105106

@@ -111,12 +112,11 @@ private function ensureFileExists(string $filePath): void
111112
}
112113

113114
/**
114-
* @param array{uid: int|string|null} $assertion
115-
* @param array<string|int, mixed[]> $records
115+
* @param array<string, string> $assertion
116+
* @param mixed[] $records
116117
*/
117118
private function getAssertionErrorMessageForNoneMatchingRecord(array $assertion, array $records, string $tableName): string
118119
{
119-
// Handle error
120120
if (isset($assertion['uid']) && empty($records[$assertion['uid']])) {
121121
return 'Record "' . $tableName . ':' . $assertion['uid'] . '" not found in database';
122122
}

phpstan-baseline.neon

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,8 @@ parameters:
1818
count: 1
1919
path: Classes/Converter/Xml.php
2020

21-
-
22-
rawMessage: 'Call to static method PHPUnit\Framework\Assert::assertTrue() with true will always evaluate to true.'
23-
identifier: staticMethod.alreadyNarrowedType
24-
count: 1
25-
path: Tests/Functional/AbstractFunctionalTestCase.php
26-
2721
-
2822
rawMessage: 'Cognitive complexity for "Codappix\Typo3PhpDatasets\Tests\Functional\AbstractFunctionalTestCase::assertPHPDataSet()" is 12, keep it under 9'
2923
identifier: complexity.functionLike
3024
count: 1
3125
path: Tests/Functional/AbstractFunctionalTestCase.php
32-
33-
-
34-
rawMessage: 'Method Codappix\Typo3PhpDatasets\Tests\Functional\AbstractFunctionalTestCase::getDataSet() should return array<string, array<array<string, string>>> but returns array<mixed, mixed>.'
35-
identifier: return.type
36-
count: 1
37-
path: Tests/Functional/AbstractFunctionalTestCase.php
38-
39-
-
40-
rawMessage: 'Parameter #1 $assertion of method Codappix\Typo3PhpDatasets\Tests\Functional\AbstractFunctionalTestCase::getAssertionErrorMessageForNoneMatchingRecord() expects array{uid: int|string|null}, array<string, string> given.'
41-
identifier: argument.type
42-
count: 1
43-
path: Tests/Functional/AbstractFunctionalTestCase.php
44-
45-
-
46-
rawMessage: 'Parameter #2 $records of method Codappix\Typo3PhpDatasets\Tests\Functional\AbstractFunctionalTestCase::getAssertionErrorMessageForNoneMatchingRecord() expects array<int|string, array<mixed>>, array given.'
47-
identifier: argument.type
48-
count: 1
49-
path: Tests/Functional/AbstractFunctionalTestCase.php

0 commit comments

Comments
 (0)