Skip to content

Commit 24c86ab

Browse files
committed
Cleanup
1 parent 89b6545 commit 24c86ab

File tree

7 files changed

+23
-32
lines changed

7 files changed

+23
-32
lines changed

src/Compiler/StandardCompiler.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class StandardCompiler implements CompilerInterface
2828
private int $openParenthesis = 0;
2929
private int $closedParenthesis = 0;
3030

31+
/** @throws ParserException */
3132
public function getCompiledRule(): string
3233
{
3334
if ($this->isIncompleteCondition()) {

src/Grammar/Grammar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
abstract class Grammar
1111
{
12-
/** @return array<int, array<int, mixed>> */
12+
/** @return array<int, <mixed>> */
1313
abstract public function getDefinition(): array;
1414

1515
/** @return array<string, string> */

src/Grammar/JavaScript/Methods/Replace.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function call(?BaseToken ...$parameters): BaseToken
4545

4646
private function doRegexReplace(string $search, string $replace): string
4747
{
48-
list($expression, $modifiers) = $this->splitRegex($search);
48+
[$expression, $modifiers] = $this->splitRegex($search);
4949

5050
$modifiers = str_replace('g', '', $modifiers, $count);
5151
$limit = $count > 0 ? -1 : 1;

src/Highlighter/Highlighter.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ final class Highlighter
1515
{
1616
/** @var string[] */
1717
private array $styles = [
18-
TokenType::COMMENT => 'color: #948a8a; font-style: italic;',
19-
TokenType::LOGICAL => 'color: #c72d2d;',
20-
TokenType::OPERATOR => 'color: #000;',
21-
TokenType::PARENTHESIS => 'color: #000;',
22-
TokenType::SPACE => '',
23-
TokenType::UNKNOWN => '',
24-
TokenType::VALUE => 'color: #e36700; font-style: italic;',
25-
TokenType::VARIABLE => 'color: #007694; font-weight: 900;',
26-
TokenType::METHOD => 'color: #000',
18+
TokenType::COMMENT => 'color: #948a8a; font-style: italic;',
19+
TokenType::LOGICAL => 'color: #c72d2d;',
20+
TokenType::OPERATOR => 'color: #000;',
21+
TokenType::PARENTHESIS => 'color: #000;',
22+
TokenType::SPACE => '',
23+
TokenType::UNKNOWN => '',
24+
TokenType::VALUE => 'color: #e36700; font-style: italic;',
25+
TokenType::VARIABLE => 'color: #007694; font-weight: 900;',
26+
TokenType::METHOD => 'color: #000',
2727
TokenType::SQUARE_BRACKET => '',
28-
TokenType::COMMA => '',
29-
TokenType::FUNCTION => '',
30-
TokenType::INT_VALUE => '',
28+
TokenType::COMMA => '',
29+
TokenType::FUNCTION => '',
30+
TokenType::INT_VALUE => '',
3131
];
3232

3333
public function __construct(private TokenizerInterface $tokenizer)

src/TokenStream/AST.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,16 @@
1919

2020
class AST
2121
{
22-
private TokenizerInterface $tokenizer;
23-
private TokenFactory $tokenFactory;
24-
private TokenStreamFactory $tokenStreamFactory;
25-
private CallableUserMethodFactoryInterface $userMethodFactory;
2622
private array $functions = [];
2723
private array $methods = [];
2824
private array $variables = [];
2925

3026
public function __construct(
31-
TokenizerInterface $tokenizer,
32-
TokenFactory $tokenFactory,
33-
TokenStreamFactory $tokenStreamFactory,
34-
CallableUserMethodFactoryInterface $userMethodFactory
27+
private TokenizerInterface $tokenizer,
28+
private TokenFactory $tokenFactory,
29+
private TokenStreamFactory $tokenStreamFactory,
30+
private CallableUserMethodFactoryInterface $userMethodFactory
3531
) {
36-
$this->tokenizer = $tokenizer;
37-
$this->tokenFactory = $tokenFactory;
38-
$this->tokenStreamFactory = $tokenStreamFactory;
39-
$this->userMethodFactory = $userMethodFactory;
4032
}
4133

4234
public function getStream(string $rule): TokenStream

src/TokenStream/CallableUserMethod.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,17 @@ private function getCallable(BaseToken $token, string $methodName): Closure
6565
private function findCallableMethod(object $object, string $methodName): callable
6666
{
6767
$this->assertNonMagicMethod($methodName);
68-
69-
$callableMethod = [$object, $methodName];
7068
$index = 0;
7169

7270
do {
7371
if (!isset($this->methodPrefixes[$index])) {
7472
throw new Exception\UndefinedMethodException();
7573
}
7674

77-
$callableMethod[1] = $this->methodPrefixes[$index++] . $methodName;
78-
} while (!is_callable($callableMethod));
75+
$callableMethod = $this->methodPrefixes[$index++] . $methodName;
76+
} while (!is_callable([$object, $callableMethod]));
7977

80-
return $callableMethod;
78+
return [$object, $callableMethod];
8179
}
8280

8381
private function getTokenValues(array $params): array

src/TokenStream/Token/TokenFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88
namespace nicoSWD\Rule\TokenStream\Token;
99

10-
use InvalidArgumentException;
1110
use nicoSWD\Rule\Parser\Exception\ParserException;
1211
use nicoSWD\Rule\TokenStream\TokenCollection;
1312

@@ -28,6 +27,7 @@ public function createFromPHPType(mixed $value): BaseToken
2827
};
2928
}
3029

30+
/** @throws ParserException */
3131
public function createFromTokenName(string $tokenName): string
3232
{
3333
return match ($tokenName) {

0 commit comments

Comments
 (0)