@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | |
16 | 16 | class Lexer extends AbstractLexer |
17 | 17 | { |
18 | - const STATE_INITIAL = 0; |
|
18 | + const STATE_INITIAL = 0; |
|
19 | 19 | const STATE_INSTRING = 1; |
20 | 20 | const STATE_INHEREDOC = 2; |
21 | 21 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | self::STATE_INITIAL => [ |
46 | 46 | self::REGEX_SPACE => false, |
47 | 47 | self::REGEX_COMMENT => false, |
48 | - self::REGEX_COMMENT_ML => function () { |
|
48 | + self::REGEX_COMMENT_ML => function() { |
|
49 | 49 | $pos = strpos($this->content, '*/', $this->count); |
50 | 50 | if (false === $pos) { |
51 | 51 | $this->line += substr_count(substr($this->content, $this->count), "\n"); |
@@ -54,29 +54,29 @@ discard block |
||
54 | 54 | $this->line += substr_count(substr($this->content, $this->count, $pos - $this->count + 2), "\n"); |
55 | 55 | $this->count = $pos + 2; |
56 | 56 | }, |
57 | - self::REGEX_DQUOTE => function () { |
|
57 | + self::REGEX_DQUOTE => function() { |
|
58 | 58 | $this->begin(self::STATE_INSTRING); |
59 | 59 | $this->textBuffer = ''; |
60 | 60 | }, |
61 | - self::REGEX_BOOL => function (&$yylval) { |
|
61 | + self::REGEX_BOOL => function(&$yylval) { |
|
62 | 62 | $yylval = TypeCaster::toBool($yylval); |
63 | 63 | |
64 | 64 | return Token::T_BOOL; |
65 | 65 | }, |
66 | - self::REGEX_NULL => function (&$yylval) { |
|
66 | + self::REGEX_NULL => function(&$yylval) { |
|
67 | 67 | $yylval = null; |
68 | 68 | |
69 | 69 | return Token::T_NULL; |
70 | 70 | }, |
71 | - self::REGEX_NUM => function (&$yylval) { |
|
71 | + self::REGEX_NUM => function(&$yylval) { |
|
72 | 72 | $yylval = TypeCaster::toNum($yylval); |
73 | 73 | |
74 | 74 | return Token::T_NUM; |
75 | 75 | }, |
76 | - self::REGEX_NAME => function () { |
|
76 | + self::REGEX_NAME => function() { |
|
77 | 77 | return Token::T_NAME; |
78 | 78 | }, |
79 | - self::REGEX_HEREDOC => function (&$yylval) { |
|
79 | + self::REGEX_HEREDOC => function(&$yylval) { |
|
80 | 80 | $needle = "\n" . $yylval; |
81 | 81 | $pos = strpos($this->content, $needle, $this->count); |
82 | 82 | if (false === $pos) { |
@@ -90,21 +90,21 @@ discard block |
||
90 | 90 | |
91 | 91 | return Token::T_END_STR; |
92 | 92 | }, |
93 | - self::REGEX_TOKEN => function ($yylval) { |
|
93 | + self::REGEX_TOKEN => function($yylval) { |
|
94 | 94 | return $yylval; |
95 | 95 | }, |
96 | - self::REGEX_VAR => function () { |
|
96 | + self::REGEX_VAR => function() { |
|
97 | 97 | return Token::T_VAR; |
98 | 98 | }, |
99 | - self::REGEX_ANY => function ($yylval) { |
|
99 | + self::REGEX_ANY => function($yylval) { |
|
100 | 100 | $this->error('Unexpected char \'' . $yylval . '\''); |
101 | 101 | }, |
102 | - self::EOF => function () { |
|
102 | + self::EOF => function() { |
|
103 | 103 | return Token::T_EOF; |
104 | 104 | }, |
105 | 105 | ], |
106 | 106 | self::STATE_INSTRING => [ |
107 | - '[^\\\"$]+' => function (&$yylval) { |
|
107 | + '[^\\\"$]+' => function(&$yylval) { |
|
108 | 108 | $this->textBuffer .= $yylval; |
109 | 109 | if ('$' == substr($this->content, $this->count, 1)) { |
110 | 110 | $yylval = $this->textBuffer; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | return Token::T_STRING; |
114 | 114 | } |
115 | 115 | }, |
116 | - '?:\\\(.)' => function ($yylval) { |
|
116 | + '?:\\\(.)' => function($yylval) { |
|
117 | 117 | switch ($yylval) { |
118 | 118 | case 'n': |
119 | 119 | $this->textBuffer .= "\n"; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | break; |
147 | 147 | } |
148 | 148 | }, |
149 | - '\$' => function (&$yylval) { |
|
149 | + '\$' => function(&$yylval) { |
|
150 | 150 | if (preg_match('/^{([A-Za-z0-9_]+)}/', substr($this->content, $this->count), $matches)) { |
151 | 151 | $this->count += strlen($matches[0]); |
152 | 152 | $yylval = $matches[1]; |
@@ -156,13 +156,13 @@ discard block |
||
156 | 156 | |
157 | 157 | $this->textBuffer .= $yylval; |
158 | 158 | }, |
159 | - self::REGEX_DQUOTE => function (&$yylval) { |
|
159 | + self::REGEX_DQUOTE => function(&$yylval) { |
|
160 | 160 | $yylval = $this->textBuffer; |
161 | 161 | $this->begin(self::STATE_INITIAL); |
162 | 162 | |
163 | 163 | return Token::T_END_STR; |
164 | 164 | }, |
165 | - self::EOF => function () { |
|
165 | + self::EOF => function() { |
|
166 | 166 | $this->error('Unterminated string'); |
167 | 167 | }, |
168 | 168 | ], |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | abstract class AbstractLexer |
17 | 17 | { |
18 | 18 | const STATE_INITIAL = 0; |
19 | - const EOF = '<<EOF>>'; |
|
19 | + const EOF = '<<EOF>>'; |
|
20 | 20 | |
21 | 21 | private $regexes = []; |
22 | 22 | private $tokenMaps = []; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $this->line += substr_count($matches[0], "\n"); |
62 | 62 | } else { |
63 | 63 | $i = 0; |
64 | - $matches = [ '' ]; |
|
64 | + $matches = ['']; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($this->tokenMaps[$this->state][$i - 1]) { |