@@ -20,23 +20,17 @@ class ExtrusiveBuffer extends LazyBuffer
20
20
*/
21
21
public const BUFFER_DEFAULT_SIZE = 100 ;
22
22
23
- /**
24
- * @var int<1, max>
25
- */
26
- private int $ size ;
27
-
28
23
/**
29
24
* @param iterable<TokenInterface> $stream
30
- * @param int<1, max> $size
31
25
*/
32
26
public function __construct (
33
27
iterable $ stream ,
34
- int $ size = self ::BUFFER_DEFAULT_SIZE
28
+ /**
29
+ * @var int<1, max>
30
+ */
31
+ private readonly int $ size = self ::BUFFER_DEFAULT_SIZE ,
35
32
) {
36
- $ this ->size = $ size ;
37
-
38
- /** @psalm-suppress RedundantCondition */
39
- assert ($ this ->size > 0 , 'Buffer size must be greater than 0, but ' . $ size . ' passed ' );
33
+ assert ($ this ->size > 0 , 'Buffer size must be greater than 0, but ' . $ this ->size . ' passed ' );
40
34
41
35
parent ::__construct ($ stream );
42
36
}
@@ -49,7 +43,7 @@ public function getBufferSize(): int
49
43
return $ this ->size ;
50
44
}
51
45
52
- public function seek ($ offset ): void
46
+ public function seek (int $ offset ): void
53
47
{
54
48
if ($ offset < \array_key_first ($ this ->buffer )) {
55
49
$ message = \sprintf (self ::ERROR_BUFFER_MEMORY_ALREADY_FREED , $ offset , $ this ->size );
@@ -63,7 +57,6 @@ public function seek($offset): void
63
57
public function next (): void
64
58
{
65
59
if ($ this ->nextValid () && $ this ->getBufferCurrentSize () > $ this ->size ) {
66
- /** @psalm-suppress PossiblyNullArrayOffset */
67
60
unset($ this ->buffer [\array_key_first ($ this ->buffer )]);
68
61
}
69
62
}
0 commit comments