@@ -611,15 +611,15 @@ |
||
| 611 | 611 | function _hash($data, $controlType) |
| 612 | 612 | { |
| 613 | 613 | switch ($controlType) { |
| 614 | - case 'md5': |
|
| 615 | - return md5($data); |
|
| 616 | - case 'crc32': |
|
| 617 | - return sprintf('% 32d', crc32($data)); |
|
| 618 | - case 'strlen': |
|
| 619 | - return sprintf('% 32d', strlen($data)); |
|
| 620 | - default: |
|
| 621 | - $this->raiseError('Unknown controlType ! '. |
|
| 622 | - '(available values are only \'md5\', \'crc32\', \'strlen\')', -5); |
|
| 614 | + case 'md5': |
|
| 615 | + return md5($data); |
|
| 616 | + case 'crc32': |
|
| 617 | + return sprintf('% 32d', crc32($data)); |
|
| 618 | + case 'strlen': |
|
| 619 | + return sprintf('% 32d', strlen($data)); |
|
| 620 | + default: |
|
| 621 | + $this->raiseError('Unknown controlType ! '. |
|
| 622 | + '(available values are only \'md5\', \'crc32\', \'strlen\')', -5); |
|
| 623 | 623 | } |
| 624 | 624 | } |
| 625 | 625 | |
@@ -22,7 +22,6 @@ |
||
| 22 | 22 | * Get the MessageSource class file. |
| 23 | 23 | */ |
| 24 | 24 | use DOMDocument; |
| 25 | -use DOMXPath; |
|
| 26 | 25 | use Prado\Exceptions\TException; |
| 27 | 26 | use Prado\Exceptions\TIOException; |
| 28 | 27 | |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | |
| 11 | 11 | namespace Prado\Util; |
| 12 | 12 | use Prado\Collections\TList; |
| 13 | -use Prado\Collections\TListIterator; |
|
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * TCallChain is a recursive event calling mechanism. This class implements |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace Prado\Web; |
| 13 | -use Prado\Collections\TMapIterator; |
|
| 14 | 13 | use Prado\Caching\TFileCacheDependency; |
| 15 | 14 | use Prado\Exceptions\TConfigurationException; |
| 16 | 15 | use Prado\Exceptions\TInvalidDataValueException; |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | namespace Prado\Web\UI; |
| 14 | 14 | use Prado\Prado; |
| 15 | 15 | use Prado\TApplicationMode; |
| 16 | -use Prado\Exceptions\TInvalidDataValueException; |
|
| 17 | 16 | use Prado\Exceptions\TInvalidOperationException; |
| 18 | 17 | use Prado\Web\Javascripts\TJavaScript; |
| 19 | 18 | use Prado\Web\UI\ActiveControls\ICallbackEventHandler; |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | use Prado\Collections\TList; |
| 14 | 14 | use Prado\Collections\TMap; |
| 15 | 15 | use Prado\Collections\TStack; |
| 16 | -use Prado\Data\ActiveRecord\TActiveRecord; |
|
| 17 | 16 | use Prado\Exceptions\TConfigurationException; |
| 18 | 17 | use Prado\Exceptions\THttpException; |
| 19 | 18 | use Prado\Exceptions\TInvalidDataValueException; |
@@ -172,118 +172,118 @@ discard block |
||
| 172 | 172 | $ignore = 0; |
| 173 | 173 | |
| 174 | 174 | switch($token[0]) { |
| 175 | - case T_WHITESPACE: |
|
| 176 | - case T_OPEN_TAG: |
|
| 177 | - case T_CLOSE_TAG: |
|
| 178 | - $ignore = 1; |
|
| 179 | - break; |
|
| 180 | - case T_FOREACH: |
|
| 181 | - case T_DO: |
|
| 182 | - case T_WHILE: |
|
| 183 | - case T_FOR: |
|
| 184 | - |
|
| 185 | - case T_IF: |
|
| 186 | - case T_RETURN: |
|
| 187 | - |
|
| 188 | - case T_CLASS: |
|
| 189 | - case T_FUNCTION: |
|
| 190 | - case T_INTERFACE: |
|
| 191 | - |
|
| 192 | - case T_PRINT: |
|
| 193 | - case T_ECHO: |
|
| 194 | - |
|
| 195 | - case T_COMMENT: |
|
| 196 | - case T_UNSET: |
|
| 197 | - |
|
| 198 | - case T_INCLUDE: |
|
| 199 | - case T_REQUIRE: |
|
| 200 | - case T_INCLUDE_ONCE: |
|
| 201 | - case T_REQUIRE_ONCE: |
|
| 202 | - case T_TRY: |
|
| 203 | - case T_SWITCH: |
|
| 204 | - case T_DEFAULT: |
|
| 205 | - case T_CASE: |
|
| 206 | - case T_BREAK: |
|
| 207 | - case T_DOC_COMMENT: |
|
| 208 | - $need_return = 0; |
|
| 209 | - break; |
|
| 210 | - case T_EMPTY: |
|
| 211 | - case T_ISSET: |
|
| 212 | - case T_EVAL: |
|
| 213 | - case T_EXIT: |
|
| 214 | - |
|
| 215 | - case T_VARIABLE: |
|
| 216 | - case T_STRING: |
|
| 217 | - case T_NEW: |
|
| 218 | - case T_EXTENDS: |
|
| 219 | - case T_IMPLEMENTS: |
|
| 220 | - case T_OBJECT_OPERATOR: |
|
| 221 | - case T_DOUBLE_COLON: |
|
| 222 | - case T_INSTANCEOF: |
|
| 223 | - |
|
| 224 | - case T_CATCH: |
|
| 225 | - case T_THROW: |
|
| 226 | - |
|
| 227 | - case T_ELSE: |
|
| 228 | - case T_AS: |
|
| 229 | - case T_LNUMBER: |
|
| 230 | - case T_DNUMBER: |
|
| 231 | - case T_CONSTANT_ENCAPSED_STRING: |
|
| 232 | - case T_ENCAPSED_AND_WHITESPACE: |
|
| 233 | - case T_CHARACTER: |
|
| 234 | - case T_ARRAY: |
|
| 235 | - case T_DOUBLE_ARROW: |
|
| 236 | - |
|
| 237 | - case T_CONST: |
|
| 238 | - case T_PUBLIC: |
|
| 239 | - case T_PROTECTED: |
|
| 240 | - case T_PRIVATE: |
|
| 241 | - case T_ABSTRACT: |
|
| 242 | - case T_STATIC: |
|
| 243 | - case T_VAR: |
|
| 244 | - |
|
| 245 | - case T_INC: |
|
| 246 | - case T_DEC: |
|
| 247 | - case T_SL: |
|
| 248 | - case T_SL_EQUAL: |
|
| 249 | - case T_SR: |
|
| 250 | - case T_SR_EQUAL: |
|
| 251 | - |
|
| 252 | - case T_IS_EQUAL: |
|
| 253 | - case T_IS_IDENTICAL: |
|
| 254 | - case T_IS_GREATER_OR_EQUAL: |
|
| 255 | - case T_IS_SMALLER_OR_EQUAL: |
|
| 256 | - |
|
| 257 | - case T_BOOLEAN_OR: |
|
| 258 | - case T_LOGICAL_OR: |
|
| 259 | - case T_BOOLEAN_AND: |
|
| 260 | - case T_LOGICAL_AND: |
|
| 261 | - case T_LOGICAL_XOR: |
|
| 262 | - case T_MINUS_EQUAL: |
|
| 263 | - case T_PLUS_EQUAL: |
|
| 264 | - case T_MUL_EQUAL: |
|
| 265 | - case T_DIV_EQUAL: |
|
| 266 | - case T_MOD_EQUAL: |
|
| 267 | - case T_XOR_EQUAL: |
|
| 268 | - case T_AND_EQUAL: |
|
| 269 | - case T_OR_EQUAL: |
|
| 270 | - |
|
| 271 | - case T_FUNC_C: |
|
| 272 | - case T_CLASS_C: |
|
| 273 | - case T_LINE: |
|
| 274 | - case T_FILE: |
|
| 275 | - |
|
| 276 | - case T_BOOL_CAST: |
|
| 277 | - case T_INT_CAST: |
|
| 278 | - case T_STRING_CAST: |
|
| 279 | - |
|
| 280 | - /* just go on */ |
|
| 281 | - break; |
|
| 282 | - default: |
|
| 283 | - /* debug unknown tags*/ |
|
| 284 | - error_log(sprintf("unknown tag: %d (%s): %s".PHP_EOL, $token[0], token_name($token[0]), $token[1])); |
|
| 285 | - |
|
| 286 | - break; |
|
| 175 | + case T_WHITESPACE: |
|
| 176 | + case T_OPEN_TAG: |
|
| 177 | + case T_CLOSE_TAG: |
|
| 178 | + $ignore = 1; |
|
| 179 | + break; |
|
| 180 | + case T_FOREACH: |
|
| 181 | + case T_DO: |
|
| 182 | + case T_WHILE: |
|
| 183 | + case T_FOR: |
|
| 184 | + |
|
| 185 | + case T_IF: |
|
| 186 | + case T_RETURN: |
|
| 187 | + |
|
| 188 | + case T_CLASS: |
|
| 189 | + case T_FUNCTION: |
|
| 190 | + case T_INTERFACE: |
|
| 191 | + |
|
| 192 | + case T_PRINT: |
|
| 193 | + case T_ECHO: |
|
| 194 | + |
|
| 195 | + case T_COMMENT: |
|
| 196 | + case T_UNSET: |
|
| 197 | + |
|
| 198 | + case T_INCLUDE: |
|
| 199 | + case T_REQUIRE: |
|
| 200 | + case T_INCLUDE_ONCE: |
|
| 201 | + case T_REQUIRE_ONCE: |
|
| 202 | + case T_TRY: |
|
| 203 | + case T_SWITCH: |
|
| 204 | + case T_DEFAULT: |
|
| 205 | + case T_CASE: |
|
| 206 | + case T_BREAK: |
|
| 207 | + case T_DOC_COMMENT: |
|
| 208 | + $need_return = 0; |
|
| 209 | + break; |
|
| 210 | + case T_EMPTY: |
|
| 211 | + case T_ISSET: |
|
| 212 | + case T_EVAL: |
|
| 213 | + case T_EXIT: |
|
| 214 | + |
|
| 215 | + case T_VARIABLE: |
|
| 216 | + case T_STRING: |
|
| 217 | + case T_NEW: |
|
| 218 | + case T_EXTENDS: |
|
| 219 | + case T_IMPLEMENTS: |
|
| 220 | + case T_OBJECT_OPERATOR: |
|
| 221 | + case T_DOUBLE_COLON: |
|
| 222 | + case T_INSTANCEOF: |
|
| 223 | + |
|
| 224 | + case T_CATCH: |
|
| 225 | + case T_THROW: |
|
| 226 | + |
|
| 227 | + case T_ELSE: |
|
| 228 | + case T_AS: |
|
| 229 | + case T_LNUMBER: |
|
| 230 | + case T_DNUMBER: |
|
| 231 | + case T_CONSTANT_ENCAPSED_STRING: |
|
| 232 | + case T_ENCAPSED_AND_WHITESPACE: |
|
| 233 | + case T_CHARACTER: |
|
| 234 | + case T_ARRAY: |
|
| 235 | + case T_DOUBLE_ARROW: |
|
| 236 | + |
|
| 237 | + case T_CONST: |
|
| 238 | + case T_PUBLIC: |
|
| 239 | + case T_PROTECTED: |
|
| 240 | + case T_PRIVATE: |
|
| 241 | + case T_ABSTRACT: |
|
| 242 | + case T_STATIC: |
|
| 243 | + case T_VAR: |
|
| 244 | + |
|
| 245 | + case T_INC: |
|
| 246 | + case T_DEC: |
|
| 247 | + case T_SL: |
|
| 248 | + case T_SL_EQUAL: |
|
| 249 | + case T_SR: |
|
| 250 | + case T_SR_EQUAL: |
|
| 251 | + |
|
| 252 | + case T_IS_EQUAL: |
|
| 253 | + case T_IS_IDENTICAL: |
|
| 254 | + case T_IS_GREATER_OR_EQUAL: |
|
| 255 | + case T_IS_SMALLER_OR_EQUAL: |
|
| 256 | + |
|
| 257 | + case T_BOOLEAN_OR: |
|
| 258 | + case T_LOGICAL_OR: |
|
| 259 | + case T_BOOLEAN_AND: |
|
| 260 | + case T_LOGICAL_AND: |
|
| 261 | + case T_LOGICAL_XOR: |
|
| 262 | + case T_MINUS_EQUAL: |
|
| 263 | + case T_PLUS_EQUAL: |
|
| 264 | + case T_MUL_EQUAL: |
|
| 265 | + case T_DIV_EQUAL: |
|
| 266 | + case T_MOD_EQUAL: |
|
| 267 | + case T_XOR_EQUAL: |
|
| 268 | + case T_AND_EQUAL: |
|
| 269 | + case T_OR_EQUAL: |
|
| 270 | + |
|
| 271 | + case T_FUNC_C: |
|
| 272 | + case T_CLASS_C: |
|
| 273 | + case T_LINE: |
|
| 274 | + case T_FILE: |
|
| 275 | + |
|
| 276 | + case T_BOOL_CAST: |
|
| 277 | + case T_INT_CAST: |
|
| 278 | + case T_STRING_CAST: |
|
| 279 | + |
|
| 280 | + /* just go on */ |
|
| 281 | + break; |
|
| 282 | + default: |
|
| 283 | + /* debug unknown tags*/ |
|
| 284 | + error_log(sprintf("unknown tag: %d (%s): %s".PHP_EOL, $token[0], token_name($token[0]), $token[1])); |
|
| 285 | + |
|
| 286 | + break; |
|
| 287 | 287 | } |
| 288 | 288 | if (!$ignore) { |
| 289 | 289 | $eval .= $token[1]." "; |
@@ -295,356 +295,356 @@ discard block |
||
| 295 | 295 | $last = count($ts) - 1; |
| 296 | 296 | |
| 297 | 297 | switch ($token) { |
| 298 | - case '(': |
|
| 299 | - /* walk backwards through the tokens */ |
|
| 300 | - |
|
| 301 | - if ($last >= 4 && |
|
| 302 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 303 | - $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && |
|
| 304 | - $ts[$last - 3]['token'] == ')' ) { |
|
| 305 | - /* func()->method() |
|
| 298 | + case '(': |
|
| 299 | + /* walk backwards through the tokens */ |
|
| 300 | + |
|
| 301 | + if ($last >= 4 && |
|
| 302 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 303 | + $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && |
|
| 304 | + $ts[$last - 3]['token'] == ')' ) { |
|
| 305 | + /* func()->method() |
|
| 306 | 306 | * |
| 307 | 307 | * we can't know what func() is return, so we can't |
| 308 | 308 | * say if the method() exists or not |
| 309 | 309 | * |
| 310 | 310 | */ |
| 311 | - } else if ($last >= 3 && |
|
| 312 | - $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 313 | - $ts[0]['token'] != T_ABSTRACT && /* if we are not in a class definition */ |
|
| 314 | - $ts[1]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 315 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 316 | - $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && |
|
| 317 | - $ts[$last - 3]['token'] == T_VARIABLE ) { |
|
| 318 | - |
|
| 319 | - /* $object->method( */ |
|
| 320 | - |
|
| 321 | - /* catch (Exception $e) does not set $e in $GLOBALS[] */ |
|
| 322 | - $in_catch = 0; |
|
| 323 | - |
|
| 324 | - foreach ($ts as $v) { |
|
| 325 | - if ($v['token'] == T_CATCH) { |
|
| 326 | - $in_catch = 1; |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - if (!$in_catch) { |
|
| 331 | - /* $object has to exist and has to be a object */ |
|
| 332 | - $objname = $ts[$last - 3]['value']; |
|
| 333 | - |
|
| 334 | - if (!isset($GLOBALS[ltrim($objname, '$')])) { |
|
| 335 | - throw new Exception(sprintf('Variable \'%s\' is not set', $objname)); |
|
| 336 | - } |
|
| 337 | - $object = $GLOBALS[ltrim($objname, '$')]; |
|
| 338 | - |
|
| 339 | - if (!is_object($object)) { |
|
| 340 | - throw new Exception(sprintf('Variable \'%s\' is not a class', $objname)); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - $method = $ts[$last - 1]['value']; |
|
| 344 | - |
|
| 345 | - /* obj */ |
|
| 311 | + } else if ($last >= 3 && |
|
| 312 | + $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 313 | + $ts[0]['token'] != T_ABSTRACT && /* if we are not in a class definition */ |
|
| 314 | + $ts[1]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 315 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 316 | + $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && |
|
| 317 | + $ts[$last - 3]['token'] == T_VARIABLE ) { |
|
| 318 | + |
|
| 319 | + /* $object->method( */ |
|
| 346 | 320 | |
| 347 | - if (!method_exists($object, $method)) { |
|
| 348 | - throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", |
|
| 349 | - $objname, get_class($object), $method)); |
|
| 350 | - } |
|
| 351 | - } |
|
| 352 | - } else if ($last >= 3 && |
|
| 353 | - $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 354 | - $ts[$last - 1]['token'] == T_VARIABLE && |
|
| 355 | - $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && |
|
| 356 | - $ts[$last - 3]['token'] == T_VARIABLE ) { |
|
| 321 | + /* catch (Exception $e) does not set $e in $GLOBALS[] */ |
|
| 322 | + $in_catch = 0; |
|
| 357 | 323 | |
| 358 | - /* $object->$method( */ |
|
| 324 | + foreach ($ts as $v) { |
|
| 325 | + if ($v['token'] == T_CATCH) { |
|
| 326 | + $in_catch = 1; |
|
| 327 | + } |
|
| 328 | + } |
|
| 359 | 329 | |
| 360 | - /* $object has to exist and has to be a object */ |
|
| 361 | - $objname = $ts[$last - 3]['value']; |
|
| 330 | + if (!$in_catch) { |
|
| 331 | + /* $object has to exist and has to be a object */ |
|
| 332 | + $objname = $ts[$last - 3]['value']; |
|
| 362 | 333 | |
| 363 | - if (!isset($GLOBALS[ltrim($objname, '$')])) { |
|
| 364 | - throw new Exception(sprintf('Variable \'%s\' is not set', $objname)); |
|
| 365 | - } |
|
| 366 | - $object = $GLOBALS[ltrim($objname, '$')]; |
|
| 334 | + if (!isset($GLOBALS[ltrim($objname, '$')])) { |
|
| 335 | + throw new Exception(sprintf('Variable \'%s\' is not set', $objname)); |
|
| 336 | + } |
|
| 337 | + $object = $GLOBALS[ltrim($objname, '$')]; |
|
| 367 | 338 | |
| 368 | - if (!is_object($object)) { |
|
| 369 | - throw new Exception(sprintf('Variable \'%s\' is not a class', $objname)); |
|
| 370 | - } |
|
| 339 | + if (!is_object($object)) { |
|
| 340 | + throw new Exception(sprintf('Variable \'%s\' is not a class', $objname)); |
|
| 341 | + } |
|
| 371 | 342 | |
| 372 | - $methodname = $ts[$last - 1]['value']; |
|
| 343 | + $method = $ts[$last - 1]['value']; |
|
| 373 | 344 | |
| 374 | - if (!isset($GLOBALS[ltrim($methodname, '$')])) { |
|
| 375 | - throw new Exception(sprintf('Variable \'%s\' is not set', $methodname)); |
|
| 376 | - } |
|
| 377 | - $method = $GLOBALS[ltrim($methodname, '$')]; |
|
| 345 | + /* obj */ |
|
| 378 | 346 | |
| 379 | - /* obj */ |
|
| 347 | + if (!method_exists($object, $method)) { |
|
| 348 | + throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", |
|
| 349 | + $objname, get_class($object), $method)); |
|
| 350 | + } |
|
| 351 | + } |
|
| 352 | + } else if ($last >= 3 && |
|
| 353 | + $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 354 | + $ts[$last - 1]['token'] == T_VARIABLE && |
|
| 355 | + $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && |
|
| 356 | + $ts[$last - 3]['token'] == T_VARIABLE ) { |
|
| 380 | 357 | |
| 381 | - if (!method_exists($object, $method)) { |
|
| 382 | - throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", |
|
| 383 | - $objname, get_class($object), $method)); |
|
| 384 | - } |
|
| 358 | + /* $object->$method( */ |
|
| 385 | 359 | |
| 386 | - } else if ($last >= 6 && |
|
| 387 | - $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 388 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 389 | - $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && |
|
| 390 | - $ts[$last - 3]['token'] == ']' && |
|
| 391 | - /* might be anything as index */ |
|
| 392 | - $ts[$last - 5]['token'] == '[' && |
|
| 393 | - $ts[$last - 6]['token'] == T_VARIABLE ) { |
|
| 360 | + /* $object has to exist and has to be a object */ |
|
| 361 | + $objname = $ts[$last - 3]['value']; |
|
| 394 | 362 | |
| 395 | - /* $object[...]->method( */ |
|
| 363 | + if (!isset($GLOBALS[ltrim($objname, '$')])) { |
|
| 364 | + throw new Exception(sprintf('Variable \'%s\' is not set', $objname)); |
|
| 365 | + } |
|
| 366 | + $object = $GLOBALS[ltrim($objname, '$')]; |
|
| 396 | 367 | |
| 397 | - /* $object has to exist and has to be a object */ |
|
| 398 | - $objname = $ts[$last - 6]['value']; |
|
| 368 | + if (!is_object($object)) { |
|
| 369 | + throw new Exception(sprintf('Variable \'%s\' is not a class', $objname)); |
|
| 370 | + } |
|
| 399 | 371 | |
| 400 | - if (!isset($GLOBALS[ltrim($objname, '$')])) { |
|
| 401 | - throw new Exception(sprintf('Variable \'%s\' is not set', $objname)); |
|
| 402 | - } |
|
| 403 | - $array = $GLOBALS[ltrim($objname, '$')]; |
|
| 372 | + $methodname = $ts[$last - 1]['value']; |
|
| 404 | 373 | |
| 405 | - if (!is_array($array)) { |
|
| 406 | - throw new Exception(sprintf('Variable \'%s\' is not a array', $objname)); |
|
| 407 | - } |
|
| 374 | + if (!isset($GLOBALS[ltrim($methodname, '$')])) { |
|
| 375 | + throw new Exception(sprintf('Variable \'%s\' is not set', $methodname)); |
|
| 376 | + } |
|
| 377 | + $method = $GLOBALS[ltrim($methodname, '$')]; |
|
| 408 | 378 | |
| 409 | - $andx = $ts[$last - 4]['value']; |
|
| 379 | + /* obj */ |
|
| 410 | 380 | |
| 411 | - if (!isset($array[$andx])) { |
|
| 412 | - throw new Exception(sprintf('%s[\'%s\'] is not set', $objname, $andx)); |
|
| 413 | - } |
|
| 381 | + if (!method_exists($object, $method)) { |
|
| 382 | + throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", |
|
| 383 | + $objname, get_class($object), $method)); |
|
| 384 | + } |
|
| 414 | 385 | |
| 415 | - $object = $array[$andx]; |
|
| 386 | + } else if ($last >= 6 && |
|
| 387 | + $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 388 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 389 | + $ts[$last - 2]['token'] == T_OBJECT_OPERATOR && |
|
| 390 | + $ts[$last - 3]['token'] == ']' && |
|
| 391 | + /* might be anything as index */ |
|
| 392 | + $ts[$last - 5]['token'] == '[' && |
|
| 393 | + $ts[$last - 6]['token'] == T_VARIABLE ) { |
|
| 416 | 394 | |
| 417 | - if (!is_object($object)) { |
|
| 418 | - throw new Exception(sprintf('Variable \'%s\' is not a class', $objname)); |
|
| 419 | - } |
|
| 395 | + /* $object[...]->method( */ |
|
| 420 | 396 | |
| 421 | - $method = $ts[$last - 1]['value']; |
|
| 397 | + /* $object has to exist and has to be a object */ |
|
| 398 | + $objname = $ts[$last - 6]['value']; |
|
| 422 | 399 | |
| 423 | - /* obj */ |
|
| 400 | + if (!isset($GLOBALS[ltrim($objname, '$')])) { |
|
| 401 | + throw new Exception(sprintf('Variable \'%s\' is not set', $objname)); |
|
| 402 | + } |
|
| 403 | + $array = $GLOBALS[ltrim($objname, '$')]; |
|
| 424 | 404 | |
| 425 | - if (!method_exists($object, $method)) { |
|
| 426 | - throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", |
|
| 427 | - $objname, get_class($object), $method)); |
|
| 428 | - } |
|
| 405 | + if (!is_array($array)) { |
|
| 406 | + throw new Exception(sprintf('Variable \'%s\' is not a array', $objname)); |
|
| 407 | + } |
|
| 429 | 408 | |
| 430 | - } else if ($last >= 3 && |
|
| 431 | - $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 432 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 433 | - $ts[$last - 2]['token'] == T_DOUBLE_COLON && |
|
| 434 | - $ts[$last - 3]['token'] == T_STRING ) { |
|
| 409 | + $andx = $ts[$last - 4]['value']; |
|
| 435 | 410 | |
| 436 | - /* Class::method() */ |
|
| 411 | + if (!isset($array[$andx])) { |
|
| 412 | + throw new Exception(sprintf('%s[\'%s\'] is not set', $objname, $andx)); |
|
| 413 | + } |
|
| 437 | 414 | |
| 438 | - /* $object has to exist and has to be a object */ |
|
| 439 | - $classname = $ts[$last - 3]['value']; |
|
| 415 | + $object = $array[$andx]; |
|
| 440 | 416 | |
| 441 | - if (!class_exists($classname)) { |
|
| 442 | - throw new Exception(sprintf('Class \'%s\' doesn\'t exist', $classname)); |
|
| 443 | - } |
|
| 417 | + if (!is_object($object)) { |
|
| 418 | + throw new Exception(sprintf('Variable \'%s\' is not a class', $objname)); |
|
| 419 | + } |
|
| 444 | 420 | |
| 445 | - $method = $ts[$last - 1]['value']; |
|
| 421 | + $method = $ts[$last - 1]['value']; |
|
| 446 | 422 | |
| 447 | - if (!in_array($method, get_class_methods($classname))) { |
|
| 448 | - throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'", |
|
| 449 | - $classname, $method)); |
|
| 450 | - } |
|
| 451 | - } else if ($last >= 3 && |
|
| 452 | - $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 453 | - $ts[$last - 1]['token'] == T_VARIABLE && |
|
| 454 | - $ts[$last - 2]['token'] == T_DOUBLE_COLON && |
|
| 455 | - $ts[$last - 3]['token'] == T_STRING ) { |
|
| 423 | + /* obj */ |
|
| 456 | 424 | |
| 457 | - /* $var::method() */ |
|
| 425 | + if (!method_exists($object, $method)) { |
|
| 426 | + throw new Exception(sprintf("Variable %s (Class '%s') doesn't have a method named '%s'", |
|
| 427 | + $objname, get_class($object), $method)); |
|
| 428 | + } |
|
| 458 | 429 | |
| 459 | - /* $object has to exist and has to be a object */ |
|
| 460 | - $classname = $ts[$last - 3]['value']; |
|
| 430 | + } else if ($last >= 3 && |
|
| 431 | + $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 432 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 433 | + $ts[$last - 2]['token'] == T_DOUBLE_COLON && |
|
| 434 | + $ts[$last - 3]['token'] == T_STRING ) { |
|
| 461 | 435 | |
| 462 | - if (!class_exists($classname)) { |
|
| 463 | - throw new Exception(sprintf('Class \'%s\' doesn\'t exist', $classname)); |
|
| 464 | - } |
|
| 436 | + /* Class::method() */ |
|
| 465 | 437 | |
| 466 | - $methodname = $ts[$last - 1]['value']; |
|
| 438 | + /* $object has to exist and has to be a object */ |
|
| 439 | + $classname = $ts[$last - 3]['value']; |
|
| 467 | 440 | |
| 468 | - if (!isset($GLOBALS[ltrim($methodname, '$')])) { |
|
| 469 | - throw new Exception(sprintf('Variable \'%s\' is not set', $methodname)); |
|
| 470 | - } |
|
| 471 | - $method = $GLOBALS[ltrim($methodname, '$')]; |
|
| 441 | + if (!class_exists($classname)) { |
|
| 442 | + throw new Exception(sprintf('Class \'%s\' doesn\'t exist', $classname)); |
|
| 443 | + } |
|
| 472 | 444 | |
| 473 | - if (!in_array($method, get_class_methods($classname))) { |
|
| 474 | - throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'", |
|
| 475 | - $classname, $method)); |
|
| 476 | - } |
|
| 445 | + $method = $ts[$last - 1]['value']; |
|
| 477 | 446 | |
| 478 | - } else if ($last >= 2 && |
|
| 479 | - $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 480 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 481 | - $ts[$last - 2]['token'] == T_NEW ) { |
|
| 447 | + if (!in_array($method, get_class_methods($classname))) { |
|
| 448 | + throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'", |
|
| 449 | + $classname, $method)); |
|
| 450 | + } |
|
| 451 | + } else if ($last >= 3 && |
|
| 452 | + $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 453 | + $ts[$last - 1]['token'] == T_VARIABLE && |
|
| 454 | + $ts[$last - 2]['token'] == T_DOUBLE_COLON && |
|
| 455 | + $ts[$last - 3]['token'] == T_STRING ) { |
|
| 482 | 456 | |
| 483 | - /* new Class() */ |
|
| 457 | + /* $var::method() */ |
|
| 484 | 458 | |
| 485 | - /* don't care about this in a class ... { ... } */ |
|
| 459 | + /* $object has to exist and has to be a object */ |
|
| 460 | + $classname = $ts[$last - 3]['value']; |
|
| 486 | 461 | |
| 487 | - $classname = $ts[$last - 1]['value']; |
|
| 462 | + if (!class_exists($classname)) { |
|
| 463 | + throw new Exception(sprintf('Class \'%s\' doesn\'t exist', $classname)); |
|
| 464 | + } |
|
| 488 | 465 | |
| 489 | - if (!class_exists($classname)) { |
|
| 490 | - throw new Exception(sprintf('Class \'%s\' doesn\'t exist', $classname)); |
|
| 491 | - } |
|
| 466 | + $methodname = $ts[$last - 1]['value']; |
|
| 492 | 467 | |
| 493 | - $r = new ReflectionClass($classname); |
|
| 468 | + if (!isset($GLOBALS[ltrim($methodname, '$')])) { |
|
| 469 | + throw new Exception(sprintf('Variable \'%s\' is not set', $methodname)); |
|
| 470 | + } |
|
| 471 | + $method = $GLOBALS[ltrim($methodname, '$')]; |
|
| 494 | 472 | |
| 495 | - if ($r->isAbstract()) { |
|
| 496 | - throw new Exception(sprintf("Can't instantiate abstract Class '%s'", $classname)); |
|
| 497 | - } |
|
| 473 | + if (!in_array($method, get_class_methods($classname))) { |
|
| 474 | + throw new Exception(sprintf("Class '%s' doesn't have a method named '%s'", |
|
| 475 | + $classname, $method)); |
|
| 476 | + } |
|
| 498 | 477 | |
| 499 | - if (!$r->isInstantiable()) { |
|
| 500 | - throw new Exception(sprintf('Class \'%s\' can\'t be instantiated. Is the class abstract ?', $classname)); |
|
| 501 | - } |
|
| 478 | + } else if ($last >= 2 && |
|
| 479 | + $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 480 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 481 | + $ts[$last - 2]['token'] == T_NEW ) { |
|
| 502 | 482 | |
| 503 | - } else if ($last >= 2 && |
|
| 504 | - $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 505 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 506 | - $ts[$last - 2]['token'] == T_FUNCTION ) { |
|
| 483 | + /* new Class() */ |
|
| 507 | 484 | |
| 508 | - /* make sure we are not a in class definition */ |
|
| 485 | + /* don't care about this in a class ... { ... } */ |
|
| 509 | 486 | |
| 510 | - /* function a() */ |
|
| 487 | + $classname = $ts[$last - 1]['value']; |
|
| 511 | 488 | |
| 512 | - $func = $ts[$last - 1]['value']; |
|
| 489 | + if (!class_exists($classname)) { |
|
| 490 | + throw new Exception(sprintf('Class \'%s\' doesn\'t exist', $classname)); |
|
| 491 | + } |
|
| 513 | 492 | |
| 514 | - if (function_exists($func)) { |
|
| 515 | - throw new Exception(sprintf('Function \'%s\' is already defined', $func)); |
|
| 516 | - } |
|
| 517 | - } else if ($last >= 4 && |
|
| 518 | - $ts[0]['token'] == T_CLASS && |
|
| 519 | - $ts[1]['token'] == T_STRING && |
|
| 520 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 521 | - $ts[$last - 2]['token'] == T_FUNCTION ) { |
|
| 493 | + $r = new ReflectionClass($classname); |
|
| 522 | 494 | |
| 523 | - /* make sure we are not a in class definition */ |
|
| 495 | + if ($r->isAbstract()) { |
|
| 496 | + throw new Exception(sprintf("Can't instantiate abstract Class '%s'", $classname)); |
|
| 497 | + } |
|
| 524 | 498 | |
| 525 | - /* class a { .. function a() ... } */ |
|
| 499 | + if (!$r->isInstantiable()) { |
|
| 500 | + throw new Exception(sprintf('Class \'%s\' can\'t be instantiated. Is the class abstract ?', $classname)); |
|
| 501 | + } |
|
| 526 | 502 | |
| 527 | - $func = $ts[$last - 1]['value']; |
|
| 528 | - $classname = $ts[1]['value']; |
|
| 503 | + } else if ($last >= 2 && |
|
| 504 | + $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 505 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 506 | + $ts[$last - 2]['token'] == T_FUNCTION ) { |
|
| 529 | 507 | |
| 530 | - if (isset($methods[$func])) { |
|
| 531 | - throw new Exception(sprintf("Can't redeclare method '%s' in Class '%s'", $func, $classname)); |
|
| 532 | - } |
|
| 508 | + /* make sure we are not a in class definition */ |
|
| 533 | 509 | |
| 534 | - $methods[$func] = 1; |
|
| 510 | + /* function a() */ |
|
| 535 | 511 | |
| 536 | - } else if ($last >= 1 && |
|
| 537 | - $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 538 | - $ts[0]['token'] != T_ABSTRACT && /* if we are not in a class definition */ |
|
| 539 | - $ts[1]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 540 | - $ts[$last - 1]['token'] == T_STRING ) { |
|
| 541 | - /* func() */ |
|
| 542 | - $funcname = $ts[$last - 1]['value']; |
|
| 512 | + $func = $ts[$last - 1]['value']; |
|
| 543 | 513 | |
| 544 | - if (!function_exists($funcname)) { |
|
| 545 | - throw new Exception(sprintf("Function %s() doesn't exist", $funcname)); |
|
| 546 | - } |
|
| 547 | - } else if ($last >= 1 && |
|
| 548 | - $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 549 | - $ts[$last - 1]['token'] == T_VARIABLE ) { |
|
| 514 | + if (function_exists($func)) { |
|
| 515 | + throw new Exception(sprintf('Function \'%s\' is already defined', $func)); |
|
| 516 | + } |
|
| 517 | + } else if ($last >= 4 && |
|
| 518 | + $ts[0]['token'] == T_CLASS && |
|
| 519 | + $ts[1]['token'] == T_STRING && |
|
| 520 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 521 | + $ts[$last - 2]['token'] == T_FUNCTION ) { |
|
| 550 | 522 | |
| 551 | - /* $object has to exist and has to be a object */ |
|
| 552 | - $funcname = $ts[$last - 1]['value']; |
|
| 553 | - |
|
| 554 | - if (!isset($GLOBALS[ltrim($funcname, '$')])) { |
|
| 555 | - throw new Exception(sprintf('Variable \'%s\' is not set', $funcname)); |
|
| 556 | - } |
|
| 557 | - $func = $GLOBALS[ltrim($funcname, '$')]; |
|
| 558 | - |
|
| 559 | - if (!function_exists($func)) { |
|
| 560 | - throw new Exception(sprintf("Function %s() doesn't exist", $func)); |
|
| 561 | - } |
|
| 562 | - |
|
| 563 | - } |
|
| 564 | - |
|
| 565 | - array_push($braces, $token); |
|
| 566 | - break; |
|
| 567 | - case '{': |
|
| 568 | - $need_return = 0; |
|
| 569 | - |
|
| 570 | - if ($last >= 2 && |
|
| 571 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 572 | - $ts[$last - 2]['token'] == T_CLASS ) { |
|
| 573 | - |
|
| 574 | - /* class name { */ |
|
| 575 | - |
|
| 576 | - $classname = $ts[$last - 1]['value']; |
|
| 577 | - |
|
| 578 | - if (class_exists($classname, false)) { |
|
| 579 | - throw new Exception(sprintf("Class '%s' can't be redeclared", $classname)); |
|
| 580 | - } |
|
| 581 | - } else if ($last >= 4 && |
|
| 582 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 583 | - $ts[$last - 2]['token'] == T_EXTENDS && |
|
| 584 | - $ts[$last - 3]['token'] == T_STRING && |
|
| 585 | - $ts[$last - 4]['token'] == T_CLASS ) { |
|
| 586 | - |
|
| 587 | - /* class classname extends classname { */ |
|
| 588 | - |
|
| 589 | - $classname = $ts[$last - 3]['value']; |
|
| 590 | - $extendsname = $ts[$last - 1]['value']; |
|
| 591 | - |
|
| 592 | - if (class_exists($classname, false)) { |
|
| 593 | - throw new Exception(sprintf("Class '%s' can't be redeclared", |
|
| 594 | - $classname)); |
|
| 595 | - } |
|
| 596 | - if (!class_exists($extendsname, true)) { |
|
| 597 | - throw new Exception(sprintf("Can't extend '%s' ... from not existing Class '%s'", |
|
| 598 | - $classname, $extendsname)); |
|
| 599 | - } |
|
| 600 | - } else if ($last >= 4 && |
|
| 601 | - $ts[$last - 1]['token'] == T_STRING && |
|
| 602 | - $ts[$last - 2]['token'] == T_IMPLEMENTS && |
|
| 603 | - $ts[$last - 3]['token'] == T_STRING && |
|
| 604 | - $ts[$last - 4]['token'] == T_CLASS ) { |
|
| 605 | - |
|
| 606 | - /* class name implements interface { */ |
|
| 607 | - |
|
| 608 | - $classname = $ts[$last - 3]['value']; |
|
| 609 | - $implements = $ts[$last - 1]['value']; |
|
| 610 | - |
|
| 611 | - if (class_exists($classname, false)) { |
|
| 612 | - throw new Exception(sprintf("Class '%s' can't be redeclared", |
|
| 613 | - $classname)); |
|
| 614 | - } |
|
| 615 | - if (!interface_exists($implements, false)) { |
|
| 616 | - throw new Exception(sprintf("Can't implement not existing Interface '%s' for Class '%s'", |
|
| 617 | - $implements, $classname)); |
|
| 618 | - } |
|
| 619 | - } |
|
| 620 | - |
|
| 621 | - array_push($braces, $token); |
|
| 622 | - break; |
|
| 623 | - case '}': |
|
| 624 | - $need_return = 0; |
|
| 625 | - case ')': |
|
| 626 | - array_pop($braces); |
|
| 627 | - break; |
|
| 628 | - case '[': |
|
| 629 | - if ($ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 630 | - $ts[0]['token'] != T_ABSTRACT && /* if we are not in a class definition */ |
|
| 631 | - $ts[1]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 632 | - $ts[$last - 1]['token'] == T_VARIABLE) { |
|
| 633 | - /* $a[] only works on array and string */ |
|
| 634 | - |
|
| 635 | - /* $object has to exist and has to be a object */ |
|
| 636 | - $objname = $ts[$last - 1]['value']; |
|
| 637 | - |
|
| 638 | - if (!isset($GLOBALS[ltrim($objname, '$')])) { |
|
| 639 | - throw new Exception(sprintf('Variable \'%s\' is not set', $objname)); |
|
| 640 | - } |
|
| 641 | - $obj = $GLOBALS[ltrim($objname, '$')]; |
|
| 642 | - |
|
| 643 | - if (is_object($obj)) { |
|
| 644 | - throw new Exception(sprintf('Objects (%s) don\'t support array access operators', $objname)); |
|
| 645 | - } |
|
| 646 | - } |
|
| 647 | - break; |
|
| 523 | + /* make sure we are not a in class definition */ |
|
| 524 | + |
|
| 525 | + /* class a { .. function a() ... } */ |
|
| 526 | + |
|
| 527 | + $func = $ts[$last - 1]['value']; |
|
| 528 | + $classname = $ts[1]['value']; |
|
| 529 | + |
|
| 530 | + if (isset($methods[$func])) { |
|
| 531 | + throw new Exception(sprintf("Can't redeclare method '%s' in Class '%s'", $func, $classname)); |
|
| 532 | + } |
|
| 533 | + |
|
| 534 | + $methods[$func] = 1; |
|
| 535 | + |
|
| 536 | + } else if ($last >= 1 && |
|
| 537 | + $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 538 | + $ts[0]['token'] != T_ABSTRACT && /* if we are not in a class definition */ |
|
| 539 | + $ts[1]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 540 | + $ts[$last - 1]['token'] == T_STRING ) { |
|
| 541 | + /* func() */ |
|
| 542 | + $funcname = $ts[$last - 1]['value']; |
|
| 543 | + |
|
| 544 | + if (!function_exists($funcname)) { |
|
| 545 | + throw new Exception(sprintf("Function %s() doesn't exist", $funcname)); |
|
| 546 | + } |
|
| 547 | + } else if ($last >= 1 && |
|
| 548 | + $ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 549 | + $ts[$last - 1]['token'] == T_VARIABLE ) { |
|
| 550 | + |
|
| 551 | + /* $object has to exist and has to be a object */ |
|
| 552 | + $funcname = $ts[$last - 1]['value']; |
|
| 553 | + |
|
| 554 | + if (!isset($GLOBALS[ltrim($funcname, '$')])) { |
|
| 555 | + throw new Exception(sprintf('Variable \'%s\' is not set', $funcname)); |
|
| 556 | + } |
|
| 557 | + $func = $GLOBALS[ltrim($funcname, '$')]; |
|
| 558 | + |
|
| 559 | + if (!function_exists($func)) { |
|
| 560 | + throw new Exception(sprintf("Function %s() doesn't exist", $func)); |
|
| 561 | + } |
|
| 562 | + |
|
| 563 | + } |
|
| 564 | + |
|
| 565 | + array_push($braces, $token); |
|
| 566 | + break; |
|
| 567 | + case '{': |
|
| 568 | + $need_return = 0; |
|
| 569 | + |
|
| 570 | + if ($last >= 2 && |
|
| 571 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 572 | + $ts[$last - 2]['token'] == T_CLASS ) { |
|
| 573 | + |
|
| 574 | + /* class name { */ |
|
| 575 | + |
|
| 576 | + $classname = $ts[$last - 1]['value']; |
|
| 577 | + |
|
| 578 | + if (class_exists($classname, false)) { |
|
| 579 | + throw new Exception(sprintf("Class '%s' can't be redeclared", $classname)); |
|
| 580 | + } |
|
| 581 | + } else if ($last >= 4 && |
|
| 582 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 583 | + $ts[$last - 2]['token'] == T_EXTENDS && |
|
| 584 | + $ts[$last - 3]['token'] == T_STRING && |
|
| 585 | + $ts[$last - 4]['token'] == T_CLASS ) { |
|
| 586 | + |
|
| 587 | + /* class classname extends classname { */ |
|
| 588 | + |
|
| 589 | + $classname = $ts[$last - 3]['value']; |
|
| 590 | + $extendsname = $ts[$last - 1]['value']; |
|
| 591 | + |
|
| 592 | + if (class_exists($classname, false)) { |
|
| 593 | + throw new Exception(sprintf("Class '%s' can't be redeclared", |
|
| 594 | + $classname)); |
|
| 595 | + } |
|
| 596 | + if (!class_exists($extendsname, true)) { |
|
| 597 | + throw new Exception(sprintf("Can't extend '%s' ... from not existing Class '%s'", |
|
| 598 | + $classname, $extendsname)); |
|
| 599 | + } |
|
| 600 | + } else if ($last >= 4 && |
|
| 601 | + $ts[$last - 1]['token'] == T_STRING && |
|
| 602 | + $ts[$last - 2]['token'] == T_IMPLEMENTS && |
|
| 603 | + $ts[$last - 3]['token'] == T_STRING && |
|
| 604 | + $ts[$last - 4]['token'] == T_CLASS ) { |
|
| 605 | + |
|
| 606 | + /* class name implements interface { */ |
|
| 607 | + |
|
| 608 | + $classname = $ts[$last - 3]['value']; |
|
| 609 | + $implements = $ts[$last - 1]['value']; |
|
| 610 | + |
|
| 611 | + if (class_exists($classname, false)) { |
|
| 612 | + throw new Exception(sprintf("Class '%s' can't be redeclared", |
|
| 613 | + $classname)); |
|
| 614 | + } |
|
| 615 | + if (!interface_exists($implements, false)) { |
|
| 616 | + throw new Exception(sprintf("Can't implement not existing Interface '%s' for Class '%s'", |
|
| 617 | + $implements, $classname)); |
|
| 618 | + } |
|
| 619 | + } |
|
| 620 | + |
|
| 621 | + array_push($braces, $token); |
|
| 622 | + break; |
|
| 623 | + case '}': |
|
| 624 | + $need_return = 0; |
|
| 625 | + case ')': |
|
| 626 | + array_pop($braces); |
|
| 627 | + break; |
|
| 628 | + case '[': |
|
| 629 | + if ($ts[0]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 630 | + $ts[0]['token'] != T_ABSTRACT && /* if we are not in a class definition */ |
|
| 631 | + $ts[1]['token'] != T_CLASS && /* if we are not in a class definition */ |
|
| 632 | + $ts[$last - 1]['token'] == T_VARIABLE) { |
|
| 633 | + /* $a[] only works on array and string */ |
|
| 634 | + |
|
| 635 | + /* $object has to exist and has to be a object */ |
|
| 636 | + $objname = $ts[$last - 1]['value']; |
|
| 637 | + |
|
| 638 | + if (!isset($GLOBALS[ltrim($objname, '$')])) { |
|
| 639 | + throw new Exception(sprintf('Variable \'%s\' is not set', $objname)); |
|
| 640 | + } |
|
| 641 | + $obj = $GLOBALS[ltrim($objname, '$')]; |
|
| 642 | + |
|
| 643 | + if (is_object($obj)) { |
|
| 644 | + throw new Exception(sprintf('Objects (%s) don\'t support array access operators', $objname)); |
|
| 645 | + } |
|
| 646 | + } |
|
| 647 | + break; |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | $eval .= $token; |
@@ -29,13 +29,13 @@ |
||
| 29 | 29 | |
| 30 | 30 | public function optSetVerbose($key, $val) { |
| 31 | 31 | switch($val) { |
| 32 | - case "false": |
|
| 33 | - case "on": |
|
| 34 | - case "1": |
|
| 35 | - $this->opt_verbose = true; |
|
| 36 | - default: |
|
| 37 | - $this->opt_verbose = false; |
|
| 38 | - break; |
|
| 32 | + case "false": |
|
| 33 | + case "on": |
|
| 34 | + case "1": |
|
| 35 | + $this->opt_verbose = true; |
|
| 36 | + default: |
|
| 37 | + $this->opt_verbose = false; |
|
| 38 | + break; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
@@ -15,19 +15,19 @@ |
||
| 15 | 15 | |
| 16 | 16 | public function optSetExecTime($key, $val) { |
| 17 | 17 | switch ($val) { |
| 18 | - case "enable": |
|
| 19 | - case "1": |
|
| 20 | - case "on": |
|
| 21 | - $this->show_exectime = true; |
|
| 22 | - break; |
|
| 23 | - case "disable": |
|
| 24 | - case "0": |
|
| 25 | - case "off": |
|
| 26 | - $this->show_exectime = false; |
|
| 27 | - break; |
|
| 28 | - default: |
|
| 29 | - printf(":set %s failed, unknown value. Use :set %s = (on|off)", $key, $key); |
|
| 30 | - break; |
|
| 18 | + case "enable": |
|
| 19 | + case "1": |
|
| 20 | + case "on": |
|
| 21 | + $this->show_exectime = true; |
|
| 22 | + break; |
|
| 23 | + case "disable": |
|
| 24 | + case "0": |
|
| 25 | + case "off": |
|
| 26 | + $this->show_exectime = false; |
|
| 27 | + break; |
|
| 28 | + default: |
|
| 29 | + printf(":set %s failed, unknown value. Use :set %s = (on|off)", $key, $key); |
|
| 30 | + break; |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |