Skip to content

Commit

Permalink
Remove $length from TokenList constructor
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <[email protected]>
  • Loading branch information
kamil-tekiela committed Aug 30, 2023
1 parent 03b0bca commit 9516074
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Statements/WithStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,6 @@ private function getSubTokenList(TokensList $list): ParserException|TokensList

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

return new TokensList(array_slice($list->tokens, $idx, $length), $length);
return new TokensList(array_slice($list->tokens, $idx, $length));
}
}
19 changes: 3 additions & 16 deletions src/TokensList.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
*/
class TokensList implements ArrayAccess
{
/**
* The array of tokens.
*
* @var Token[]
*/
public $tokens = [];

/**
* The count of tokens.
*
Expand All @@ -42,17 +35,11 @@ class TokensList implements ArrayAccess
public $idx = 0;

/**
* @param Token[] $tokens the initial array of tokens
* @param int $count the count of tokens in the initial array
* @param Token[] $tokens The array of tokens.
*/
public function __construct(array $tokens = [], $count = -1)
public function __construct(public array $tokens = [])
{
if ($tokens === []) {
return;
}

$this->tokens = $tokens;
$this->count = $count === -1 ? count($tokens) : $count;
$this->count = count($tokens);
}

/**
Expand Down

0 comments on commit 9516074

Please sign in to comment.