@@ -73,7 +73,7 @@ |
||
73 | 73 | * @param TokensList $list the list of tokens that are being parsed |
74 | 74 | * @param array $options parameters for parsing |
75 | 75 | * |
76 | - * @return component |
|
76 | + * @return Check |
|
77 | 77 | */ |
78 | 78 | public static function parse(Parser $parser, TokensList $list, array $options = array()) |
79 | 79 | { |
@@ -161,7 +161,9 @@ |
||
161 | 161 | if(count($bracketStack) > 1) { |
162 | 162 | array_pop($bracketStack); |
163 | 163 | $state = 2; |
164 | - } else $state = 5; |
|
164 | + } else { |
|
165 | + $state = 5; |
|
166 | + } |
|
165 | 167 | } elseif(in_array($token->value, self::$operatorsArray)) { |
166 | 168 | $ret->operators[] = $token->value; |
167 | 169 | $state = 3; |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | if ($state === 0) { |
132 | 132 | if (($token->type === Token::TYPE_KEYWORD) && $token->keyword === 'CHECK') { |
133 | 133 | $state = 0; |
134 | - } elseif(($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
|
134 | + } elseif (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
|
135 | 135 | $state = 1; |
136 | 136 | array_push($bracketStack, '('); |
137 | 137 | } else { |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | ); |
142 | 142 | return $ret; |
143 | 143 | } |
144 | - } else if($state === 1) { |
|
145 | - if(($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
|
144 | + } else if ($state === 1) { |
|
145 | + if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
|
146 | 146 | array_push($bracketStack, '('); |
147 | 147 | $state = 1; |
148 | - } elseif($token->type === Token::TYPE_OPERATOR) { |
|
148 | + } elseif ($token->type === Token::TYPE_OPERATOR) { |
|
149 | 149 | $parser->error( |
150 | 150 | 'A Column name was expected!', |
151 | 151 | $token |
@@ -156,13 +156,13 @@ discard block |
||
156 | 156 | $state = 2; |
157 | 157 | } |
158 | 158 | } elseif ($state === 2) { |
159 | - if(($token->type === Token::TYPE_OPERATOR) || in_array($token->value, self::$operatorsArray)) { |
|
160 | - if(($token->value === ')')) { |
|
161 | - if(count($bracketStack) > 1) { |
|
159 | + if (($token->type === Token::TYPE_OPERATOR) || in_array($token->value, self::$operatorsArray)) { |
|
160 | + if (($token->value === ')')) { |
|
161 | + if (count($bracketStack) > 1) { |
|
162 | 162 | array_pop($bracketStack); |
163 | 163 | $state = 2; |
164 | 164 | } else $state = 5; |
165 | - } elseif(in_array($token->value, self::$operatorsArray)) { |
|
165 | + } elseif (in_array($token->value, self::$operatorsArray)) { |
|
166 | 166 | $ret->operators[] = $token->value; |
167 | 167 | $state = 3; |
168 | 168 | } else { |
@@ -180,10 +180,10 @@ discard block |
||
180 | 180 | return $ret; |
181 | 181 | } |
182 | 182 | } elseif ($state === 3) { |
183 | - if(($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
|
183 | + if (($token->type === Token::TYPE_OPERATOR) && ($token->value === '(')) { |
|
184 | 184 | $state = 3; |
185 | 185 | array_push($bracketStack, '('); |
186 | - } elseif($token->type === Token::TYPE_OPERATOR) { |
|
186 | + } elseif ($token->type === Token::TYPE_OPERATOR) { |
|
187 | 187 | $parser->error( |
188 | 188 | 'An operand was expected!', |
189 | 189 | $token |
@@ -198,13 +198,13 @@ discard block |
||
198 | 198 | $ret->logicalOperators[] = $token->value; |
199 | 199 | $state = 1; |
200 | 200 | } elseif (($token->type === Token::TYPE_OPERATOR) && ($token->value === ')')) { |
201 | - if(count($bracketStack) === 1) { |
|
201 | + if (count($bracketStack) === 1) { |
|
202 | 202 | $state = 5; |
203 | 203 | } else { |
204 | 204 | array_pop($bracketStack); |
205 | 205 | $state = 4; |
206 | 206 | } |
207 | - } elseif($token->type === Token::TYPE_OPERATOR) { |
|
207 | + } elseif ($token->type === Token::TYPE_OPERATOR) { |
|
208 | 208 | $parser->error( |
209 | 209 | 'Unrecognized token!', |
210 | 210 | $token |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | $operators = $component->operators; |
237 | 237 | $operands = $component->operands; |
238 | 238 | $definition = 'CHECK ('; |
239 | - for($i=0; $i<count($columns); ++$i) { |
|
239 | + for ($i = 0; $i < count($columns); ++$i) { |
|
240 | 240 | $columns[$i] = trim($columns[$i]); |
241 | - if($i>0) { |
|
242 | - $definition .= ' ' . $logical_op[$i-1] . ' '; |
|
241 | + if ($i > 0) { |
|
242 | + $definition .= ' ' . $logical_op[$i - 1] . ' '; |
|
243 | 243 | } |
244 | 244 | $definition .= Context::escape($columns[$i]); |
245 | - if($operators[$i] === 'IS NULL' || $operators[$i] === 'IS NOT NULL') { |
|
245 | + if ($operators[$i] === 'IS NULL' || $operators[$i] === 'IS NOT NULL') { |
|
246 | 246 | $definition .= ' ' . $operators[$i]; |
247 | 247 | } else { |
248 | 248 | $definition .= ' ' . $operators[$i] . ' \'' . $operands[$i] . '\''; |