File tree Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Expand file tree Collapse file tree 2 files changed +16
-13
lines changed Original file line number Diff line number Diff line change @@ -113,17 +113,17 @@ class Token
113
113
* All tokens types
114
114
*/
115
115
public const TYPE_ALL = [
116
- Token ::TYPE_NONE ,
117
- Token ::TYPE_KEYWORD ,
118
- Token ::TYPE_OPERATOR ,
119
- Token ::TYPE_WHITESPACE ,
120
- Token ::TYPE_COMMENT ,
121
- Token ::TYPE_BOOL ,
122
- Token ::TYPE_NUMBER ,
123
- Token ::TYPE_STRING ,
124
- Token ::TYPE_SYMBOL ,
125
- Token ::TYPE_DELIMITER ,
126
- Token ::TYPE_LABEL ,
116
+ self ::TYPE_NONE ,
117
+ self ::TYPE_KEYWORD ,
118
+ self ::TYPE_OPERATOR ,
119
+ self ::TYPE_WHITESPACE ,
120
+ self ::TYPE_COMMENT ,
121
+ self ::TYPE_BOOL ,
122
+ self ::TYPE_NUMBER ,
123
+ self ::TYPE_STRING ,
124
+ self ::TYPE_SYMBOL ,
125
+ self ::TYPE_DELIMITER ,
126
+ self ::TYPE_LABEL ,
127
127
];
128
128
129
129
// Flags that describe the tokens in more detail.
Original file line number Diff line number Diff line change 7
7
use ArrayAccess ;
8
8
9
9
use function count ;
10
+ use function in_array ;
10
11
use function is_array ;
11
12
use function is_string ;
12
13
@@ -140,9 +141,10 @@ public function getPrevious(): ?Token
140
141
*/
141
142
public function getPreviousOfType ($ type )
142
143
{
143
- if (!is_array ($ type )) {
144
+ if (! is_array ($ type )) {
144
145
$ type = [$ type ];
145
146
}
147
+
146
148
for (; $ this ->idx >= 0 ; --$ this ->idx ) {
147
149
if (in_array ($ this ->tokens [$ this ->idx ]->type , $ type , true )) {
148
150
return $ this ->tokens [$ this ->idx --];
@@ -161,9 +163,10 @@ public function getPreviousOfType($type)
161
163
*/
162
164
public function getNextOfType ($ type )
163
165
{
164
- if (!is_array ($ type )) {
166
+ if (! is_array ($ type )) {
165
167
$ type = [$ type ];
166
168
}
169
+
167
170
for (; $ this ->idx < $ this ->count ; ++$ this ->idx ) {
168
171
if (in_array ($ this ->tokens [$ this ->idx ]->type , $ type , true )) {
169
172
return $ this ->tokens [$ this ->idx ++];
You can’t perform that action at this time.
0 commit comments