Skip to content

Commit 8550227

Browse files
✨ Multiples tokenizer improvements to handle tag, interpolation, unary, ...
1 parent 306a626 commit 8550227

File tree

8 files changed

+288
-85
lines changed

8 files changed

+288
-85
lines changed

TwigCS/src/Ruleset/Generic/OperatorSpacingSniff.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ private function isUnary(int $tokenPosition, array $tokens): bool
8181
return true;
8282
}
8383

84+
if ($this->isTokenMatching($previousToken, Token::BLOCK_TAG_TYPE)) {
85+
// {% if -2 ... %}
86+
return true;
87+
}
88+
8489
return false;
8590
}
8691
}

TwigCS/src/Token/Token.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ class Token
2525
public const INTERPOLATION_END_TYPE = 11;
2626
public const ARROW_TYPE = 12;
2727
// New constants
28-
public const WHITESPACE_TYPE = 13;
29-
public const TAB_TYPE = 14;
30-
public const EOL_TYPE = 15;
31-
public const COMMENT_START_TYPE = 16;
32-
public const COMMENT_TEXT_TYPE = 17;
33-
public const COMMENT_WHITESPACE_TYPE = 18;
34-
public const COMMENT_TAB_TYPE = 19;
35-
public const COMMENT_EOL_TYPE = 20;
36-
public const COMMENT_END_TYPE = 21;
28+
public const DQ_STRING_START_TYPE = 13;
29+
public const DQ_STRING_END_TYPE = 14;
30+
public const BLOCK_TAG_TYPE = 15;
31+
public const WHITESPACE_TYPE = 16;
32+
public const TAB_TYPE = 17;
33+
public const EOL_TYPE = 18;
34+
public const COMMENT_START_TYPE = 19;
35+
public const COMMENT_TEXT_TYPE = 20;
36+
public const COMMENT_WHITESPACE_TYPE = 21;
37+
public const COMMENT_TAB_TYPE = 22;
38+
public const COMMENT_EOL_TYPE = 23;
39+
public const COMMENT_END_TYPE = 24;
3740

3841
public const EMPTY_TOKENS = [
3942
self::WHITESPACE_TYPE => self::WHITESPACE_TYPE,

0 commit comments

Comments
 (0)