@@ -9,7 +9,7 @@ class LineReaderTest extends TestCase
9
9
private static $ maxLines ;
10
10
private static $ testFile ;
11
11
12
- public static function setUpBeforeClass ()
12
+ public static function setUpBeforeClass (): void
13
13
{
14
14
self ::$ maxLines = (int )getenv ('TEST_MAX_LINES ' ) ?: 10000 ;
15
15
self ::$ testFile = __DIR__ .'/testfile_ ' .self ::$ maxLines .'.txt ' ;
@@ -25,29 +25,23 @@ public static function setUpBeforeClass()
25
25
fclose ($ fh );
26
26
}
27
27
28
- public function testCanNotBeInstantiated ()
29
- {
30
- $ this ->expectException (\Error::class);
31
- new LineReader ();
32
- }
33
-
34
- public function testReadLinesThrowsException ()
28
+ public function testReadLinesThrowsException (): void
35
29
{
36
30
$ this ->expectException (\InvalidArgumentException::class);
37
31
$ this ->expectExceptionMessage ('Cannot open file for reading: /tmp/invalid-file.txt ' );
38
32
39
33
LineReader::readLines ('/tmp/invalid-file.txt ' );
40
34
}
41
35
42
- public function testReadLinesBackwardsThrowsException ()
36
+ public function testReadLinesBackwardsThrowsException (): void
43
37
{
44
38
$ this ->expectException (\InvalidArgumentException::class);
45
39
$ this ->expectExceptionMessage ('Cannot open file for reading: /tmp/invalid-file.txt ' );
46
40
47
41
LineReader::readLinesBackwards ('/tmp/invalid-file.txt ' );
48
42
}
49
43
50
- public function testReadsAllLines ()
44
+ public function testReadsAllLines (): void
51
45
{
52
46
$ result = LineReader::readLines (self ::$ testFile );
53
47
@@ -59,7 +53,7 @@ public function testReadsAllLines()
59
53
$ this ->assertLines ($ result , $ firstLine , $ lastLine , $ lineCount );
60
54
}
61
55
62
- public function testReadsLinesByStartline ()
56
+ public function testReadsLinesByStartline (): void
63
57
{
64
58
$ lineGenerator = LineReader::readLines (self ::$ testFile );
65
59
$ lineGenerator = new \LimitIterator ($ lineGenerator , 50 );
@@ -70,7 +64,7 @@ public function testReadsLinesByStartline()
70
64
$ this ->assertLines ($ lineGenerator , $ firstLine , $ lastLine , $ lineCount );
71
65
}
72
66
73
- public function testReadsLinesByLimit ()
67
+ public function testReadsLinesByLimit (): void
74
68
{
75
69
$ lineGenerator = LineReader::readLines (self ::$ testFile );
76
70
$ lineGenerator = new \LimitIterator ($ lineGenerator , 50 , 100 );
@@ -81,7 +75,7 @@ public function testReadsLinesByLimit()
81
75
$ this ->assertLines ($ lineGenerator , $ firstLine , $ lastLine , $ lineCount );
82
76
}
83
77
84
- public function testReadsLinesBackwards ()
78
+ public function testReadsLinesBackwards (): void
85
79
{
86
80
$ lineGenerator = LineReader::readLinesBackwards (self ::$ testFile );
87
81
@@ -91,7 +85,7 @@ public function testReadsLinesBackwards()
91
85
$ this ->assertLines ($ lineGenerator , $ firstLine , $ lastLine , $ lineCount );
92
86
}
93
87
94
- public function testReadsLinesBackwardsWithOffsetAndLimit ()
88
+ public function testReadsLinesBackwardsWithOffsetAndLimit (): void
95
89
{
96
90
$ lineGenerator = LineReader::readLinesBackwards (self ::$ testFile );
97
91
$ lineGenerator = new \LimitIterator ($ lineGenerator , 10 , 50 );
@@ -102,7 +96,7 @@ public function testReadsLinesBackwardsWithOffsetAndLimit()
102
96
$ this ->assertLines ($ lineGenerator , $ firstLine , $ lastLine , $ lineCount );
103
97
}
104
98
105
- public function testEmptyFile ()
99
+ public function testEmptyFile (): void
106
100
{
107
101
$ testFile = __DIR__ .'/testfile_empty.txt ' ;
108
102
$ content = '' ;
@@ -115,7 +109,7 @@ public function testEmptyFile()
115
109
self ::assertSame ([], iterator_to_array ($ lineGenerator ));
116
110
}
117
111
118
- public function testFileWithLeadingAndTrailingNewlines ()
112
+ public function testFileWithLeadingAndTrailingNewlines (): void
119
113
{
120
114
$ testFile = __DIR__ .'/testfile_space.txt ' ;
121
115
@@ -166,11 +160,8 @@ public function testFileWithLeadingAndTrailingNewlines()
166
160
* Runs the generator and asserts on first, last and the total line count
167
161
*
168
162
* @param \Traversable $generator
169
- * @param int $firstLine
170
- * @param int $lastLine
171
- * @param int $lineCount
172
163
*/
173
- private function assertLines (\Traversable $ generator , $ firstLine , $ lastLine , $ lineCount )
164
+ private function assertLines (\Traversable $ generator , string $ firstLine , int $ lastLine , int $ lineCount ): void
174
165
{
175
166
$ count = 0 ;
176
167
$ line = '' ;
0 commit comments