Skip to content

Commit 8b37c13

Browse files
committed
Remove $length from TokenList constructor
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent d4581b8 commit 8b37c13

2 files changed

Lines changed: 4 additions & 17 deletions

File tree

src/Statements/WithStatement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,6 @@ private function getSubTokenList(TokensList $list): ParserException|TokensList
330330

331331
$length = $list->idx - $idx;
332332

333-
return new TokensList(array_slice($list->tokens, $idx, $length), $length);
333+
return new TokensList(array_slice($list->tokens, $idx, $length));
334334
}
335335
}

src/TokensList.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@
2020
*/
2121
class TokensList implements ArrayAccess
2222
{
23-
/**
24-
* The array of tokens.
25-
*
26-
* @var Token[]
27-
*/
28-
public $tokens = [];
29-
3023
/**
3124
* The count of tokens.
3225
*
@@ -42,17 +35,11 @@ class TokensList implements ArrayAccess
4235
public $idx = 0;
4336

4437
/**
45-
* @param Token[] $tokens the initial array of tokens
46-
* @param int $count the count of tokens in the initial array
38+
* @param Token[] $tokens The array of tokens.
4739
*/
48-
public function __construct(array $tokens = [], $count = -1)
40+
public function __construct(public array $tokens = [])
4941
{
50-
if ($tokens === []) {
51-
return;
52-
}
53-
54-
$this->tokens = $tokens;
55-
$this->count = $count === -1 ? count($tokens) : $count;
42+
$this->count = count($tokens);
5643
}
5744

5845
/**

0 commit comments

Comments
 (0)