From 33cf1c66af970edaf7eb0a468276fca249b8a5c8 Mon Sep 17 00:00:00 2001 From: jeroenpost86 Date: Thu, 12 May 2022 03:49:39 -0700 Subject: [PATCH] fix: Updated PHP mode to support PHP8.1 syntax (#4696) Co-authored-by: Pipelines --- lib/ace/mode/php/php.js | 4830 ++++++++++++++++++++------------------- 1 file changed, 2509 insertions(+), 2321 deletions(-) diff --git a/lib/ace/mode/php/php.js b/lib/ace/mode/php/php.js index 29f4c05699b..315471c3376 100644 --- a/lib/ace/mode/php/php.js +++ b/lib/ace/mode/php/php.js @@ -16,2329 +16,2517 @@ */ - -define(function(require, exports, module) { - -var PHP = {Constants:{}}; - -PHP.Constants.T_INCLUDE = 259 -PHP.Constants.T_INCLUDE_ONCE = 260 -PHP.Constants.T_EVAL = 318 -PHP.Constants.T_REQUIRE = 261 -PHP.Constants.T_REQUIRE_ONCE = 262 -PHP.Constants.T_LOGICAL_OR = 263 -PHP.Constants.T_LOGICAL_XOR = 264 -PHP.Constants.T_LOGICAL_AND = 265 -PHP.Constants.T_PRINT = 266 -PHP.Constants.T_YIELD = 267 -PHP.Constants.T_DOUBLE_ARROW = 268 -PHP.Constants.T_YIELD_FROM = 269 -PHP.Constants.T_PLUS_EQUAL = 270 -PHP.Constants.T_MINUS_EQUAL = 271 -PHP.Constants.T_MUL_EQUAL = 272 -PHP.Constants.T_DIV_EQUAL = 273 -PHP.Constants.T_CONCAT_EQUAL = 274 -PHP.Constants.T_MOD_EQUAL = 275 -PHP.Constants.T_AND_EQUAL = 276 -PHP.Constants.T_OR_EQUAL = 277 -PHP.Constants.T_XOR_EQUAL = 278 -PHP.Constants.T_SL_EQUAL = 279 -PHP.Constants.T_SR_EQUAL = 280 -PHP.Constants.T_POW_EQUAL = 281 -PHP.Constants.T_COALESCE_EQUAL = 282 -PHP.Constants.T_COALESCE = 283 -PHP.Constants.T_BOOLEAN_OR = 284 -PHP.Constants.T_BOOLEAN_AND = 285 -PHP.Constants.T_IS_EQUAL = 286 -PHP.Constants.T_IS_NOT_EQUAL = 287 -PHP.Constants.T_IS_IDENTICAL = 288 -PHP.Constants.T_IS_NOT_IDENTICAL = 289 -PHP.Constants.T_SPACESHIP = 290 -PHP.Constants.T_IS_SMALLER_OR_EQUAL = 291 -PHP.Constants.T_IS_GREATER_OR_EQUAL = 292 -PHP.Constants.T_SL = 293 -PHP.Constants.T_SR = 294 -PHP.Constants.T_INSTANCEOF = 295 -PHP.Constants.T_INC = 319 -PHP.Constants.T_DEC = 320 -PHP.Constants.T_INT_CAST = 296 -PHP.Constants.T_DOUBLE_CAST = 297 -PHP.Constants.T_STRING_CAST = 298 -PHP.Constants.T_ARRAY_CAST = 299 -PHP.Constants.T_OBJECT_CAST = 300 -PHP.Constants.T_BOOL_CAST = 301 -PHP.Constants.T_UNSET_CAST = 302 -PHP.Constants.T_POW = 303 -PHP.Constants.T_NEW = 304 -PHP.Constants.T_CLONE = 305 -PHP.Constants.T_EXIT = 321 -PHP.Constants.T_IF = 322 -PHP.Constants.T_ELSEIF = 307 -PHP.Constants.T_ELSE = 308 -PHP.Constants.T_ENDIF = 323 -PHP.Constants.T_LNUMBER = 309 -PHP.Constants.T_DNUMBER = 310 -PHP.Constants.T_STRING = 311 -PHP.Constants.T_STRING_VARNAME = 316 -PHP.Constants.T_VARIABLE = 312 -PHP.Constants.T_NUM_STRING = 317 -PHP.Constants.T_INLINE_HTML = 313 -PHP.Constants.T_BAD_CHARACTER = 395 -PHP.Constants.T_ENCAPSED_AND_WHITESPACE = 314 -PHP.Constants.T_CONSTANT_ENCAPSED_STRING = 315 -PHP.Constants.T_ECHO = 324 -PHP.Constants.T_DO = 325 -PHP.Constants.T_WHILE = 326 -PHP.Constants.T_ENDWHILE = 327 -PHP.Constants.T_FOR = 328 -PHP.Constants.T_ENDFOR = 329 -PHP.Constants.T_FOREACH = 330 -PHP.Constants.T_ENDFOREACH = 331 -PHP.Constants.T_DECLARE = 332 -PHP.Constants.T_ENDDECLARE = 333 -PHP.Constants.T_AS = 334 -PHP.Constants.T_SWITCH = 335 -PHP.Constants.T_ENDSWITCH = 336 -PHP.Constants.T_CASE = 337 -PHP.Constants.T_DEFAULT = 338 -PHP.Constants.T_BREAK = 339 -PHP.Constants.T_CONTINUE = 340 -PHP.Constants.T_GOTO = 341 -PHP.Constants.T_FUNCTION = 342 -PHP.Constants.T_FN = 343 -PHP.Constants.T_CONST = 344 -PHP.Constants.T_RETURN = 345 -PHP.Constants.T_TRY = 346 -PHP.Constants.T_CATCH = 347 -PHP.Constants.T_FINALLY = 348 -PHP.Constants.T_THROW = 349 -PHP.Constants.T_USE = 350 -PHP.Constants.T_INSTEADOF = 351 -PHP.Constants.T_GLOBAL = 352 -PHP.Constants.T_STATIC = 353 -PHP.Constants.T_ABSTRACT = 354 -PHP.Constants.T_FINAL = 355 -PHP.Constants.T_PRIVATE = 356 -PHP.Constants.T_PROTECTED = 357 -PHP.Constants.T_PUBLIC = 358 -PHP.Constants.T_VAR = 359 -PHP.Constants.T_UNSET = 360 -PHP.Constants.T_ISSET = 361 -PHP.Constants.T_EMPTY = 362 -PHP.Constants.T_HALT_COMPILER = 363 -PHP.Constants.T_CLASS = 364 -PHP.Constants.T_TRAIT = 365 -PHP.Constants.T_INTERFACE = 366 -PHP.Constants.T_EXTENDS = 367 -PHP.Constants.T_IMPLEMENTS = 368 -PHP.Constants.T_OBJECT_OPERATOR = 369 -PHP.Constants.T_DOUBLE_ARROW = 268 -PHP.Constants.T_LIST = 370 -PHP.Constants.T_ARRAY = 371 -PHP.Constants.T_CALLABLE = 372 -PHP.Constants.T_CLASS_C = 376 -PHP.Constants.T_TRAIT_C = 377 -PHP.Constants.T_METHOD_C = 378 -PHP.Constants.T_FUNC_C = 379 -PHP.Constants.T_LINE = 373 -PHP.Constants.T_FILE = 374 -PHP.Constants.T_COMMENT = 380 -PHP.Constants.T_DOC_COMMENT = 381 -PHP.Constants.T_OPEN_TAG = 382 -PHP.Constants.T_OPEN_TAG_WITH_ECHO = 383 -PHP.Constants.T_CLOSE_TAG = 384 -PHP.Constants.T_WHITESPACE = 385 -PHP.Constants.T_START_HEREDOC = 386 -PHP.Constants.T_END_HEREDOC = 387 -PHP.Constants.T_DOLLAR_OPEN_CURLY_BRACES = 388 -PHP.Constants.T_CURLY_OPEN = 389 -PHP.Constants.T_PAAMAYIM_NEKUDOTAYIM = 390 -PHP.Constants.T_NAMESPACE = 391 -PHP.Constants.T_NS_C = 392 -PHP.Constants.T_DIR = 375 -PHP.Constants.T_NS_SEPARATOR = 393 -PHP.Constants.T_ELLIPSIS = 394 - -PHP.Lexer = function(src, ini) { - var heredoc, heredocEndAllowed, - - stateStack = ['INITIAL'], stackPos = 0, - swapState = function(state) { - stateStack[stackPos] = state; - }, - pushState = function(state) { - stateStack[++stackPos] = state; - }, - popState = function() { - --stackPos; - }, - - shortOpenTag = ini === undefined || /^(on|true|1)$/i.test(ini.short_open_tag), - openTag = shortOpenTag - ? /^(\<\?php(?:\r\n|[ \t\r\n])|<\?|\