From 951607432db6b4512c8b3a14b3931c6848ea88f9 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Thu, 31 Aug 2023 00:07:43 +0100 Subject: [PATCH] Remove $length from TokenList constructor Signed-off-by: Kamil Tekiela --- src/Statements/WithStatement.php | 2 +- src/TokensList.php | 19 +++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/Statements/WithStatement.php b/src/Statements/WithStatement.php index 7e0ea1e0e..c23c68d26 100644 --- a/src/Statements/WithStatement.php +++ b/src/Statements/WithStatement.php @@ -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)); } } diff --git a/src/TokensList.php b/src/TokensList.php index d669bda4c..d6b5a6af3 100644 --- a/src/TokensList.php +++ b/src/TokensList.php @@ -20,13 +20,6 @@ */ class TokensList implements ArrayAccess { - /** - * The array of tokens. - * - * @var Token[] - */ - public $tokens = []; - /** * The count of tokens. * @@ -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); } /**