Skip to content

Commit

Permalink
Merge branch '11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 8, 2024
2 parents 3fa92eb + c157a06 commit 1adf30d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions .psalm/baseline.xml
Expand Up @@ -68,6 +68,7 @@
<file src="src/Event/Value/Telemetry/HRTime.php">
<ImpureMethodCall>
<code><![CDATA[fromSecondsAndNanoseconds]]></code>
<code><![CDATA[fromSecondsAndNanoseconds]]></code>
</ImpureMethodCall>
</file>
<file src="src/Event/Value/Telemetry/MemoryUsage.php">
Expand Down
5 changes: 1 addition & 4 deletions src/Event/Value/Telemetry/HRTime.php
Expand Up @@ -56,9 +56,6 @@ public function nanoseconds(): int
return $this->nanoseconds;
}

/**
* @throws InvalidArgumentException
*/
public function duration(self $start): Duration
{
$seconds = $this->seconds - $start->seconds();
Expand All @@ -71,7 +68,7 @@ public function duration(self $start): Duration
}

if ($seconds < 0) {
throw new InvalidArgumentException('Start needs to be smaller.');
return Duration::fromSecondsAndNanoseconds(0, 0);

Check failure on line 71 in src/Event/Value/Telemetry/HRTime.php

View workflow job for this annotation

GitHub Actions / Type Checker

MissingThrowsDocblock

src/Event/Value/Telemetry/HRTime.php:71:20: MissingThrowsDocblock: PHPUnit\Event\InvalidArgumentException is thrown but not caught - please either catch or add a @throws annotation (see https://psalm.dev/169)
}

return Duration::fromSecondsAndNanoseconds(

Check failure on line 74 in src/Event/Value/Telemetry/HRTime.php

View workflow job for this annotation

GitHub Actions / Type Checker

MissingThrowsDocblock

src/Event/Value/Telemetry/HRTime.php:74:16: MissingThrowsDocblock: PHPUnit\Event\InvalidArgumentException is thrown but not caught - please either catch or add a @throws annotation (see https://psalm.dev/169)
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/Event/Value/Telemetry/HRTimeTest.php
Expand Up @@ -124,7 +124,7 @@ public function testFromSecondsAndNanosecondsReturnsHRTime(): void
}

#[DataProvider('provideStartGreaterThanEnd')]
public function testDurationRejectsStartGreaterThanEnd(int $startSeconds, int $startNanoseconds, int $endSeconds, int $endNanoseconds): void
public function testDurationIgnoresStartGreaterThanEnd(int $startSeconds, int $startNanoseconds, int $endSeconds, int $endNanoseconds): void
{
$start = HRTime::fromSecondsAndNanoseconds(
$startSeconds,
Expand All @@ -136,10 +136,10 @@ public function testDurationRejectsStartGreaterThanEnd(int $startSeconds, int $s
$endNanoseconds,
);

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Start needs to be smaller.');
$duration = $end->duration($start);

$end->duration($start);
$this->assertSame(0, $duration->seconds());
$this->assertSame(0, $duration->nanoseconds());
}

#[DataProvider('provideStartEndAndDuration')]
Expand Down

0 comments on commit 1adf30d

Please sign in to comment.