Literal Types
As a type description, specific values corresponding to a specific type are allowed:
boolstringintfloatnull.
Boolean And Null
The literals true and false are used as the value of the PHP bool type.
For PHP null types, the null literal is used.
For other types the logic is more complicated.
Strings
The syntax of string types is similar to that in PHP: The string allows single (') and double (") quotes, which can be escaped using a backslash (\).
Strings in single quotes are processed "as is", strings in double quotes allow insertion of special sequences.
Escape Sequences
All control sequences are similar to the PHP language: https://www.php.net/manual/en/language.types.string.php
\n— Line break (0x0Acode)\r— Carriage return (0x0Dcode)\t— Tab (0x09code)\v— Vertical Tab (0x0Bcode)\e— Escape (0x1Bcode)\f— Form Feed (0x0Ccode)\$— Dollar Sign (0x24code)
Hexadecimal Sequences
The sequence of characters matching the regular expression [0-9A-Fa-f]{1,2} is a character in hexadecimal notation (e.g. "\x41" === "A").
Unicode Sequences
the sequence of characters matching the regular expression [0-9A-Fa-f]+ is a Unicode codepoint, which will be output to the string as that codepoint's UTF-8 representation. The braces are required in the sequence. E.g. "\u{41}" === "A"
Integer
The syntax of integer numbers is similar to the PHP language. Binary, octal, decimal and hexadecimal number systems are supported.
Decimal numbers can contain any digits from 0 to 9 (leading 0 not allowed) and must match the regular expression [1-9][0-9]*. For any other numbers, a special prefixed format is used, described below. Negative values are prefixed with a minus (-).
Binary
Every binary number is prefixed with 0b or 0B and can only contain the numbers 1 and 0 and must match the regular expression 0b[0-1]+.
Octal
Every octal number is prefixed with 0o or 0O and can only contain the numbers between 0 and 7 and must match the regular expression 0o[0-7]+ or [0-7]+.
Hexadecimal
Every hexadecimal number is prefixed with 0x or 0X and can only contain the numbers between 0 and F and must match the regular expression 0x[0-9a-fA-F]+.
Float
The syntax of float numbers is similar to the PHP language. Basic floating point syntax and scientific notation are supported.
Every floating point number accepts the format [0-9]+\.[0-9]+. The leading or trailing number may be omitted. Negative values are prefixed with a minus (-.
Scientific Notation
Scientific notation is a way of expressing numbers that are too large or too small to be conveniently written in decimal form, since to do so would require writing out an inconveniently long string of digits.