Skip to content

Commit ebb1596

Browse files
committed
Enforce strict_types
1 parent 1050be8 commit ebb1596

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/JohnKary/PHPUnit/Listener/SpeedTrapListener.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace JohnKary\PHPUnit\Listener;
45

@@ -187,7 +188,7 @@ public function endTestSuite(TestSuite $suite)
187188
* @param int $slowThreshold Test execution time at which a test should be considered slow (milliseconds)
188189
* @return bool
189190
*/
190-
protected function isSlow($time, $slowThreshold)
191+
protected function isSlow(int $time, int $slowThreshold) : bool
191192
{
192193
return $time >= $slowThreshold;
193194
}
@@ -196,9 +197,9 @@ protected function isSlow($time, $slowThreshold)
196197
* Stores a test as slow.
197198
*
198199
* @param TestCase $test
199-
* @param int $time Test execution time in milliseconds
200+
* @param int $time Test execution time in milliseconds
200201
*/
201-
protected function addSlowTest(TestCase $test, $time)
202+
protected function addSlowTest(TestCase $test, int $time)
202203
{
203204
$label = $this->makeLabel($test);
204205

@@ -210,7 +211,7 @@ protected function addSlowTest(TestCase $test, $time)
210211
*
211212
* @return bool
212213
*/
213-
protected function hasSlowTests()
214+
protected function hasSlowTests() : bool
214215
{
215216
return !empty($this->slow);
216217
}
@@ -221,7 +222,7 @@ protected function hasSlowTests()
221222
* @param float $time
222223
* @return int
223224
*/
224-
protected function toMilliseconds($time)
225+
protected function toMilliseconds(float $time) : int
225226
{
226227
return (int) round($time * 1000);
227228
}
@@ -232,7 +233,7 @@ protected function toMilliseconds($time)
232233
* @param TestCase $test
233234
* @return string
234235
*/
235-
protected function makeLabel(TestCase $test)
236+
protected function makeLabel(TestCase $test) : string
236237
{
237238
return sprintf('%s:%s', get_class($test), $test->getName());
238239
}
@@ -242,7 +243,7 @@ protected function makeLabel(TestCase $test)
242243
*
243244
* @return int
244245
*/
245-
protected function getReportLength()
246+
protected function getReportLength() : int
246247
{
247248
return min(count($this->slow), $this->reportLength);
248249
}
@@ -253,7 +254,7 @@ protected function getReportLength()
253254
*
254255
* @return int
255256
*/
256-
protected function getHiddenCount()
257+
protected function getHiddenCount() : int
257258
{
258259
$total = count($this->slow);
259260
$showing = $this->getReportLength();
@@ -327,10 +328,10 @@ protected function loadOptions(array $options)
327328
* @param TestCase $test
328329
* @return int
329330
*/
330-
protected function getSlowThreshold(TestCase $test)
331+
protected function getSlowThreshold(TestCase $test) : int
331332
{
332333
$ann = $test->getAnnotations();
333334

334-
return isset($ann['method']['slowThreshold'][0]) ? $ann['method']['slowThreshold'][0] : $this->slowThreshold;
335+
return isset($ann['method']['slowThreshold'][0]) ? (int) $ann['method']['slowThreshold'][0] : $this->slowThreshold;
335336
}
336337
}

src/JohnKary/PHPUnit/Listener/Tests/ExceptionalTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace JohnKary\PHPUnit\Listener\Tests;
45

src/JohnKary/PHPUnit/Listener/Tests/SomeSlowTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
declare(strict_types=1);
23

34
namespace JohnKary\PHPUnit\Listener\Tests;
45

@@ -35,7 +36,7 @@ public function testLongEndToEndTest()
3536
/**
3637
* @dataProvider provideTime
3738
*/
38-
public function testWithDataProvider($time)
39+
public function testWithDataProvider(int $time)
3940
{
4041
$this->extendTime($time);
4142

@@ -79,7 +80,7 @@ public function testCanSetHigherSlowThreshold()
7980
/**
8081
* @param int $ms Number of additional microseconds to execute code
8182
*/
82-
private function extendTime($ms)
83+
private function extendTime(int $ms)
8384
{
8485
usleep($ms * 1000);
8586
}

0 commit comments

Comments
 (0)