public
|
PHPDOC_TYPE = "(?xi)\n(?(DEFINE)\n (?<sp> [\\f\\n\\r\\t\\x0b ] )\n (?<lnum> [0-9]+ (?: _ [0-9]+ )* )\n (?<dnum> (?: [0-9]* (?: _ [0-9]+ )* \\. (?&lnum) ) | (?: (?&lnum) \\. [0-9]* (?: _ [0-9]+ )* ) )\n (?<exponent_dnum> (?: (?&lnum) | (?&dnum) ) e [+-]? (?&lnum) )\n (?<php_identifier> [[:alpha:]_\\x80-\\xff] [[:alnum:]_\\x80-\\xff]* )\n (?<php_type> \\\\ (?&php_identifier) (?: \\\\ (?&php_identifier) )* | (?&php_identifier) (?: \\\\ (?&php_identifier) )+ )\n (?<phpdoc_type> (?&php_identifier) (?: - [[:alnum:]_\\x80-\\xff]+ )+ )\n (?<variable> \\$ (?&php_identifier) )\n (?<variance_type> covariant | contravariant )\n (?<variance> (?&sp)*+ (?: (?&variance_type) (?&sp)*+ )? (?! (?&variance_type) \\b ) )\n (?<param> \\s*+ (?: & \\s*+ )? (?: \\.\\.\\. \\s*+ )? (?: (?&variable) \\s*+ )? =? )\n (?<trailing> (?: \\s*+ , (?: \\s*+ \\.\\.\\. (?: \\s*+ , )? )? )? )\n)\n(\n (?:\n \\* |\n \\$this |\n \" (?: [^\"\\\\] | \\\\ . )*+ \" |\n ' (?: [^'\\\\] | \\\\ . )*+ ' |\n\n [+-]? (?:\n (?&exponent_dnum) |\n (?&dnum) |\n 0x [0-9a-f]++ (?: _ [0-9a-f]++ )*+ |\n 0b [01]++ (?: _ [01]++ )*+ |\n 0o? [0-7]++ (?: _ [0-7]++ )*+ |\n [1-9] [0-9]*+ (?: _ [0-9]++ )*+ |\n 0\n ) |\n\n (?: (?: pure- (?! \\\\ ) )? (?: callable | \\\\? Closure ) ) \\s*+\n (?: \\s* < (?&variance) (?: (?&php_identifier) \\s++ (?: of | as ) \\b (?&sp)*+ )? (?-1)\n (?: \\s*+ , (?&variance) (?: (?&php_identifier) \\s++ (?: of | as ) \\b (?&sp)*+ )? (?-1) )*+\n (?&trailing) \\s*+ > )?\n \\( (?&sp)*+ (?: (?-1) (?¶m)\n (?: \\s*+ , (?&sp)*+ (?-1) (?¶m) )*+\n (?&trailing) \\s*+ | \\.\\.\\. \\s*+ )? \\)\n (?: \\s* : (?&sp)*+ (?-1) )? |\n\n (?: \\? (?&sp)*+ )?\n (?: (?&php_type) | (?&phpdoc_type) | (?&php_identifier) )\n (?: :: [[:alpha:]_\\x80-\\xff*] [[:alnum:]_\\x80-\\xff*]*+ )?\n (?: \\s* < (?&variance) (?-1)\n (?: \\s*+ , (?&variance) (?-1) )*+\n (?&trailing) \\s*+ > )?\n (?: \\s* \\{ (?&sp)*+ (?: (?:\n (?: (?-1) \\s*+ (?: \\? \\s*+ )? : (?&sp)*+ )? (?-1)\n (?: \\s*+ , (?&sp)*+ (?: (?-1) \\s*+ (?: \\? \\s*+ )? : (?&sp)*+ )? (?-1) )*+\n (?&trailing) | \\.\\.\\. )?\n (?: (?<= \\.\\.\\. ) \\s*+ < (?&sp)*+ (?-1) (?: \\s*+ , (?&sp)*+ (?-1) )? \\s*+ > (?: \\s*+ , )? )? \\s*+ ) \\} )*+ |\n\n (?: (?&variable) | (?&php_identifier) ) \\s+ is (?: \\s++ not )? \\b (?&sp)*+ (?-1)\n \\s*+ \\? (?&sp)*+ (?-1)\n \\s*+ : (?&sp)*+ (?-1) |\n\n (?: \\? \\s*+ )? \\( (?&sp)*+ (?-1) \\s*+ \\)\n )\n (?: \\s* \\[ (?&sp)*+ (?: (?-1) \\s*+ )? \\] )*+\n (?: \\s* (?: \\| | & ) (?&sp)* (?-1) )?\n)"
A valid PHPDoc type
A valid PHPDoc type
Recursively matches plain, union and intersection types comprised of:
-
* (used in star projections like Collection<*> )
-
$this
- string, float or integer literals
- callables with optional template, parameter and/or return types
- native or PHPDoc types with optional
::CONST_* , <Type,...> and/or
{Foo?: string, ...<int>}
- conditional return types
- enclosing parentheses
In some locales, \s matches non-breaking space (\xA0 ), so (?&sp) is
used in contexts where the start of a PHP identifier would otherwise be
treated as whitespace.
|
#
|