Skip to content

Commit d18a2d5

Browse files
Fix issues reported by PHPStan (level 7)
1 parent dfdaf8e commit d18a2d5

10 files changed

Lines changed: 73 additions & 42 deletions

File tree

src/Metadata/UsesNamespace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function isUsesNamespace(): true
3737
}
3838

3939
/**
40-
* @return class-string
40+
* @return non-empty-string
4141
*/
4242
public function namespace(): string
4343
{

src/Runner/ErrorHandler.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ private function trigger(TestMethod $test, bool $isUserland, string $errorString
556556
}
557557

558558
/**
559-
* @param list<array{file?: string, line?: int, class?: class-string, function?: string, type?: string, args?: list<mixed>}> $trace
559+
* @param list<array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object}> $trace
560560
*/
561561
private function triggerForUserlandDeprecation(TestMethod $test, string $message, array $trace): IssueTrigger
562562
{
@@ -624,7 +624,7 @@ private function categorizeFileWithoutTest(string $file): Code
624624
}
625625

626626
/**
627-
* @param list<array{file?: string, line?: int, class?: class-string, function?: string, type?: string, args?: list<mixed>}> $trace
627+
* @param list<array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object}> $trace
628628
*/
629629
private function triggerForUserlandDeprecationWithoutTest(string $message, array $trace): IssueTrigger
630630
{
@@ -656,7 +656,7 @@ private function triggerForUserlandDeprecationWithoutTest(string $message, array
656656
}
657657

658658
/**
659-
* @return list<array{file: string, line: int, class?: string, function?: string, type: string, args?: list<mixed>, object?: object}>
659+
* @return list<array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object}>
660660
*/
661661
private function filteredStackTrace(): array
662662
{
@@ -690,7 +690,7 @@ private function filteredStackTrace(): array
690690
}
691691

692692
/**
693-
* @return ?array{file: non-empty-string, line: positive-int}
693+
* @return ?array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object}
694694
*/
695695
private function guessDeprecationFrame(): ?array
696696
{
@@ -718,7 +718,7 @@ private function guessDeprecationFrame(): ?array
718718
}
719719

720720
/**
721-
* @return list<array{file: string, line: ?int, class?: class-string, function?: string, type: string, args?: list<mixed>, object?: object}>
721+
* @return list<array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object}>
722722
*/
723723
private function errorStackTrace(bool $ignoreArgs = true): array
724724
{
@@ -738,17 +738,17 @@ private function errorStackTrace(bool $ignoreArgs = true): array
738738
}
739739

740740
/**
741-
* @param array{class? : class-string, function?: non-empty-string} $frame
742-
* @param non-empty-string $function
741+
* @param array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object} $frame
742+
* @param non-empty-string $function
743743
*/
744744
private function frameIsFunction(array $frame, string $function): bool
745745
{
746746
return !isset($frame['class']) && isset($frame['function']) && $frame['function'] === $function;
747747
}
748748

749749
/**
750-
* @param array{class? : class-string, function?: non-empty-string} $frame
751-
* @param array{className: class-string, methodName: non-empty-string} $method
750+
* @param array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object} $frame
751+
* @param array{className: class-string, methodName: non-empty-string} $method
752752
*/
753753
private function frameIsMethod(array $frame, array $method): bool
754754
{
@@ -758,9 +758,6 @@ private function frameIsMethod(array $frame, array $method): bool
758758
$frame['function'] === $method['methodName'];
759759
}
760760

761-
/**
762-
* @return non-empty-string
763-
*/
764761
private function stackTrace(): string
765762
{
766763
$buffer = '';

src/Runner/Filter/Factory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Iterator;
1515
use PHPUnit\Framework\Test;
1616
use PHPUnit\Framework\TestSuite;
17+
use RecursiveFilterIterator;
1718

1819
/**
1920
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
@@ -23,7 +24,7 @@
2324
final class Factory
2425
{
2526
/**
26-
* @var list<array{className: class-string<FilterIterator<int, Test, Iterator<int, Test>>>, argument: list<non-empty-string>|non-empty-string}>
27+
* @var list<array{className: class-string<RecursiveFilterIterator>, argument: list<non-empty-string>|non-empty-string}>
2728
*/
2829
private array $filters = [];
2930

src/Runner/IssueTriggerResolver/DefaultResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
final class DefaultResolver implements Resolver
1818
{
1919
/**
20-
* @param list<array{file?: string, line?: int, class?: class-string, function?: string, type?: string, args?: list<mixed>}> $trace
20+
* @param list<array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object}> $trace
2121
*/
2222
public function resolve(array $trace, string $message): Resolution
2323
{

src/Runner/IssueTriggerResolver/Resolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface Resolver
1717
/**
1818
* Return null to defer to the next resolver in the chain.
1919
*
20-
* @param list<array{file?: string, line?: int, class?: class-string, function?: string, type?: string, args?: list<mixed>, object?: object}> $trace
20+
* @param list<array{function: string, line?: int, file?: string, class?: class-string, type?: '->'|'::', args?: list<mixed>, object?: object}> $trace
2121
*/
2222
public function resolve(array $trace, string $message): ?Resolution;
2323
}

src/Runner/TestResult/Issue.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,21 @@ final class Issue
4646
private ?string $stackTrace;
4747

4848
/**
49-
* @param non-empty-string $file
50-
* @param positive-int $line
51-
* @param non-empty-string $description
49+
* @param non-empty-string $file
50+
* @param positive-int $line
51+
* @param non-empty-string $description
52+
* @param ?non-empty-string $stackTrace
5253
*/
5354
public static function from(string $file, int $line, string $description, Test $triggeringTest, ?string $stackTrace = null): self
5455
{
5556
return new self($file, $line, $description, $triggeringTest, $stackTrace);
5657
}
5758

5859
/**
59-
* @param non-empty-string $file
60-
* @param positive-int $line
61-
* @param non-empty-string $description
60+
* @param non-empty-string $file
61+
* @param positive-int $line
62+
* @param non-empty-string $description
63+
* @param ?non-empty-string $stackTrace
6264
*/
6365
private function __construct(string $file, int $line, string $description, Test $triggeringTest, ?string $stackTrace)
6466
{

src/TextUI/Configuration/Configuration.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,18 @@
480480

481481
/**
482482
* @param list<non-empty-string> $cliArguments
483+
* @param ?non-empty-string $testFilesFile
484+
* @param ?non-empty-string $configurationFile
485+
* @param ?non-empty-string $bootstrap
483486
* @param array<non-empty-string, non-empty-string> $bootstrapForTestSuite
487+
* @param ?non-empty-string $cacheDirectory
488+
* @param ?non-empty-string $coverageCacheDirectory
489+
* @param non-empty-string $testResultCacheFile
490+
* @param ?non-empty-string $coverageClover
491+
* @param ?non-empty-string $coverageCobertura
492+
* @param ?non-empty-string $coverageCrap4j
484493
* @param non-negative-int $coverageCrap4jThreshold
494+
* @param ?non-empty-string $coverageHtml
485495
* @param non-negative-int $coverageHtmlLowUpperBound
486496
* @param non-negative-int $coverageHtmlHighLowerBound
487497
* @param non-empty-string $coverageHtmlColorSuccessLow
@@ -502,8 +512,14 @@
502512
* @param non-empty-string $coverageHtmlColorDangerBarDark
503513
* @param non-empty-string $coverageHtmlColorBreadcrumbs
504514
* @param non-empty-string $coverageHtmlColorBreadcrumbsDark
515+
* @param ?non-empty-string $coverageHtmlCustomCssFile
516+
* @param ?non-empty-string $coverageOpenClover
517+
* @param ?non-empty-string $coveragePhp
518+
* @param ?non-empty-string $coverageText
519+
* @param ?non-empty-string $coverageXml
505520
* @param non-negative-int $stopOnDefect
506521
* @param non-negative-int $stopOnDeprecation
522+
* @param ?non-empty-string $specificDeprecationToStopOn
507523
* @param non-negative-int $stopOnError
508524
* @param non-negative-int $stopOnFailure
509525
* @param non-negative-int $stopOnIncomplete
@@ -519,6 +535,13 @@
519535
* @param positive-int $timeoutForSmallTests
520536
* @param positive-int $timeoutForMediumTests
521537
* @param positive-int $timeoutForLargeTests
538+
* @param ?non-empty-string $logfileTeamcity
539+
* @param ?non-empty-string $logfileJunit
540+
* @param ?non-empty-string $logfileOtr
541+
* @param ?non-empty-string $logfileTestdoxHtml
542+
* @param ?non-empty-string $logfileTestdoxText
543+
* @param ?non-empty-string $logEventsText
544+
* @param ?non-empty-string $logEventsVerboseText
522545
* @param ?non-empty-list<non-empty-string> $testsCovering
523546
* @param ?non-empty-list<non-empty-string> $testsUsing
524547
* @param ?non-empty-list<non-empty-string> $testsRequiringPhpExtension
@@ -527,6 +550,7 @@
527550
* @param list<non-empty-string> $groups
528551
* @param list<non-empty-string> $excludeGroups
529552
* @param positive-int $randomOrderSeed
553+
* @param ?non-empty-string $defaultTestSuite
530554
* @param non-empty-list<non-empty-string> $testSuffixes
531555
* @param positive-int $numberOfTestsBeforeGarbageCollection
532556
* @param null|non-empty-string $generateBaseline

src/TextUI/Configuration/Xml/CodeCoverage/Report/Html.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -130,26 +130,27 @@
130130
private ?string $customCssFile;
131131

132132
/**
133-
* @param non-negative-int $lowUpperBound
134-
* @param non-negative-int $highLowerBound
135-
* @param non-empty-string $colorSuccessLow
136-
* @param non-empty-string $colorSuccessLowDark
137-
* @param non-empty-string $colorSuccessMedium
138-
* @param non-empty-string $colorSuccessMediumDark
139-
* @param non-empty-string $colorSuccessHigh
140-
* @param non-empty-string $colorSuccessHighDark
141-
* @param non-empty-string $colorSuccessBar
142-
* @param non-empty-string $colorSuccessBarDark
143-
* @param non-empty-string $colorWarning
144-
* @param non-empty-string $colorWarningDark
145-
* @param non-empty-string $colorWarningBar
146-
* @param non-empty-string $colorWarningBarDark
147-
* @param non-empty-string $colorDanger
148-
* @param non-empty-string $colorDangerDark
149-
* @param non-empty-string $colorDangerBar
150-
* @param non-empty-string $colorDangerBarDark
151-
* @param non-empty-string $colorBreadcrumbs
152-
* @param non-empty-string $colorBreadcrumbsDark
133+
* @param non-negative-int $lowUpperBound
134+
* @param non-negative-int $highLowerBound
135+
* @param non-empty-string $colorSuccessLow
136+
* @param non-empty-string $colorSuccessLowDark
137+
* @param non-empty-string $colorSuccessMedium
138+
* @param non-empty-string $colorSuccessMediumDark
139+
* @param non-empty-string $colorSuccessHigh
140+
* @param non-empty-string $colorSuccessHighDark
141+
* @param non-empty-string $colorSuccessBar
142+
* @param non-empty-string $colorSuccessBarDark
143+
* @param non-empty-string $colorWarning
144+
* @param non-empty-string $colorWarningDark
145+
* @param non-empty-string $colorWarningBar
146+
* @param non-empty-string $colorWarningBarDark
147+
* @param non-empty-string $colorDanger
148+
* @param non-empty-string $colorDangerDark
149+
* @param non-empty-string $colorDangerBar
150+
* @param non-empty-string $colorDangerBarDark
151+
* @param non-empty-string $colorBreadcrumbs
152+
* @param non-empty-string $colorBreadcrumbsDark
153+
* @param ?non-empty-string $customCssFile
153154
*/
154155
public function __construct(?Directory $target, int $lowUpperBound, int $highLowerBound, string $colorSuccessLow, string $colorSuccessLowDark, string $colorSuccessMedium, string $colorSuccessMediumDark, string $colorSuccessHigh, string $colorSuccessHighDark, string $colorSuccessBar, string $colorSuccessBarDark, string $colorWarning, string $colorWarningDark, string $colorWarningBar, string $colorWarningBarDark, string $colorDanger, string $colorDangerDark, string $colorDangerBar, string $colorDangerBarDark, string $colorBreadcrumbs, string $colorBreadcrumbsDark, ?string $customCssFile)
155156
{

src/TextUI/Configuration/Xml/Loader.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,9 @@ private function phpunit(string $filename, DOMDocument $document, DOMXPath $xpat
10711071
);
10721072
}
10731073

1074+
/**
1075+
* @return non-empty-string
1076+
*/
10741077
private function parseColors(DOMDocument $document): string
10751078
{
10761079
$colors = Configuration::COLOR_DEFAULT;

src/TextUI/Configuration/Xml/PHPUnit.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@
171171
private int $shortenArraysForExportThreshold;
172172

173173
/**
174+
* @param ?non-empty-string $cacheDirectory
174175
* @param non-empty-string $colors
176+
* @param ?non-empty-string $bootstrap
175177
* @param array<non-empty-string, non-empty-string> $bootstrapForTestSuite
176178
* @param non-negative-int $stopOnDefect
177179
* @param non-negative-int $stopOnDeprecation
@@ -187,6 +189,7 @@
187189
* @param positive-int $timeoutForSmallTests
188190
* @param positive-int $timeoutForMediumTests
189191
* @param positive-int $timeoutForLargeTests
192+
* @param ?non-empty-string $defaultTestSuite
190193
* @param positive-int $numberOfTestsBeforeGarbageCollection
191194
* @param non-negative-int $shortenArraysForExportThreshold
192195
* @param positive-int $diffContext

0 commit comments

Comments
 (0)