]> git.lizzy.rs Git - micro.git/commitdiff
PHP: Add enum and keyword, and modify types (#2204)
authorUSAMI Kenta <tadsan@zonu.me>
Sun, 17 Jul 2022 19:16:17 +0000 (04:16 +0900)
committerGitHub <noreply@github.com>
Sun, 17 Jul 2022 19:16:17 +0000 (12:16 -0700)
* Add enum keyword to PHP (8.1) syntax

* Specify only keywords that are valid as type declarations as PHP types

boolean, integer and resource are not valid type name.

* Add match keyword to PHP (8.2) syntax

runtime/syntax/php.yaml

index 56b003f2906ae9f494faed871009666cd2e139a2..a4e20dec3b0d19ecff132e65889a04d9d2a8bd44 100644 (file)
@@ -17,14 +17,14 @@ rules:
     - comment: "<!--.+?-->"
     - default: "<\\?(php|=)\" end=\"\\?>"
     - identifier.class: "([a-zA-Z0-9_-]+)\\("
-    - type: "\\b(array|bool(ean)?|callable|callback|float|int(eger)?|iterable|object|resource|mixed|string|void)\\b"
+    - type: "\\b(array|bool|callable|float|int|iterable|object|mixed|string|void)\\b"
     - identifier.class: "[a-zA-Z\\\\]+::"
     - identifier: "\\b([A-Z][a-zA-Z0-9_]+)\\b"
     - identifier: "([A-Z0-9_]+)[;|\\s|\\)|,]"
     - type.keyword: "\\b(global|final|public|private|protected|static|const|var)\\b"
-    - statement: "\\b(abstract|catch|class|declare|do|else(if)?|end(declare|for(each)?|if|switch|while)|finally|for(each)|function|if|interface|namespace|switch|trait|try|while)\\b"
+    - statement: "\\b(abstract|catch|class|declare|do|else(if)?|end(declare|for(each)?|if|switch|while)|enum|finally|for(each)|function|if|interface|namespace|switch|trait|try|while)\\b"
     - identifier: "\\bnew\\s+([a-zA-Z0-9\\\\]+)"
-    - special: "\\b(as|and|break|case|clone|continue|default|die|fn|echo|empty|eval|exit|extends|goto|or|include(_once)?|implements|instanceof|insteadof|isset|list|new|print|return|require(_once)?|unset|use|throw|xor|yield(\\s+from))\\b"
+    - special: "\\b(as|and|break|case|clone|continue|default|die|fn|echo|empty|eval|exit|extends|goto|or|include(_once)?|implements|instanceof|insteadof|isset|list|match|new|print|return|require(_once)?|unset|use|throw|xor|yield(\\s+from))\\b"
     - constant.bool: "\\b(true|false|null|TRUE|FALSE|NULL)\\b"
     - constant: "[\\s|=|\\s|\\(|/|+|-|\\*|\\[]"
     - constant.number: "[0-9]"