@@ -53,7 +53,7 @@ |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
56 | - * @param $input |
|
56 | + * @param TableASTNode $input |
|
57 | 57 | * |
58 | 58 | * @return array |
59 | 59 | * @throws LuaParseException |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | return self::parseTable($input); |
37 | 37 | } |
38 | 38 | if (!($input instanceof ASTNode)) { |
39 | - throw new ParseException("Unexpected AST node: " . get_class($input)); |
|
39 | + throw new ParseException("Unexpected AST node: ".get_class($input)); |
|
40 | 40 | } |
41 | 41 | if ($input instanceof LiteralASTNode) { |
42 | 42 | return $input->getValue(); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | if ($input instanceof NilASTNode) { |
45 | 45 | return null; |
46 | 46 | } |
47 | - throw new ParseException("Unexpected AST node: " . $input->getName()); |
|
47 | + throw new ParseException("Unexpected AST node: ".$input->getName()); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -56,11 +56,11 @@ discard block |
||
56 | 56 | private static function parseTable($input) { |
57 | 57 | $data = []; |
58 | 58 | if (!($input instanceof TableASTNode)) { |
59 | - throw new ParseException("Unexpected AST node: " . get_class($input)); |
|
59 | + throw new ParseException("Unexpected AST node: ".get_class($input)); |
|
60 | 60 | } |
61 | 61 | foreach ($input->getEntries() as $token) { |
62 | 62 | if (!($token instanceof TableEntryASTNode)) { |
63 | - throw new ParseException("Unexpected token: " . $token->getName()); |
|
63 | + throw new ParseException("Unexpected token: ".$token->getName()); |
|
64 | 64 | } |
65 | 65 | $value = self::parseValue($token->getValue()); |
66 | 66 | if ($token->hasKey()) { |
@@ -111,7 +111,7 @@ |
||
111 | 111 | * @param string $separator |
112 | 112 | * @param callable $parser |
113 | 113 | * |
114 | - * @return array |
|
114 | + * @return TableEntryASTNode[] |
|
115 | 115 | */ |
116 | 116 | protected function delimited($start, $stop, $separator, callable $parser) { |
117 | 117 | $a = []; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | return new TableASTNode([new TableEntryASTNode($value, $result)]); |
49 | 49 | } |
50 | 50 | |
51 | - $this->input->error('Parser has finished parsing, but end of file was not reached. Next character is ' . $this->input->peek()->getValue()); |
|
51 | + $this->input->error('Parser has finished parsing, but end of file was not reached. Next character is '.$this->input->peek()->getValue()); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | return $result; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | if ($token->getValue() === 'nil') { |
78 | 78 | return new NilASTNode(); |
79 | 79 | } else { |
80 | - $this->input->error('Unexpected keyword: ' . $token->getValue()); |
|
80 | + $this->input->error('Unexpected keyword: '.$token->getValue()); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | $this->unexpected(); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | if ($this->isPunctuation($char)) { |
174 | 174 | $this->input->next(); |
175 | 175 | } else { |
176 | - $this->input->error('Expecting punctuation: "' . $char . '"'); |
|
176 | + $this->input->error('Expecting punctuation: "'.$char.'"'); |
|
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
@@ -181,6 +181,6 @@ discard block |
||
181 | 181 | * @throws ParseException |
182 | 182 | */ |
183 | 183 | protected function unexpected() { |
184 | - $this->input->error('Unexpected token: ' . json_encode($this->input->peek())); |
|
184 | + $this->input->error('Unexpected token: '.json_encode($this->input->peek())); |
|
185 | 185 | } |
186 | 186 | } |
187 | 187 | \ No newline at end of file |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | - throw new \InvalidArgumentException("Cannot encode type " . get_class($data) . ": " . var_export($data, true)); |
|
39 | + throw new \InvalidArgumentException("Cannot encode type ".get_class($data).": ".var_export($data, true)); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | private static function encodeArray(array $data, $indent) { |
@@ -45,12 +45,12 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | $result = "{\n"; |
48 | - $subIndent = $indent . ' '; |
|
48 | + $subIndent = $indent.' '; |
|
49 | 49 | $seen = []; |
50 | 50 | foreach ($data as $key => $value) { |
51 | 51 | if (is_int($key)) { |
52 | 52 | $seen[$key] = true; |
53 | - $result .= $subIndent . self::encode($value, $subIndent) . ",\n"; |
|
53 | + $result .= $subIndent.self::encode($value, $subIndent).",\n"; |
|
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | && !in_array($key, Lua::$luaKeywords) |
61 | 61 | && preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $key) |
62 | 62 | ) { |
63 | - $entry = $key . ' = ' . self::encode($value, $subIndent) . ",\n"; |
|
63 | + $entry = $key.' = '.self::encode($value, $subIndent).",\n"; |
|
64 | 64 | } else { |
65 | - $entry = '[ ' . self::encode($key, $subIndent) . ' ] = ' . self::encode($value, $subIndent) . ",\n"; |
|
65 | + $entry = '[ '.self::encode($key, $subIndent).' ] = '.self::encode($value, $subIndent).",\n"; |
|
66 | 66 | } |
67 | - $result = $result . $subIndent . $entry; |
|
67 | + $result = $result.$subIndent.$entry; |
|
68 | 68 | } |
69 | 69 | } |
70 | - $result = $result . $indent . '}'; |
|
70 | + $result = $result.$indent.'}'; |
|
71 | 71 | return $result; |
72 | 72 | } |
73 | 73 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | case '"': |
87 | 87 | case "\\": |
88 | 88 | case "\n": |
89 | - $result .= "\\" . $char; |
|
89 | + $result .= "\\".$char; |
|
90 | 90 | break; |
91 | 91 | default: |
92 | 92 | if (($char <= chr(0x1F) || $char == chr(0x7F)) && $char != chr(9)) { |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | 'type' => $type, |
35 | 35 | 'format' => 'lua', |
36 | 36 | 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, |
37 | - 'method' => 'serialize' . $type, |
|
37 | + 'method' => 'serialize'.$type, |
|
38 | 38 | ]; |
39 | 39 | } |
40 | 40 | return $methods; |
@@ -93,25 +93,25 @@ discard block |
||
93 | 93 | public function format(\DateInterval $dateInterval) { |
94 | 94 | $format = 'P'; |
95 | 95 | if (0 < $dateInterval->y) { |
96 | - $format .= $dateInterval->y . 'Y'; |
|
96 | + $format .= $dateInterval->y.'Y'; |
|
97 | 97 | } |
98 | 98 | if (0 < $dateInterval->m) { |
99 | - $format .= $dateInterval->m . 'M'; |
|
99 | + $format .= $dateInterval->m.'M'; |
|
100 | 100 | } |
101 | 101 | if (0 < $dateInterval->d) { |
102 | - $format .= $dateInterval->d . 'D'; |
|
102 | + $format .= $dateInterval->d.'D'; |
|
103 | 103 | } |
104 | 104 | if (0 < $dateInterval->h || 0 < $dateInterval->i || 0 < $dateInterval->s) { |
105 | 105 | $format .= 'T'; |
106 | 106 | } |
107 | 107 | if (0 < $dateInterval->h) { |
108 | - $format .= $dateInterval->h . 'H'; |
|
108 | + $format .= $dateInterval->h.'H'; |
|
109 | 109 | } |
110 | 110 | if (0 < $dateInterval->i) { |
111 | - $format .= $dateInterval->i . 'M'; |
|
111 | + $format .= $dateInterval->i.'M'; |
|
112 | 112 | } |
113 | 113 | if (0 < $dateInterval->s) { |
114 | - $format .= $dateInterval->s . 'S'; |
|
114 | + $format .= $dateInterval->s.'S'; |
|
115 | 115 | } |
116 | 116 | return $format; |
117 | 117 | } |
@@ -30,13 +30,13 @@ |
||
30 | 30 | 'direction' => GraphNavigator::DIRECTION_SERIALIZATION, |
31 | 31 | 'type' => $type, |
32 | 32 | 'format' => 'lua', |
33 | - 'method' => 'serialize' . $shortName, |
|
33 | + 'method' => 'serialize'.$shortName, |
|
34 | 34 | ]; |
35 | 35 | $methods[] = [ |
36 | 36 | 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION, |
37 | 37 | 'type' => $type, |
38 | 38 | 'format' => 'lua', |
39 | - 'method' => 'deserialize' . $shortName, |
|
39 | + 'method' => 'deserialize'.$shortName, |
|
40 | 40 | ]; |
41 | 41 | } |
42 | 42 | return $methods; |
@@ -58,6 +58,6 @@ |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | public function error($msg) { |
61 | - throw new ParseException($msg . ' (' . $this->line . ':' . $this->column . ')'); |
|
61 | + throw new ParseException($msg.' ('.$this->line.':'.$this->column.')'); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | \ No newline at end of file |
@@ -237,7 +237,7 @@ |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | public function testAdvancedTable() { |
240 | - $parser = new Parser(new TokenStream(new InputStream(file_get_contents(__DIR__ . '/advanced-test.lua')))); |
|
240 | + $parser = new Parser(new TokenStream(new InputStream(file_get_contents(__DIR__.'/advanced-test.lua')))); |
|
241 | 241 | |
242 | 242 | $parser->parse(); |
243 | 243 | } |
@@ -237,7 +237,7 @@ |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | public function testAdvancedTable() { |
240 | - $parser = new Parser(new TokenStream(new InputStream(file_get_contents(__DIR__ . '/advanced-test.lua')))); |
|
240 | + $parser = new Parser(new TokenStream(new InputStream(file_get_contents(__DIR__.'/advanced-test.lua')))); |
|
241 | 241 | |
242 | 242 | $parser->parse(); |
243 | 243 | } |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | if ($this->isPunctuation($char)) { |
98 | 98 | return $this->readPunctuation(); |
99 | 99 | } |
100 | - $this->input->error('Cannot handle character: ' . $char . ' (ord: ' . ord($char) . ')'); |
|
100 | + $this->input->error('Cannot handle character: '.$char.' (ord: '.ord($char).')'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | protected function skipComment() { |
104 | 104 | $this->readWhile( |
105 | - function ($char) { |
|
105 | + function($char) { |
|
106 | 106 | return $char != "\n"; |
107 | 107 | } |
108 | 108 | ); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $this->input->next(); |
139 | 139 | } |
140 | 140 | if ($this->input->peek() != '[') { |
141 | - $this->error('Unexpected character ' . $this->input->peek() . ', expected ['); |
|
141 | + $this->error('Unexpected character '.$this->input->peek().', expected ['); |
|
142 | 142 | } |
143 | 143 | $this->input->next(); |
144 | 144 | while (!$this->input->eof()) { |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | // we have an equal number of equal signs |
163 | 163 | if ($endNumberOfEqualsSigns == $startNumberOfEqualsSigns) { |
164 | 164 | if ($this->input->peek() != ']') { |
165 | - $this->error('Unexpected character ' . $this->input->peek() . ', expected ['); |
|
165 | + $this->error('Unexpected character '.$this->input->peek().', expected ['); |
|
166 | 166 | } |
167 | 167 | $this->input->next(); |
168 | 168 | break; |
169 | 169 | } else { |
170 | - $str .= $char . str_repeat('=', $endNumberOfEqualsSigns); |
|
170 | + $str .= $char.str_repeat('=', $endNumberOfEqualsSigns); |
|
171 | 171 | } |
172 | 172 | } else { |
173 | 173 | $str .= $char; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | protected function readNumber() { |
223 | 223 | $hasDot = false; |
224 | 224 | $number = $this->readWhile( |
225 | - function ($char) use (&$hasDot) { |
|
225 | + function($char) use (&$hasDot) { |
|
226 | 226 | if ($char == '.') { |
227 | 227 | if ($hasDot) { |
228 | 228 | return false; |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | protected function readIdentifier() { |
243 | 243 | $first = false; |
244 | 244 | $identifier = $this->readWhile( |
245 | - function ($char) use (&$first) { |
|
245 | + function($char) use (&$first) { |
|
246 | 246 | if ($first) { |
247 | 247 | $first = false; |
248 | 248 | return $this->isStartIdentifierCharacter($char); |