Skip to content

Commit d6a7da8

Browse files
committed
Cast runtime to int
1 parent 64aed61 commit d6a7da8

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/TestCase.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,40 +28,40 @@ public function createCallback(int $count): callable {
2828
/**
2929
* Asserts that the given callback takes no more than $maxRunTime to run.
3030
*
31-
* @param callable $callback
32-
* @param int $maxRunTime
33-
* @param mixed[]|null $args Function arguments.
31+
* @param callable $callback
32+
* @param int $maxRunTime Max runtime allowed for the test to pass.
33+
* @param mixed[] $args Function arguments.
3434
*/
35-
public function assertRunTimeLessThan(callable $callback, int $maxRunTime, array $args = null) {
35+
public function assertRunTimeLessThan(callable $callback, int $maxRunTime, array $args = []) {
3636
$this->assertRunTimeBetween($callback, 0, $maxRunTime, $args);
3737
}
3838

3939
/**
4040
* Asserts that the given callback takes more than $minRunTime to run.
4141
*
42-
* @param callable $callback
43-
* @param int $minRunTime
44-
* @param mixed[]|null $args Function arguments.
42+
* @param callable $callback
43+
* @param int $minRunTime Minimum runtime allowed for the test to pass.
44+
* @param mixed[] $args Function arguments.
4545
*/
46-
public function assertRunTimeGreaterThan(callable $callback, int $minRunTime, array $args = null) {
46+
public function assertRunTimeGreaterThan(callable $callback, int $minRunTime, array $args = []) {
4747
$this->assertRunTimeBetween($callback, $minRunTime, 0, $args);
4848
}
4949

5050
/**
5151
* Asserts that the given callback takes between $minRunTime and $maxRunTime to execute.
5252
* Rounds to the nearest 100 ms.
5353
*
54-
* @param callable $callback
55-
* @param int $minRunTime
56-
* @param int $maxRunTime
57-
* @param mixed[]|null $args Function arguments.
54+
* @param callable $callback
55+
* @param int $minRunTime Minimum runtime allowed for the test to pass.
56+
* @param int $maxRunTime Max runtime allowed for the test to pass.
57+
* @param mixed[] $args Function arguments.
5858
*/
59-
public function assertRunTimeBetween(callable $callback, int $minRunTime, int $maxRunTime, array $args = null) {
59+
public function assertRunTimeBetween(callable $callback, int $minRunTime, int $maxRunTime, array $args = []) {
6060
$start = \microtime(true);
6161

62-
\call_user_func_array($callback, $args ?: []);
62+
$callback(...$args);
6363

64-
$runTime = \round(\microtime(true) - $start, self::RUNTIME_PRECISION) * 1000;
64+
$runTime = (int) (\round(\microtime(true) - $start, self::RUNTIME_PRECISION) * 1000);
6565

6666
if (0 < $maxRunTime) {
6767
$this->assertLessThanOrEqual(

0 commit comments

Comments
 (0)