@@ -29,8 +29,9 @@ discard block |
||
29 | 29 | $currentLanguage = self::getLanguage(); |
30 | 30 | } |
31 | 31 | //decoding for Start Date & Time and End Date & Time |
32 | - if (!is_array($key)) |
|
33 | - $key = decode_html($key); |
|
32 | + if (!is_array($key)) { |
|
33 | + $key = decode_html($key); |
|
34 | + } |
|
34 | 35 | $translatedString = self::getLanguageTranslatedString($currentLanguage, $key, $module); |
35 | 36 | |
36 | 37 | // label not found in users language pack, then check in the default language pack(config.inc.php) |
@@ -60,8 +61,9 @@ discard block |
||
60 | 61 | $moduleStrings = []; |
61 | 62 | |
62 | 63 | $module = str_replace(':', '.', $module); |
63 | - if (is_array($module)) |
|
64 | - return null; |
|
64 | + if (is_array($module)) { |
|
65 | + return null; |
|
66 | + } |
|
65 | 67 | $moduleStrings = self::getModuleStringsFromFile($language, $module); |
66 | 68 | if (!empty($moduleStrings['languageStrings'][$key])) { |
67 | 69 | return stripslashes($moduleStrings['languageStrings'][$key]); |
@@ -78,8 +80,9 @@ discard block |
||
78 | 80 | } |
79 | 81 | } |
80 | 82 | $commonStrings = self::getModuleStringsFromFile($language); |
81 | - if (!empty($commonStrings['languageStrings'][$key])) |
|
82 | - return stripslashes($commonStrings['languageStrings'][$key]); |
|
83 | + if (!empty($commonStrings['languageStrings'][$key])) { |
|
84 | + return stripslashes($commonStrings['languageStrings'][$key]); |
|
85 | + } |
|
83 | 86 | |
84 | 87 | return null; |
85 | 88 | } |
@@ -112,8 +115,9 @@ discard block |
||
112 | 115 | } |
113 | 116 | |
114 | 117 | $commonStrings = self::getModuleStringsFromFile($language); |
115 | - if (!empty($commonStrings['jsLanguageStrings'][$key])) |
|
116 | - return $commonStrings['jsLanguageStrings'][$key]; |
|
118 | + if (!empty($commonStrings['jsLanguageStrings'][$key])) { |
|
119 | + return $commonStrings['jsLanguageStrings'][$key]; |
|
120 | + } |
|
117 | 121 | |
118 | 122 | return $key; |
119 | 123 | } |
@@ -398,8 +398,9 @@ discard block |
||
398 | 398 | $fallBackFilePath = Vtiger_Loader::resolveNameToPath($preLayoutPath . $layoutPath . '/' . $jsFile, $fileExtension); |
399 | 399 | if (is_file($fallBackFilePath)) { |
400 | 400 | $filePath = $jsFile; |
401 | - if (empty($preLayoutPath)) |
|
402 | - $filePath = str_replace('.', '/', $filePath) . '.js'; |
|
401 | + if (empty($preLayoutPath)) { |
|
402 | + $filePath = str_replace('.', '/', $filePath) . '.js'; |
|
403 | + } |
|
403 | 404 | $minFilePath = str_replace('.js', '.min.js', $filePath); |
404 | 405 | if (vtlib\Functions::getMinimizationOptions($fileExtension) && is_file(Vtiger_Loader::resolveNameToPath('~' . $layoutPath . '/' . $minFilePath, $fileExtension))) { |
405 | 406 | $filePath = $minFilePath; |
@@ -413,8 +414,9 @@ discard block |
||
413 | 414 | $fallBackFilePath = Vtiger_Loader::resolveNameToPath($preLayoutPath . $layoutPath . '/' . $jsFile, $fileExtension); |
414 | 415 | if (is_file($fallBackFilePath)) { |
415 | 416 | $filePath = $jsFile; |
416 | - if (empty($preLayoutPath)) |
|
417 | - $filePath = str_replace('.', '/', $jsFile) . '.js'; |
|
417 | + if (empty($preLayoutPath)) { |
|
418 | + $filePath = str_replace('.', '/', $jsFile) . '.js'; |
|
419 | + } |
|
418 | 420 | $minFilePath = str_replace('.js', '.min.js', $filePath); |
419 | 421 | if (vtlib\Functions::getMinimizationOptions($fileExtension) && is_file(Vtiger_Loader::resolveNameToPath('~' . $layoutPath . '/' . $minFilePath, $fileExtension))) { |
420 | 422 | $filePath = $minFilePath; |
@@ -471,8 +473,9 @@ discard block |
||
471 | 473 | $layoutPath = 'layouts' . '/' . Yeti_Layout::getActiveLayout(); |
472 | 474 | $fallBackFilePath = Vtiger_Loader::resolveNameToPath($preLayoutPath . $layoutPath . '/' . $cssFile, $fileExtension); |
473 | 475 | if (is_file($fallBackFilePath)) { |
474 | - if (empty($preLayoutPath)) |
|
475 | - $filePath = str_replace('.', '/', $cssFile) . '.css'; |
|
476 | + if (empty($preLayoutPath)) { |
|
477 | + $filePath = str_replace('.', '/', $cssFile) . '.css'; |
|
478 | + } |
|
476 | 479 | $minFilePath = str_replace('.css', '.min.css', $filePath); |
477 | 480 | if (vtlib\Functions::getMinimizationOptions($fileExtension) && is_file(Vtiger_Loader::resolveNameToPath('~' . $layoutPath . '/' . $minFilePath, $fileExtension))) { |
478 | 481 | $filePath = $minFilePath; |
@@ -485,8 +488,9 @@ discard block |
||
485 | 488 | $layoutPath = 'layouts' . '/' . Vtiger_Viewer::getDefaultLayoutName(); |
486 | 489 | $fallBackFilePath = Vtiger_Loader::resolveNameToPath($preLayoutPath . $layoutPath . '/' . $cssFile, $fileExtension); |
487 | 490 | if (is_file($fallBackFilePath)) { |
488 | - if (empty($preLayoutPath)) |
|
489 | - $filePath = str_replace('.', '/', $cssFile) . '.css'; |
|
491 | + if (empty($preLayoutPath)) { |
|
492 | + $filePath = str_replace('.', '/', $cssFile) . '.css'; |
|
493 | + } |
|
490 | 494 | $minFilePath = str_replace('.css', '.min.css', $filePath); |
491 | 495 | if (vtlib\Functions::getMinimizationOptions($fileExtension) && is_file(Vtiger_Loader::resolveNameToPath('~' . $layoutPath . '/' . $minFilePath, $fileExtension))) { |
492 | 496 | $filePath = $minFilePath; |
@@ -77,8 +77,6 @@ |
||
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Function invokes exposed methods for this class |
80 | - * @param string $name - method name |
|
81 | - * @param Vtiger_Request $request |
|
82 | 80 | * @throws Exception |
83 | 81 | */ |
84 | 82 | public function invokeExposedMethod() |
@@ -306,8 +306,9 @@ |
||
306 | 306 | public function validateWriteAccess($skipRequestTypeCheck = false) |
307 | 307 | { |
308 | 308 | if (!$skipRequestTypeCheck) { |
309 | - if ($_SERVER['REQUEST_METHOD'] != 'POST') |
|
310 | - throw new \Exception\Csrf('Invalid request - validate Write Access'); |
|
309 | + if ($_SERVER['REQUEST_METHOD'] != 'POST') { |
|
310 | + throw new \Exception\Csrf('Invalid request - validate Write Access'); |
|
311 | + } |
|
311 | 312 | } |
312 | 313 | $this->validateReadAccess(); |
313 | 314 | $this->validateCSRF(); |
@@ -79,6 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Get value for key as boolean |
82 | + * @param string $key |
|
82 | 83 | */ |
83 | 84 | public function getBoolean($key, $defvalue = '') |
84 | 85 | { |
@@ -88,8 +89,8 @@ discard block |
||
88 | 89 | /** |
89 | 90 | * Function to get the value if its safe to use for SQL Query (column). |
90 | 91 | * @param string $key |
91 | - * @param boolean $skipEmpty - Skip the check if string is empty |
|
92 | - * @return Value for the given key |
|
92 | + * @param boolean $skipEmtpy - Skip the check if string is empty |
|
93 | + * @return string|false for the given key |
|
93 | 94 | */ |
94 | 95 | public function getForSql($key, $skipEmtpy = true) |
95 | 96 | { |
@@ -157,6 +158,7 @@ discard block |
||
157 | 158 | |
158 | 159 | /** |
159 | 160 | * Is the value (linked to key) empty? |
161 | + * @param string $key |
|
160 | 162 | */ |
161 | 163 | public function isEmpty($key) |
162 | 164 | { |
@@ -187,6 +189,7 @@ discard block |
||
187 | 189 | |
188 | 190 | /** |
189 | 191 | * Set the value for key |
192 | + * @param string $key |
|
190 | 193 | */ |
191 | 194 | public function delete($key) |
192 | 195 | { |
@@ -256,6 +259,9 @@ discard block |
||
256 | 259 | return $headers; |
257 | 260 | } |
258 | 261 | |
262 | + /** |
|
263 | + * @param string $key |
|
264 | + */ |
|
259 | 265 | public function getHeader($key) |
260 | 266 | { |
261 | 267 | if (empty($this->headers)) { |
@@ -264,6 +270,9 @@ discard block |
||
264 | 270 | return isset($this->headers[$key]) ? $this->headers[$key] : null; |
265 | 271 | } |
266 | 272 | |
273 | + /** |
|
274 | + * @return string |
|
275 | + */ |
|
267 | 276 | public function getRequestMetod() |
268 | 277 | { |
269 | 278 | $method = $_SERVER['REQUEST_METHOD']; |
@@ -362,6 +371,9 @@ discard block |
||
362 | 371 | return static::$request->get($key, $defvalue); |
363 | 372 | } |
364 | 373 | |
374 | + /** |
|
375 | + * @param string $key |
|
376 | + */ |
|
365 | 377 | public static function has($key) |
366 | 378 | { |
367 | 379 | if (!static::$request) { |
@@ -370,6 +382,11 @@ discard block |
||
370 | 382 | return static::$request->has($key); |
371 | 383 | } |
372 | 384 | |
385 | + /** |
|
386 | + * @param string $key |
|
387 | + * |
|
388 | + * @return string |
|
389 | + */ |
|
373 | 390 | public static function getForSql($key, $skipEmtpy = true) |
374 | 391 | { |
375 | 392 | if (!static::$request) { |
@@ -378,6 +395,9 @@ discard block |
||
378 | 395 | return static::$request->getForSql($key, $skipEmtpy); |
379 | 396 | } |
380 | 397 | |
398 | + /** |
|
399 | + * @param string $key |
|
400 | + */ |
|
381 | 401 | public static function set($key, $value) |
382 | 402 | { |
383 | 403 | if (!static::$request) { |
@@ -386,6 +406,9 @@ discard block |
||
386 | 406 | return static::$request->set($key, $value); |
387 | 407 | } |
388 | 408 | |
409 | + /** |
|
410 | + * @param string $key |
|
411 | + */ |
|
389 | 412 | public static function isEmpty($key) |
390 | 413 | { |
391 | 414 | if (!static::$request) { |
@@ -38,7 +38,7 @@ |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | public function __toString() { |
41 | - return "MismatchedNotSetException(".$this->getUnexpectedType()." not in [".a.",".b."])"; |
|
41 | + return "MismatchedNotSetException(" . $this->getUnexpectedType() . " not in [" . a . "," . b . "])"; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | public function __construct($input, $state = null) { |
38 | 38 | parent::__construct($state); // share the state object with another parser |
39 | 39 | $this->setTokenStream($input); |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | 42 | public function reset() { |
43 | 43 | parent::reset(); // reset all recognizer state variables |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $this->input = $input; |
78 | 78 | } |
79 | 79 | |
80 | - public function getTokenStream() { |
|
80 | + public function getTokenStream() { |
|
81 | 81 | return $this->input; |
82 | 82 | } |
83 | 83 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | public function reset() { |
43 | 43 | parent::reset(); // reset all recognizer state variables |
44 | - if ( $this->input!=null ) { |
|
44 | + if ($this->input != null) { |
|
45 | 45 | $this->input->seek(0); // rewind the input |
46 | 46 | } |
47 | 47 | } |
@@ -53,15 +53,15 @@ discard block |
||
53 | 53 | protected function getMissingSymbol($input, $e, $expectedTokenType, $follow) |
54 | 54 | { |
55 | 55 | $tokenText = null; |
56 | - if ( $expectedTokenType==TokenConst::$EOF ){ |
|
56 | + if ($expectedTokenType == TokenConst::$EOF) { |
|
57 | 57 | $tokenText = "<missing EOF>"; |
58 | 58 | } else { |
59 | 59 | $tokenNames = $this->getTokenNames(); |
60 | - $tokenText = "<missing ".$tokenNames[$expectedTokenType].">"; |
|
60 | + $tokenText = "<missing " . $tokenNames[$expectedTokenType] . ">"; |
|
61 | 61 | } |
62 | 62 | $t = CommonToken::forTypeAndText($expectedTokenType, $tokenText); |
63 | 63 | $current = $input->LT(1); |
64 | - if ( $current->getType() == TokenConst::$EOF ) { |
|
64 | + if ($current->getType() == TokenConst::$EOF) { |
|
65 | 65 | $current = $this->input->LT(-1); |
66 | 66 | } |
67 | 67 | $t->line = $current->getLine(); |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | return $this->input->getSourceName(); |
86 | 86 | } |
87 | 87 | |
88 | - public function traceIn($ruleName, $ruleIndex, $inputSymbol=null) { |
|
88 | + public function traceIn($ruleName, $ruleIndex, $inputSymbol = null) { |
|
89 | 89 | parent::traceIn($ruleName, $ruleIndex, $this->input->LT(1)); |
90 | 90 | } |
91 | 91 | |
92 | - public function traceOut($ruleName, $ruleIndex, $inputSymbol=null) { |
|
92 | + public function traceOut($ruleName, $ruleIndex, $inputSymbol = null) { |
|
93 | 93 | parent::traceOut($ruleName, $ruleIndex, $this->input->LT(1)); |
94 | 94 | } |
95 | 95 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | |
11 | 11 | public static $MIN_TOKEN_TYPE;// = UP+1; |
12 | 12 | |
13 | - public static $EOF;// = CharStream.EOF; |
|
13 | + public static $EOF;// = CharStream.EOF; |
|
14 | 14 | public static $EOF_TOKEN;// = new CommonToken(EOF); |
15 | 15 | |
16 | 16 | public static $INVALID_TOKEN_TYPE = 0; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | - class TokenConst{ |
|
3 | + class TokenConst { |
|
4 | 4 | public static $EOR_TOKEN_TYPE = 1; |
5 | 5 | |
6 | 6 | /** imaginary tree navigation type; traverse "get child" link */ |
@@ -8,18 +8,18 @@ discard block |
||
8 | 8 | /** imaginary tree navigation type; finish with a child list */ |
9 | 9 | public static $UP = 3; |
10 | 10 | |
11 | - public static $MIN_TOKEN_TYPE;// = UP+1; |
|
11 | + public static $MIN_TOKEN_TYPE; // = UP+1; |
|
12 | 12 | |
13 | - public static $EOF;// = CharStream.EOF; |
|
14 | - public static $EOF_TOKEN;// = new CommonToken(EOF); |
|
13 | + public static $EOF; // = CharStream.EOF; |
|
14 | + public static $EOF_TOKEN; // = new CommonToken(EOF); |
|
15 | 15 | |
16 | 16 | public static $INVALID_TOKEN_TYPE = 0; |
17 | - public static $INVALID_TOKEN;// = new CommonToken(INVALID_TOKEN_TYPE); |
|
17 | + public static $INVALID_TOKEN; // = new CommonToken(INVALID_TOKEN_TYPE); |
|
18 | 18 | |
19 | 19 | /** In an action, a lexer rule can set token to this SKIP_TOKEN and ANTLR |
20 | 20 | * will avoid creating a token for this symbol and try to fetch another. |
21 | 21 | */ |
22 | - public static $SKIP_TOKEN;// = new CommonToken(INVALID_TOKEN_TYPE); |
|
22 | + public static $SKIP_TOKEN; // = new CommonToken(INVALID_TOKEN_TYPE); |
|
23 | 23 | |
24 | 24 | /** All tokens go to the parser (unless skip() is called in that rule) |
25 | 25 | * on a particular "channel". The parser tunes to a particular channel |
@@ -34,20 +34,20 @@ discard block |
||
34 | 34 | } |
35 | 35 | |
36 | 36 | |
37 | - interface Token{ |
|
37 | + interface Token { |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
41 | 41 | class CommonToken implements Token { |
42 | 42 | |
43 | 43 | |
44 | - public function __construct(){ |
|
44 | + public function __construct() { |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | |
48 | - public static function forInput($input=null, $type, $channel=0, $start=0, $stop=0) { |
|
48 | + public static function forInput($input = null, $type, $channel = 0, $start = 0, $stop = 0) { |
|
49 | 49 | $ct = new CommonToken(); |
50 | - $ct->charPositionInLine=-1; |
|
50 | + $ct->charPositionInLine = -1; |
|
51 | 51 | $ct->input = $input; |
52 | 52 | $ct->type = $type; |
53 | 53 | $ct->channel = $channel; |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | return $ct; |
57 | 57 | } |
58 | 58 | |
59 | - public static function forType($type){ |
|
60 | - return CommonToken::forInput($input=null, $type); |
|
59 | + public static function forType($type) { |
|
60 | + return CommonToken::forInput($input = null, $type); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | public static function forTypeAndText($type, $text) { |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | } |
91 | 91 | |
92 | 92 | public function getText() { |
93 | - if ( $this->text!=null ) { |
|
93 | + if ($this->text != null) { |
|
94 | 94 | return $this->text; |
95 | 95 | } |
96 | - if ( $this->input==null ) { |
|
96 | + if ($this->input == null) { |
|
97 | 97 | return null; |
98 | 98 | } |
99 | - $this->text = $this->input->substring($this->start,$this->stop); |
|
99 | + $this->text = $this->input->substring($this->start, $this->stop); |
|
100 | 100 | return $this->text; |
101 | 101 | } |
102 | 102 | |
@@ -167,28 +167,28 @@ discard block |
||
167 | 167 | |
168 | 168 | public function toString() { |
169 | 169 | $channelStr = ""; |
170 | - if ( $this->channel>0 ) { |
|
171 | - $channelStr=",channel=".$this->channel; |
|
170 | + if ($this->channel > 0) { |
|
171 | + $channelStr = ",channel=" . $this->channel; |
|
172 | 172 | } |
173 | 173 | $txt = $this->getText(); |
174 | - if ( $txt!=null ) { |
|
175 | - $txt = str_replace("\n",'\n', $txt); |
|
176 | - $txt = str_replace("\r",'\r', $txt); |
|
177 | - $txt = str_replace("\t",'\t', $txt); |
|
174 | + if ($txt != null) { |
|
175 | + $txt = str_replace("\n", '\n', $txt); |
|
176 | + $txt = str_replace("\r", '\r', $txt); |
|
177 | + $txt = str_replace("\t", '\t', $txt); |
|
178 | 178 | } |
179 | 179 | else { |
180 | 180 | $txt = "<no text>"; |
181 | 181 | } |
182 | - return "[@".$this->getTokenIndex().",".$this->start.":".$this->stop."='".$txt."',<".$this->type.">".$channelStr.",".$this->line.":".$this->getCharPositionInLine()."]"; |
|
182 | + return "[@" . $this->getTokenIndex() . "," . $this->start . ":" . $this->stop . "='" . $txt . "',<" . $this->type . ">" . $channelStr . "," . $this->line . ":" . $this->getCharPositionInLine() . "]"; |
|
183 | 183 | } |
184 | 184 | |
185 | - public function __toString(){ |
|
185 | + public function __toString() { |
|
186 | 186 | return $this->toString(); |
187 | 187 | } |
188 | 188 | } |
189 | 189 | |
190 | - TokenConst::$DEFAULT_CHANNEL=0; |
|
191 | - TokenConst::$INVALID_TOKEN_TYPE=0; |
|
190 | + TokenConst::$DEFAULT_CHANNEL = 0; |
|
191 | + TokenConst::$INVALID_TOKEN_TYPE = 0; |
|
192 | 192 | |
193 | 193 | TokenConst::$EOF = CharStreamConst::$EOF; |
194 | 194 | TokenConst::$EOF_TOKEN = CommonToken::forType(TokenConst::$EOF); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | |
214 | 214 | |
215 | 215 | |
216 | - TokenConst::$MIN_TOKEN_TYPE = TokenConst::$UP+1; |
|
216 | + TokenConst::$MIN_TOKEN_TYPE = TokenConst::$UP + 1; |
|
217 | 217 | |
218 | 218 | |
219 | 219 |
@@ -175,8 +175,7 @@ |
||
175 | 175 | $txt = str_replace("\n",'\n', $txt); |
176 | 176 | $txt = str_replace("\r",'\r', $txt); |
177 | 177 | $txt = str_replace("\t",'\t', $txt); |
178 | - } |
|
179 | - else { |
|
178 | + } else { |
|
180 | 179 | $txt = "<no text>"; |
181 | 180 | } |
182 | 181 | return "[@".$this->getTokenIndex().",".$this->start.":".$this->stop."='".$txt."',<".$this->type.">".$channelStr.",".$this->line.":".$this->getCharPositionInLine()."]"; |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * something nonnull so that the auto token emit mechanism will not |
56 | 56 | * emit another token. |
57 | 57 | */ |
58 | - $this->token = null; |
|
58 | + $this->token = null; |
|
59 | 59 | |
60 | 60 | /** What character index in the stream did the current token start at? |
61 | 61 | * Needed, for example, to get the text for current token. Set at |
62 | 62 | * the start of nextToken. |
63 | - */ |
|
63 | + */ |
|
64 | 64 | $this->tokenStartCharIndex = -1; |
65 | 65 | |
66 | 66 | /** The line on which the first character of the token resides */ |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | /** You can set the text for the current token to override what is in |
79 | 79 | * the input char buffer. Use setText() or can set this instance var. |
80 | - */ |
|
80 | + */ |
|
81 | 81 | $this->text=null; |
82 | 82 | |
83 | 83 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | class RecognizerSharedState { |
3 | - public function __construct(){ |
|
3 | + public function __construct() { |
|
4 | 4 | /** Track the set of token types that can follow any rule invocation. |
5 | 5 | * Stack grows upwards. When it hits the max, it grows 2x in size |
6 | 6 | * and keeps going. |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | /** In lieu of a return value, this indicates that a rule or token |
25 | 25 | * has failed to match. Reset to false upon valid token match. |
26 | 26 | */ |
27 | - $this->failed=false; |
|
27 | + $this->failed = false; |
|
28 | 28 | /** Did the recognizer encounter a syntax error? Track how many. */ |
29 | - $this->syntaxErrors=0; |
|
29 | + $this->syntaxErrors = 0; |
|
30 | 30 | |
31 | 31 | /** If 0, no backtracking is going on. Safe to exec actions etc... |
32 | 32 | * If >0 then it's the level of backtracking. |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** You can set the text for the current token to override what is in |
79 | 79 | * the input char buffer. Use setText() or can set this instance var. |
80 | 80 | */ |
81 | - $this->text=null; |
|
81 | + $this->text = null; |
|
82 | 82 | |
83 | 83 | } |
84 | 84 |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Base class for lexers |
4 | 4 | */ |
5 | -abstract class AntlrLexer extends BaseRecognizer{ |
|
5 | +abstract class AntlrLexer extends BaseRecognizer { |
|
6 | 6 | public static $DEFAULT_TOKEN_CHANNEL = 0; |
7 | 7 | protected $input; |
8 | 8 | |
9 | - public function __construct($input, &$state=null) { |
|
10 | - if($state==null){ |
|
9 | + public function __construct($input, &$state = null) { |
|
10 | + if ($state == null) { |
|
11 | 11 | $state = new RecognizerSharedState(); |
12 | 12 | } |
13 | 13 | $this->state = $state; |
@@ -17,10 +17,10 @@ discard block |
||
17 | 17 | public function reset() { |
18 | 18 | parent::reset(); // reset all recognizer state variables |
19 | 19 | // wack Lexer state variables |
20 | - if ( $this->input!=null ) { |
|
20 | + if ($this->input != null) { |
|
21 | 21 | $this->input->seek(0); // rewind the input |
22 | 22 | } |
23 | - if ( $this->state==null ) { |
|
23 | + if ($this->state == null) { |
|
24 | 24 | return; // no shared state work to do |
25 | 25 | } |
26 | 26 | $this->state->token = null; |
@@ -39,20 +39,20 @@ discard block |
||
39 | 39 | public function nextToken() { |
40 | 40 | while (true) { |
41 | 41 | $this->state->token = null; |
42 | - $this->state->channel = 0;//Token::DEFAULT_CHANNEL; |
|
42 | + $this->state->channel = 0; //Token::DEFAULT_CHANNEL; |
|
43 | 43 | $this->state->tokenStartCharIndex = $this->input->index(); |
44 | 44 | $this->state->tokenStartCharPositionInLine = $this->input->getCharPositionInLine(); |
45 | 45 | $this->state->tokenStartLine = $this->input->getLine(); |
46 | 46 | $this->state->text = null; |
47 | - if ( $this->input->LA(1)==CharStreamConst::$EOF ) { |
|
47 | + if ($this->input->LA(1) == CharStreamConst::$EOF) { |
|
48 | 48 | return TokenConst::$EOF_TOKEN; |
49 | 49 | } |
50 | 50 | try { |
51 | 51 | $this->mTokens(); |
52 | - if ( $this->state->token==null ) { |
|
52 | + if ($this->state->token == null) { |
|
53 | 53 | $this->emit(); |
54 | 54 | } |
55 | - else if ( $this->state->token==Token::$SKIP_TOKEN ) { |
|
55 | + else if ($this->state->token == Token::$SKIP_TOKEN) { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | 58 | return $this->state->token; |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | * If you are building trees, then you should also override |
111 | 111 | * Parser or TreeParser.getMissingSymbol(). |
112 | 112 | */ |
113 | - public function emit($token=null) { |
|
114 | - if($token==null){ |
|
113 | + public function emit($token = null) { |
|
114 | + if ($token == null) { |
|
115 | 115 | $token = CommonToken::forInput($this->input, $this->state->type, $this->state->channel, |
116 | - $this->state->tokenStartCharIndex, $this->getCharIndex()-1); |
|
116 | + $this->state->tokenStartCharIndex, $this->getCharIndex() - 1); |
|
117 | 117 | $token->setLine($this->state->tokenStartLine); |
118 | 118 | $token->setText($this->state->text); |
119 | 119 | $token->setCharPositionInLine($this->state->tokenStartCharPositionInLine); |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | return $token; |
123 | 123 | } |
124 | 124 | |
125 | - public function matchString($s){ |
|
125 | + public function matchString($s) { |
|
126 | 126 | $i = 0; |
127 | - while ( $i<strlen($s)) { |
|
128 | - if ( $this->input->LA(1)!=charAt($s, $i) ) { |
|
129 | - if ( $this->state->backtracking>0 ) { |
|
127 | + while ($i < strlen($s)) { |
|
128 | + if ($this->input->LA(1) != charAt($s, $i)) { |
|
129 | + if ($this->state->backtracking > 0) { |
|
130 | 130 | $this->state->failed = true; |
131 | 131 | return; |
132 | 132 | } |
@@ -140,18 +140,18 @@ discard block |
||
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - public function matchAny($x=null) { |
|
143 | + public function matchAny($x = null) { |
|
144 | 144 | $this->input->consume(); |
145 | 145 | } |
146 | 146 | |
147 | 147 | public function matchChar($c) { |
148 | - if ($this->input->LA(1)!=$c ) { |
|
149 | - if ( $this->state->backtracking>0 ) { |
|
148 | + if ($this->input->LA(1) != $c) { |
|
149 | + if ($this->state->backtracking > 0) { |
|
150 | 150 | $this->state->failed = true; |
151 | 151 | return; |
152 | 152 | } |
153 | 153 | $mte = new MismatchedTokenException($c, $this->input); |
154 | - $this->recover($mte); // don't really recover; just consume in lexer |
|
154 | + $this->recover($mte); // don't really recover; just consume in lexer |
|
155 | 155 | throw $mte; |
156 | 156 | } |
157 | 157 | $this->input->consume(); |
@@ -159,8 +159,8 @@ discard block |
||
159 | 159 | } |
160 | 160 | |
161 | 161 | public function matchRange($a, $b) { |
162 | - if ( $this->input->LA(1)<$a || $this->input->LA(1)>$b ) { |
|
163 | - if ( $this->state->backtracking>0 ) { |
|
162 | + if ($this->input->LA(1) < $a || $this->input->LA(1) > $b) { |
|
163 | + if ($this->state->backtracking > 0) { |
|
164 | 164 | $this->state->failed = true; |
165 | 165 | return; |
166 | 166 | } |
@@ -190,10 +190,10 @@ discard block |
||
190 | 190 | * text override. |
191 | 191 | */ |
192 | 192 | public function getText() { |
193 | - if ( $this->state->text!=null ) { |
|
193 | + if ($this->state->text != null) { |
|
194 | 194 | return $this->state->text; |
195 | 195 | } |
196 | - return $this->input->substring($this->state->tokenStartCharIndex,$this->getCharIndex()-1); |
|
196 | + return $this->input->substring($this->state->tokenStartCharIndex, $this->getCharIndex() - 1); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** Set the complete text of this token; it wipes any previous |
@@ -220,35 +220,35 @@ discard block |
||
220 | 220 | |
221 | 221 | public function getErrorMessage($e, $tokenNames) { |
222 | 222 | $msg = null; |
223 | - if ( $e instanceof MismatchedTokenException ) { |
|
223 | + if ($e instanceof MismatchedTokenException) { |
|
224 | 224 | $mte = $e; |
225 | - $msg = "mismatched character ".$this->getCharErrorDisplay($e->c). |
|
226 | - " expecting ".$this->getCharErrorDisplay($mte->expecting); |
|
225 | + $msg = "mismatched character " . $this->getCharErrorDisplay($e->c) . |
|
226 | + " expecting " . $this->getCharErrorDisplay($mte->expecting); |
|
227 | 227 | } |
228 | - else if ( $e instanceof NoViableAltException ) { |
|
228 | + else if ($e instanceof NoViableAltException) { |
|
229 | 229 | $nvae = $e; |
230 | 230 | // for development, can add "decision=<<"+nvae.grammarDecisionDescription+">>" |
231 | 231 | // and "(decision="+nvae.decisionNumber+") and |
232 | 232 | // "state "+nvae.stateNumber |
233 | - $msg = "no viable alternative at character ".$this->getCharErrorDisplay($e->c); |
|
233 | + $msg = "no viable alternative at character " . $this->getCharErrorDisplay($e->c); |
|
234 | 234 | } |
235 | - else if ( $e instanceof EarlyExitException ) { |
|
235 | + else if ($e instanceof EarlyExitException) { |
|
236 | 236 | $eee = $e; |
237 | 237 | // for development, can add "(decision="+eee.decisionNumber+")" |
238 | - $msg = "required (...)+ loop did not match anything at character ".$this->getCharErrorDisplay($e->c); |
|
238 | + $msg = "required (...)+ loop did not match anything at character " . $this->getCharErrorDisplay($e->c); |
|
239 | 239 | } |
240 | - else if ( $e instanceof MismatchedNotSetException ) { |
|
240 | + else if ($e instanceof MismatchedNotSetException) { |
|
241 | 241 | $mse = $e; |
242 | - $msg = "mismatched character ".$this->getCharErrorDisplay($e->c)." expecting set ".$mse->expecting; |
|
242 | + $msg = "mismatched character " . $this->getCharErrorDisplay($e->c) . " expecting set " . $mse->expecting; |
|
243 | 243 | } |
244 | - else if ( $e instanceof MismatchedSetException ) { |
|
244 | + else if ($e instanceof MismatchedSetException) { |
|
245 | 245 | $mse = $e; |
246 | - $msg = "mismatched character ".$this->getCharErrorDisplay($e->c)." expecting set ".$mse->expecting; |
|
246 | + $msg = "mismatched character " . $this->getCharErrorDisplay($e->c) . " expecting set " . $mse->expecting; |
|
247 | 247 | } |
248 | - else if ( $e instanceof MismatchedRangeException ) { |
|
248 | + else if ($e instanceof MismatchedRangeException) { |
|
249 | 249 | $mre = $e; |
250 | - $msg = "mismatched character ".$this->getCharErrorDisplay($e->c)." expecting set ". |
|
251 | - $this->getCharErrorDisplay($mre->a)."..".$this->getCharErrorDisplay($mre->b); |
|
250 | + $msg = "mismatched character " . $this->getCharErrorDisplay($e->c) . " expecting set " . |
|
251 | + $this->getCharErrorDisplay($mre->a) . ".." . $this->getCharErrorDisplay($mre->b); |
|
252 | 252 | } |
253 | 253 | else { |
254 | 254 | $msg = parent::getErrorMessage($e, $tokenNames); |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | |
259 | 259 | public function getCharErrorDisplay($c) { |
260 | 260 | $s = chr($c); |
261 | - switch ( $s ) { |
|
261 | + switch ($s) { |
|
262 | 262 | case '\n' : |
263 | 263 | $s = "\\n"; |
264 | 264 | break; |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | $s = "\\r"; |
270 | 270 | break; |
271 | 271 | } |
272 | - if ($c==TokenConst::$EOF){ |
|
272 | + if ($c == TokenConst::$EOF) { |
|
273 | 273 | $s = "<EOF>"; |
274 | 274 | } |
275 | - return "'".$s."'"; |
|
275 | + return "'" . $s . "'"; |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** Lexers can normally match any char in it's vocabulary after matching |
@@ -280,18 +280,18 @@ discard block |
||
280 | 280 | * it all works out. You can instead use the rule invocation stack |
281 | 281 | * to do sophisticated error recovery if you are in a fragment rule. |
282 | 282 | */ |
283 | - public function recover($re, $input=null) { |
|
283 | + public function recover($re, $input = null) { |
|
284 | 284 | $this->input->consume(); |
285 | 285 | } |
286 | 286 | |
287 | 287 | |
288 | - public function traceIn($ruleName, $ruleIndex, $inputSymbol=null) { |
|
289 | - $inputSymbol = $this->input->LT(1)." line=".$this->getLine().":".$this->getCharPositionInLine(); |
|
288 | + public function traceIn($ruleName, $ruleIndex, $inputSymbol = null) { |
|
289 | + $inputSymbol = $this->input->LT(1) . " line=" . $this->getLine() . ":" . $this->getCharPositionInLine(); |
|
290 | 290 | parent::traceIn($ruleName, $ruleIndex, $inputSymbol); |
291 | 291 | } |
292 | 292 | |
293 | - public function traceOut($ruleName, $ruleIndex, $inputSymbol=null) { |
|
294 | - $inputSymbol = $this->input->LT(1)." line=".$this->getLine().":".$this->getCharPositionInLine(); |
|
293 | + public function traceOut($ruleName, $ruleIndex, $inputSymbol = null) { |
|
294 | + $inputSymbol = $this->input->LT(1) . " line=" . $this->getLine() . ":" . $this->getCharPositionInLine(); |
|
295 | 295 | parent::traceOut($ruleName, $ruleIndex, $inputSymbol); |
296 | 296 | } |
297 | 297 | } |
@@ -51,17 +51,14 @@ discard block |
||
51 | 51 | $this->mTokens(); |
52 | 52 | if ( $this->state->token==null ) { |
53 | 53 | $this->emit(); |
54 | - } |
|
55 | - else if ( $this->state->token==Token::$SKIP_TOKEN ) { |
|
54 | + } else if ( $this->state->token==Token::$SKIP_TOKEN ) { |
|
56 | 55 | continue; |
57 | 56 | } |
58 | 57 | return $this->state->token; |
59 | - } |
|
60 | - catch (NoViableAltException $nva) { |
|
58 | + } catch (NoViableAltException $nva) { |
|
61 | 59 | $this->reportError($nva); |
62 | 60 | $this->recover($nva); // throw out current char and try again |
63 | - } |
|
64 | - catch (RecognitionException $re) { |
|
61 | + } catch (RecognitionException $re) { |
|
65 | 62 | $this->reportError($re); |
66 | 63 | // match() routine has already called recover() |
67 | 64 | } |
@@ -224,33 +221,27 @@ discard block |
||
224 | 221 | $mte = $e; |
225 | 222 | $msg = "mismatched character ".$this->getCharErrorDisplay($e->c). |
226 | 223 | " expecting ".$this->getCharErrorDisplay($mte->expecting); |
227 | - } |
|
228 | - else if ( $e instanceof NoViableAltException ) { |
|
224 | + } else if ( $e instanceof NoViableAltException ) { |
|
229 | 225 | $nvae = $e; |
230 | 226 | // for development, can add "decision=<<"+nvae.grammarDecisionDescription+">>" |
231 | 227 | // and "(decision="+nvae.decisionNumber+") and |
232 | 228 | // "state "+nvae.stateNumber |
233 | 229 | $msg = "no viable alternative at character ".$this->getCharErrorDisplay($e->c); |
234 | - } |
|
235 | - else if ( $e instanceof EarlyExitException ) { |
|
230 | + } else if ( $e instanceof EarlyExitException ) { |
|
236 | 231 | $eee = $e; |
237 | 232 | // for development, can add "(decision="+eee.decisionNumber+")" |
238 | 233 | $msg = "required (...)+ loop did not match anything at character ".$this->getCharErrorDisplay($e->c); |
239 | - } |
|
240 | - else if ( $e instanceof MismatchedNotSetException ) { |
|
234 | + } else if ( $e instanceof MismatchedNotSetException ) { |
|
241 | 235 | $mse = $e; |
242 | 236 | $msg = "mismatched character ".$this->getCharErrorDisplay($e->c)." expecting set ".$mse->expecting; |
243 | - } |
|
244 | - else if ( $e instanceof MismatchedSetException ) { |
|
237 | + } else if ( $e instanceof MismatchedSetException ) { |
|
245 | 238 | $mse = $e; |
246 | 239 | $msg = "mismatched character ".$this->getCharErrorDisplay($e->c)." expecting set ".$mse->expecting; |
247 | - } |
|
248 | - else if ( $e instanceof MismatchedRangeException ) { |
|
240 | + } else if ( $e instanceof MismatchedRangeException ) { |
|
249 | 241 | $mre = $e; |
250 | 242 | $msg = "mismatched character ".$this->getCharErrorDisplay($e->c)." expecting set ". |
251 | 243 | $this->getCharErrorDisplay($mre->a)."..".$this->getCharErrorDisplay($mre->b); |
252 | - } |
|
253 | - else { |
|
244 | + } else { |
|
254 | 245 | $msg = parent::getErrorMessage($e, $tokenNames); |
255 | 246 | } |
256 | 247 | return $msg; |
@@ -122,6 +122,9 @@ discard block |
||
122 | 122 | return $token; |
123 | 123 | } |
124 | 124 | |
125 | + /** |
|
126 | + * @param string $s |
|
127 | + */ |
|
125 | 128 | public function matchString($s){ |
126 | 129 | $i = 0; |
127 | 130 | while ( $i<strlen($s)) { |
@@ -144,6 +147,9 @@ discard block |
||
144 | 147 | $this->input->consume(); |
145 | 148 | } |
146 | 149 | |
150 | + /** |
|
151 | + * @param integer $c |
|
152 | + */ |
|
147 | 153 | public function matchChar($c) { |
148 | 154 | if ($this->input->LA(1)!=$c ) { |
149 | 155 | if ( $this->state->backtracking>0 ) { |
@@ -158,6 +164,10 @@ discard block |
||
158 | 164 | $this->state->failed = false; |
159 | 165 | } |
160 | 166 | |
167 | + /** |
|
168 | + * @param integer $a |
|
169 | + * @param integer $b |
|
170 | + */ |
|
161 | 171 | public function matchRange($a, $b) { |
162 | 172 | if ( $this->input->LA(1)<$a || $this->input->LA(1)>$b ) { |
163 | 173 | if ( $this->state->backtracking>0 ) { |
@@ -203,6 +213,9 @@ discard block |
||
203 | 213 | $this->state->text = $text; |
204 | 214 | } |
205 | 215 | |
216 | + /** |
|
217 | + * @param RecognitionException $e |
|
218 | + */ |
|
206 | 219 | public function reportError($e) { |
207 | 220 | $this->displayRecognitionError($this->getTokenNames(), $e); |
208 | 221 | } |
@@ -30,13 +30,13 @@ |
||
30 | 30 | /** A mismatched char or Token or tree node */ |
31 | 31 | class MismatchedTokenException extends RecognitionException { |
32 | 32 | |
33 | - public function __construct($expecting=0, $input=null) { |
|
33 | + public function __construct($expecting = 0, $input = null) { |
|
34 | 34 | parent::__construct($input); |
35 | 35 | $this->expecting = $expecting; |
36 | 36 | } |
37 | 37 | |
38 | 38 | public function __toString() { |
39 | - return "MismatchedTokenException(".$this->getUnexpectedType()."!=".$this->expecting.")"; |
|
39 | + return "MismatchedTokenException(" . $this->getUnexpectedType() . "!=" . $this->expecting . ")"; |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | ?> |