@@ -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 = []; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | if ($token->getValue() === 'nil') { |
56 | 56 | return new NilASTNode(); |
57 | 57 | } else { |
58 | - $this->input->error('Unexpected keyword: ' . $token->getValue()); |
|
58 | + $this->input->error('Unexpected keyword: '.$token->getValue()); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 | $this->unexpected(); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | if ($this->isPunctuation($char)) { |
152 | 152 | $this->input->next(); |
153 | 153 | } else { |
154 | - $this->input->error('Expecting punctuation: "' . $char . '"'); |
|
154 | + $this->input->error('Expecting punctuation: "'.$char.'"'); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
@@ -159,6 +159,6 @@ discard block |
||
159 | 159 | * @throws ParseException |
160 | 160 | */ |
161 | 161 | protected function unexpected() { |
162 | - $this->input->error('Unexpected token: ' . json_encode($this->input->peek())); |
|
162 | + $this->input->error('Unexpected token: '.json_encode($this->input->peek())); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | \ No newline at end of file |
@@ -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 | ); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | protected function readNumber() { |
189 | 189 | $hasDot = false; |
190 | 190 | $number = $this->readWhile( |
191 | - function ($char) use (&$hasDot) { |
|
191 | + function($char) use (&$hasDot) { |
|
192 | 192 | if ($char == '.') { |
193 | 193 | if ($hasDot) { |
194 | 194 | return false; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | protected function readIdentifier() { |
209 | 209 | $first = false; |
210 | 210 | $identifier = $this->readWhile( |
211 | - function ($char) use (&$first) { |
|
211 | + function($char) use (&$first) { |
|
212 | 212 | if ($first) { |
213 | 213 | $first = false; |
214 | 214 | return $this->isStartIdentifierCharacter($char); |
@@ -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 | } |