diff --git a/src/Event/Emitter/Emitter.php b/src/Event/Emitter/Emitter.php index 9204ac98534..ec34561de12 100644 --- a/src/Event/Emitter/Emitter.php +++ b/src/Event/Emitter/Emitter.php @@ -145,9 +145,6 @@ public function testConsideredRisky(Code\Test $test, string $message): void; public function testMarkedAsIncomplete(Code\Test $test, Throwable $throwable): void; - /** - * @param non-empty-string $message - */ public function testSkipped(Code\Test $test, string $message): void; /** diff --git a/src/Framework/MockObject/Generator/HookedPropertyGenerator.php b/src/Framework/MockObject/Generator/HookedPropertyGenerator.php index 8da519e4990..2ae770d6037 100644 --- a/src/Framework/MockObject/Generator/HookedPropertyGenerator.php +++ b/src/Framework/MockObject/Generator/HookedPropertyGenerator.php @@ -22,7 +22,7 @@ final class HookedPropertyGenerator * @param class-string $className * @param list $properties * - * @return non-empty-string + * @return string */ public function generate(string $className, array $properties): string { diff --git a/src/Framework/TestBuilder.php b/src/Framework/TestBuilder.php index 5c3effc7a35..3444a435dbc 100644 --- a/src/Framework/TestBuilder.php +++ b/src/Framework/TestBuilder.php @@ -76,7 +76,7 @@ public function build(ReflectionClass $theClass, string $methodName, array $grou /** * @param non-empty-string $methodName * @param class-string $className - * @param array> $data + * @param array> $data * @param array{backupGlobals: ?bool, backupGlobalsExcludeList: list, backupStaticProperties: ?bool, backupStaticPropertiesExcludeList: array>} $backupSettings * @param list $groups */ diff --git a/src/Framework/TestCase.php b/src/Framework/TestCase.php index 43305f7c137..dffa70cb479 100644 --- a/src/Framework/TestCase.php +++ b/src/Framework/TestCase.php @@ -389,6 +389,8 @@ final public function size(): TestSize /** * @internal This method is not covered by the backward compatibility promise for PHPUnit + * + * @phpstan-assert-if-true non-empty-string $this->output() */ final public function hasUnexpectedOutput(): bool { diff --git a/src/Logging/EventLogger.php b/src/Logging/EventLogger.php index e7f029af914..ab3a30c2fed 100644 --- a/src/Logging/EventLogger.php +++ b/src/Logging/EventLogger.php @@ -41,7 +41,7 @@ public function trace(Event $event): void { $telemetryInfo = $this->telemetryInfo($event); $indentation = PHP_EOL . str_repeat(' ', strlen($telemetryInfo)); - $lines = preg_split('/\r\n|\r|\n/', $event->asString()); + $lines = preg_split('/\r\n|\r|\n/', $event->asString()) ?: []; $flags = FILE_APPEND; diff --git a/src/Logging/JUnit/JunitXmlLogger.php b/src/Logging/JUnit/JunitXmlLogger.php index 2eae77ac6de..262872a7ea1 100644 --- a/src/Logging/JUnit/JunitXmlLogger.php +++ b/src/Logging/JUnit/JunitXmlLogger.php @@ -102,7 +102,7 @@ public function __construct(Printer $printer, Facade $facade) public function flush(): void { - $this->printer->print($this->document->saveXML()); + $this->printer->print($this->document->saveXML() ?: ''); $this->printer->flush(); } @@ -269,7 +269,7 @@ private function handleFinish(Info $telemetryInfo, int $numberOfAssertionsPerfor ); $this->testSuiteTests[$this->testSuiteLevel]++; - $this->testSuiteTimes[$this->testSuiteLevel] += $time; + $this->testSuiteTimes[$this->testSuiteLevel] += (int) $time; $this->currentTestCase = null; $this->time = null; diff --git a/src/Metadata/Api/Requirements.php b/src/Metadata/Api/Requirements.php index b29c45f0b99..32ec095cd99 100644 --- a/src/Metadata/Api/Requirements.php +++ b/src/Metadata/Api/Requirements.php @@ -72,7 +72,7 @@ public function requirementsNotSatisfiedFor(string $className, string $methodNam if (!extension_loaded($metadata->extension()) || ($metadata->hasVersionRequirement() && - !$metadata->versionRequirement()->isSatisfiedBy(phpversion($metadata->extension())))) { + !$metadata->versionRequirement()->isSatisfiedBy(phpversion($metadata->extension()) ?: ''))) { $notSatisfied[] = sprintf( 'PHP extension %s%s is required.', $metadata->extension(), diff --git a/src/Metadata/CoversClassesThatExtendClass.php b/src/Metadata/CoversClassesThatExtendClass.php index abe524a4dd5..cd677debf2c 100644 --- a/src/Metadata/CoversClassesThatExtendClass.php +++ b/src/Metadata/CoversClassesThatExtendClass.php @@ -23,6 +23,7 @@ /** * @param 0|1 $level + * @param class-string $className */ protected function __construct(int $level, string $className) { diff --git a/src/Metadata/Version/Requirement.php b/src/Metadata/Version/Requirement.php index 391ccdec55f..73c64f55a53 100644 --- a/src/Metadata/Version/Requirement.php +++ b/src/Metadata/Version/Requirement.php @@ -23,7 +23,7 @@ */ abstract readonly class Requirement { - private const VERSION_COMPARISON = '/(?P[<>=!]{0,2})\s*(?P[\d\.-]+(dev|(RC|alpha|beta)[\d\.])?)[ \t]*\r?$/m'; + private const VERSION_COMPARISON = "/(?P!=|<|<=|<>|=|==|>|>=)\s*(?P[\d\.-]+(dev|(RC|alpha|beta)[\d\.])?)[ \t]*\r?$/m"; /** * @throws InvalidVersionOperatorException @@ -41,9 +41,7 @@ public static function from(string $versionRequirement): self if (preg_match(self::VERSION_COMPARISON, $versionRequirement, $matches)) { return new ComparisonRequirement( $matches['version'], - new VersionComparisonOperator( - !empty($matches['operator']) ? $matches['operator'] : '>=', - ), + new VersionComparisonOperator($matches['operator']), ); } }