Skip to content

Commit 0045422

Browse files
committed
Allow underscore only variables that are longer than 4 characters.
1 parent 91d52ec commit 0045422

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
## [1.3.1] - 2019-05-01
99
### Fixed
1010
- Fixed `config.m4` to correct install headers
11+
- Fixed underscore only identifiers to be more than 4 characters
1112

1213
## [1.3.0] - 2019-04-27
1314
### Added

parser/scanner.re

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,12 +652,7 @@ int xx_get_token(xx_scanner_state *s, xx_scanner_token *token) {
652652
}
653653
}
654654

655-
/* This is hack */
656-
if ((token->len == 1 && (!memcmp(token->value, "_", sizeof("_")-1)))
657-
|| (token->len == 2 && (!memcmp(token->value, "__", sizeof("__")-1)))
658-
|| (token->len == 3 && (!memcmp(token->value, "___", sizeof("___")-1)))
659-
|| (token->len == 4 && (!memcmp(token->value, "____", sizeof("____")-1)))
660-
) {
655+
if (strspn(token->value, "_") == token->len) {
661656
token->opcode = XX_T_IDENTIFIER;
662657
return 0;
663658
}

tests/base/variables.phpt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class Foo\Bar\Bas
2121
public \$_abc;
2222
public \_cde;
2323
public __edc;
24+
public ______;
2425
}
2526
ZEP;
2627

@@ -56,7 +57,7 @@ array(2) {
5657
["definition"]=>
5758
array(4) {
5859
["properties"]=>
59-
array(9) {
60+
array(10) {
6061
[0]=>
6162
array(6) {
6263
["visibility"]=>
@@ -217,6 +218,24 @@ array(2) {
217218
["line"]=>
218219
int(16)
219220
["char"]=>
221+
int(10)
222+
}
223+
[9]=>
224+
array(6) {
225+
["visibility"]=>
226+
array(1) {
227+
[0]=>
228+
string(6) "public"
229+
}
230+
["type"]=>
231+
string(8) "property"
232+
["name"]=>
233+
string(6) "______"
234+
["file"]=>
235+
string(11) "(eval code)"
236+
["line"]=>
237+
int(17)
238+
["char"]=>
220239
int(1)
221240
}
222241
}

0 commit comments

Comments
 (0)