From 5446227a694c9092a9d5cf94db8384c78d658bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Dorn?= Date: Fri, 5 Nov 2021 19:02:36 +0100 Subject: [PATCH] fix phpstan errors, add it to ci --- .github/workflows/formats.yml | 3 +++ composer.json | 1 + src/Contracts/Token.php | 1 - src/Runtime.php | 5 ++--- src/Tokens/Comma.php | 1 - 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/formats.yml b/.github/workflows/formats.yml index f9f1116..b3ce8a2 100644 --- a/.github/workflows/formats.yml +++ b/.github/workflows/formats.yml @@ -39,3 +39,6 @@ jobs: - name: Coding Style Checks run: composer test:lint + + - name: Type Checks + run: composer test:types diff --git a/composer.json b/composer.json index b943a39..fc9d808 100644 --- a/composer.json +++ b/composer.json @@ -39,6 +39,7 @@ "test:unit": "pest --colors=always", "test": [ "@test:lint", + "@test:types", "@test:unit" ] } diff --git a/src/Contracts/Token.php b/src/Contracts/Token.php index dbb6ea9..32007a2 100644 --- a/src/Contracts/Token.php +++ b/src/Contracts/Token.php @@ -3,7 +3,6 @@ namespace Felix\Sey\Contracts; use Felix\Sey\Runtime; -use Felix\Sey\Tokens\NullToken; abstract class Token { diff --git a/src/Runtime.php b/src/Runtime.php index c36d539..bbe66aa 100644 --- a/src/Runtime.php +++ b/src/Runtime.php @@ -36,9 +36,8 @@ public function __construct(string $expression, array $variables, array $functio public function run(): string { - while ($this->tokens->current() !== null) { - $this->tokens->current()->consume($this); - $this->tokens->next(); + foreach ($this->tokens as $token) { + $token->consume($this); } // no more tokens to read but some operators are still in the stack diff --git a/src/Tokens/Comma.php b/src/Tokens/Comma.php index f66bb78..cb399c0 100644 --- a/src/Tokens/Comma.php +++ b/src/Tokens/Comma.php @@ -10,7 +10,6 @@ class Comma extends Token { public function __construct(public string $value = ',') { - } public function consume(Runtime $runtime): void