2016-06-24 00:45:46 +02:00
|
|
|
<?php
|
2018-11-06 03:57:36 +01:00
|
|
|
namespace Psalm\Internal\Analyzer;
|
2016-08-13 20:20:46 +02:00
|
|
|
|
2019-06-01 17:53:32 +02:00
|
|
|
use PhpParser;
|
2017-07-25 22:11:02 +02:00
|
|
|
use Psalm\Aliases;
|
2018-11-06 03:57:36 +01:00
|
|
|
use Psalm\DocComment;
|
2016-11-02 07:29:00 +01:00
|
|
|
use Psalm\Exception\DocblockParseException;
|
2017-11-15 03:43:31 +01:00
|
|
|
use Psalm\Exception\IncorrectDocblockException;
|
2017-05-19 06:48:26 +02:00
|
|
|
use Psalm\Exception\TypeParseTreeException;
|
2018-01-21 18:44:46 +01:00
|
|
|
use Psalm\FileSource;
|
2020-05-29 04:14:41 +02:00
|
|
|
use Psalm\Internal\Scanner\ParsedDocblock;
|
2021-06-08 04:55:21 +02:00
|
|
|
use Psalm\Internal\Scanner\VarDocblockComment;
|
2020-05-14 01:29:59 +02:00
|
|
|
use Psalm\Internal\Type\TypeAlias;
|
2020-05-14 01:12:45 +02:00
|
|
|
use Psalm\Internal\Type\TypeParser;
|
|
|
|
use Psalm\Internal\Type\TypeTokenizer;
|
2021-06-08 04:55:21 +02:00
|
|
|
use Psalm\Type;
|
|
|
|
|
|
|
|
use function array_merge;
|
2019-06-26 22:52:29 +02:00
|
|
|
use function count;
|
2021-06-08 04:55:21 +02:00
|
|
|
use function preg_match;
|
|
|
|
use function preg_replace;
|
2019-06-26 22:52:29 +02:00
|
|
|
use function preg_split;
|
2021-06-08 04:55:21 +02:00
|
|
|
use function reset;
|
2019-06-26 22:52:29 +02:00
|
|
|
use function rtrim;
|
2021-06-08 04:55:21 +02:00
|
|
|
use function str_replace;
|
|
|
|
use function strlen;
|
|
|
|
use function substr;
|
|
|
|
use function substr_count;
|
|
|
|
use function trim;
|
2016-06-24 00:45:46 +02:00
|
|
|
|
2018-12-02 00:37:49 +01:00
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2018-11-06 03:57:36 +01:00
|
|
|
class CommentAnalyzer
|
2016-06-24 00:45:46 +02:00
|
|
|
{
|
2020-09-20 18:54:46 +02:00
|
|
|
public const TYPE_REGEX = '(\??\\\?[\(\)A-Za-z0-9_&\<\.=,\>\[\]\-\{\}:|?\\\\]*|\$[a-zA-Z_0-9_]+)';
|
2016-06-24 00:45:46 +02:00
|
|
|
|
|
|
|
/**
|
2020-11-27 17:43:23 +01:00
|
|
|
* @param array<string, array<string, Type\Union>>|null $template_type_map
|
2020-05-14 01:29:59 +02:00
|
|
|
* @param array<string, TypeAlias> $type_aliases
|
2017-05-27 02:16:18 +02:00
|
|
|
*
|
|
|
|
* @throws DocblockParseException if there was a problem parsing the docblock
|
|
|
|
*
|
2020-10-17 18:36:44 +02:00
|
|
|
* @return list<VarDocblockComment>
|
2016-06-24 00:45:46 +02:00
|
|
|
*/
|
2016-11-02 07:29:00 +01:00
|
|
|
public static function getTypeFromComment(
|
2019-06-01 17:53:32 +02:00
|
|
|
PhpParser\Comment\Doc $comment,
|
2018-01-21 18:44:46 +01:00
|
|
|
FileSource $source,
|
2017-07-25 22:11:02 +02:00
|
|
|
Aliases $aliases,
|
2020-09-07 01:36:47 +02:00
|
|
|
?array $template_type_map = null,
|
2019-06-01 18:25:57 +02:00
|
|
|
?array $type_aliases = null
|
2020-09-04 22:26:33 +02:00
|
|
|
): array {
|
2019-06-26 22:26:14 +02:00
|
|
|
$parsed_docblock = DocComment::parsePreservingLength($comment);
|
|
|
|
|
|
|
|
return self::arrayToDocblocks(
|
|
|
|
$comment,
|
|
|
|
$parsed_docblock,
|
|
|
|
$source,
|
|
|
|
$aliases,
|
|
|
|
$template_type_map,
|
|
|
|
$type_aliases
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-27 17:43:23 +01:00
|
|
|
* @param array<string, array<string, Type\Union>>|null $template_type_map
|
2020-05-14 01:29:59 +02:00
|
|
|
* @param array<string, TypeAlias> $type_aliases
|
2019-06-26 22:26:14 +02:00
|
|
|
*
|
2020-10-17 18:36:44 +02:00
|
|
|
* @return list<VarDocblockComment>
|
2019-06-26 22:26:14 +02:00
|
|
|
*
|
|
|
|
* @throws DocblockParseException if there was a problem parsing the docblock
|
|
|
|
*/
|
|
|
|
public static function arrayToDocblocks(
|
|
|
|
PhpParser\Comment\Doc $comment,
|
2020-05-29 04:14:41 +02:00
|
|
|
ParsedDocblock $parsed_docblock,
|
2019-06-26 22:26:14 +02:00
|
|
|
FileSource $source,
|
|
|
|
Aliases $aliases,
|
2020-09-07 01:36:47 +02:00
|
|
|
?array $template_type_map = null,
|
2019-06-26 22:26:14 +02:00
|
|
|
?array $type_aliases = null
|
|
|
|
) : array {
|
2017-05-25 07:32:34 +02:00
|
|
|
$var_id = null;
|
2016-06-24 00:45:46 +02:00
|
|
|
|
2018-05-20 23:19:53 +02:00
|
|
|
$var_type_tokens = null;
|
2018-01-02 02:04:03 +01:00
|
|
|
$original_type = null;
|
2016-06-24 00:45:46 +02:00
|
|
|
|
2018-02-08 05:33:31 +01:00
|
|
|
$var_comments = [];
|
2016-06-24 00:45:46 +02:00
|
|
|
|
2019-06-01 22:57:33 +02:00
|
|
|
$comment_text = $comment->getText();
|
|
|
|
|
2020-09-20 14:56:49 +02:00
|
|
|
$var_line_number = $comment->getStartLine();
|
2019-06-01 17:53:32 +02:00
|
|
|
|
2020-05-29 04:14:41 +02:00
|
|
|
if (isset($parsed_docblock->combined_tags['var'])) {
|
|
|
|
foreach ($parsed_docblock->combined_tags['var'] as $offset => $var_line) {
|
2017-03-02 04:27:52 +01:00
|
|
|
$var_line = trim($var_line);
|
2016-06-24 00:45:46 +02:00
|
|
|
|
2017-03-02 04:27:52 +01:00
|
|
|
if (!$var_line) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-06-01 18:25:57 +02:00
|
|
|
$type_start = null;
|
|
|
|
$type_end = null;
|
|
|
|
|
2019-02-01 02:21:20 +01:00
|
|
|
$line_parts = self::splitDocLine($var_line);
|
2017-03-02 04:27:52 +01:00
|
|
|
|
2021-08-07 00:22:47 +02:00
|
|
|
$line_number = $comment->getStartLine() + substr_count(
|
|
|
|
$comment_text,
|
|
|
|
"\n",
|
|
|
|
0,
|
|
|
|
$offset - $comment->getStartFilePos()
|
|
|
|
);
|
2021-02-24 16:14:04 +01:00
|
|
|
$description = $parsed_docblock->description;
|
2019-06-01 22:57:33 +02:00
|
|
|
|
2017-03-02 04:27:52 +01:00
|
|
|
if ($line_parts && $line_parts[0]) {
|
2021-08-06 22:00:37 +02:00
|
|
|
$type_start = $offset;
|
2019-06-02 00:44:59 +02:00
|
|
|
$type_end = $type_start + strlen($line_parts[0]);
|
|
|
|
|
2020-04-03 20:56:11 +02:00
|
|
|
$line_parts[0] = self::sanitizeDocblockType($line_parts[0]);
|
2019-06-02 00:44:59 +02:00
|
|
|
|
2019-06-03 21:46:25 +02:00
|
|
|
if ($line_parts[0] === ''
|
|
|
|
|| ($line_parts[0][0] === '$'
|
|
|
|
&& !preg_match('/^\$this(\||$)/', $line_parts[0]))
|
|
|
|
) {
|
2017-11-15 03:43:31 +01:00
|
|
|
throw new IncorrectDocblockException('Misplaced variable');
|
|
|
|
}
|
|
|
|
|
2018-04-05 23:18:49 +02:00
|
|
|
try {
|
2020-05-14 01:12:45 +02:00
|
|
|
$var_type_tokens = TypeTokenizer::getFullyQualifiedTokens(
|
2019-06-02 00:44:59 +02:00
|
|
|
$line_parts[0],
|
2018-04-05 23:18:49 +02:00
|
|
|
$aliases,
|
2018-12-18 05:29:27 +01:00
|
|
|
$template_type_map,
|
2018-07-15 23:23:17 +02:00
|
|
|
$type_aliases
|
2018-04-05 23:18:49 +02:00
|
|
|
);
|
|
|
|
} catch (TypeParseTreeException $e) {
|
|
|
|
throw new DocblockParseException($line_parts[0] . ' is not a valid type');
|
|
|
|
}
|
2017-03-02 04:27:52 +01:00
|
|
|
|
2018-01-02 02:04:03 +01:00
|
|
|
$original_type = $line_parts[0];
|
|
|
|
|
2017-03-02 04:27:52 +01:00
|
|
|
$var_line_number = $line_number;
|
|
|
|
|
2021-02-24 16:14:04 +01:00
|
|
|
if (count($line_parts) > 1) {
|
|
|
|
if ($line_parts[1][0] === '$') {
|
|
|
|
$var_id = $line_parts[1];
|
|
|
|
$description = trim(substr($var_line, strlen($line_parts[0]) + strlen($line_parts[1]) + 2));
|
|
|
|
} else {
|
|
|
|
$description = trim(substr($var_line, strlen($line_parts[0]) + 1));
|
|
|
|
}
|
|
|
|
$description = preg_replace('/\\n \\*\\s+/um', ' ', $description);
|
2017-03-02 04:27:52 +01:00
|
|
|
}
|
2018-02-08 05:33:31 +01:00
|
|
|
}
|
2017-03-02 04:27:52 +01:00
|
|
|
|
2018-05-20 23:19:53 +02:00
|
|
|
if (!$var_type_tokens || !$original_type) {
|
2018-02-08 05:33:31 +01:00
|
|
|
continue;
|
2016-06-24 00:45:46 +02:00
|
|
|
}
|
|
|
|
|
2018-02-08 05:33:31 +01:00
|
|
|
try {
|
2020-05-15 06:15:48 +02:00
|
|
|
$defined_type = TypeParser::parseTokens(
|
|
|
|
$var_type_tokens,
|
|
|
|
null,
|
|
|
|
$template_type_map ?: [],
|
|
|
|
$type_aliases ?: []
|
|
|
|
);
|
2018-02-08 05:33:31 +01:00
|
|
|
} catch (TypeParseTreeException $e) {
|
2019-06-01 17:53:32 +02:00
|
|
|
throw new DocblockParseException(
|
2019-06-23 05:30:40 +02:00
|
|
|
$line_parts[0] .
|
2019-06-01 17:53:32 +02:00
|
|
|
' is not a valid type' .
|
|
|
|
' (from ' .
|
|
|
|
$source->getFilePath() .
|
|
|
|
':' .
|
2020-09-20 14:56:49 +02:00
|
|
|
$comment->getStartLine() .
|
2019-06-01 17:53:32 +02:00
|
|
|
')'
|
|
|
|
);
|
2018-02-08 05:33:31 +01:00
|
|
|
}
|
2017-05-25 07:32:34 +02:00
|
|
|
|
2018-02-08 05:33:31 +01:00
|
|
|
$defined_type->setFromDocblock();
|
2016-06-24 00:45:46 +02:00
|
|
|
|
2018-02-08 05:33:31 +01:00
|
|
|
$var_comment = new VarDocblockComment();
|
|
|
|
$var_comment->type = $defined_type;
|
|
|
|
$var_comment->var_id = $var_id;
|
|
|
|
$var_comment->line_number = $var_line_number;
|
2019-06-01 18:25:57 +02:00
|
|
|
$var_comment->type_start = $type_start;
|
|
|
|
$var_comment->type_end = $type_end;
|
2021-02-24 16:14:04 +01:00
|
|
|
$var_comment->description = $description;
|
2019-05-15 00:27:27 +02:00
|
|
|
|
2020-05-29 04:14:41 +02:00
|
|
|
self::decorateVarDocblockComment($var_comment, $parsed_docblock);
|
2017-02-04 04:07:14 +01:00
|
|
|
|
2018-02-08 05:33:31 +01:00
|
|
|
$var_comments[] = $var_comment;
|
|
|
|
}
|
|
|
|
}
|
2016-06-24 00:45:46 +02:00
|
|
|
|
2019-08-11 22:01:37 +02:00
|
|
|
if (!$var_comments
|
2020-05-29 04:14:41 +02:00
|
|
|
&& (isset($parsed_docblock->tags['deprecated'])
|
|
|
|
|| isset($parsed_docblock->tags['internal'])
|
|
|
|
|| isset($parsed_docblock->tags['readonly'])
|
|
|
|
|| isset($parsed_docblock->tags['psalm-readonly'])
|
|
|
|
|| isset($parsed_docblock->tags['psalm-readonly-allow-private-mutation'])
|
2020-06-21 17:43:08 +02:00
|
|
|
|| isset($parsed_docblock->tags['psalm-taint-escape'])
|
2021-02-24 16:14:04 +01:00
|
|
|
|| isset($parsed_docblock->tags['psalm-internal'])
|
|
|
|
|| $parsed_docblock->description)
|
2019-08-11 22:01:37 +02:00
|
|
|
) {
|
|
|
|
$var_comment = new VarDocblockComment();
|
2020-05-29 04:14:41 +02:00
|
|
|
|
|
|
|
self::decorateVarDocblockComment($var_comment, $parsed_docblock);
|
2019-08-11 22:01:37 +02:00
|
|
|
|
|
|
|
$var_comments[] = $var_comment;
|
|
|
|
}
|
|
|
|
|
2018-02-08 05:33:31 +01:00
|
|
|
return $var_comments;
|
2016-06-24 00:45:46 +02:00
|
|
|
}
|
|
|
|
|
2020-05-29 04:14:41 +02:00
|
|
|
private static function decorateVarDocblockComment(
|
|
|
|
VarDocblockComment $var_comment,
|
|
|
|
ParsedDocblock $parsed_docblock
|
|
|
|
) : void {
|
|
|
|
$var_comment->deprecated = isset($parsed_docblock->tags['deprecated']);
|
|
|
|
$var_comment->internal = isset($parsed_docblock->tags['internal']);
|
|
|
|
$var_comment->readonly = isset($parsed_docblock->tags['readonly'])
|
|
|
|
|| isset($parsed_docblock->tags['psalm-readonly'])
|
|
|
|
|| isset($parsed_docblock->tags['psalm-readonly-allow-private-mutation']);
|
|
|
|
|
|
|
|
$var_comment->allow_private_mutation
|
|
|
|
= isset($parsed_docblock->tags['psalm-allow-private-mutation'])
|
|
|
|
|| isset($parsed_docblock->tags['psalm-readonly-allow-private-mutation']);
|
|
|
|
|
2021-02-24 16:14:04 +01:00
|
|
|
if (!$var_comment->description) {
|
|
|
|
$var_comment->description = $parsed_docblock->description;
|
|
|
|
}
|
|
|
|
|
2020-06-21 17:43:08 +02:00
|
|
|
if (isset($parsed_docblock->tags['psalm-taint-escape'])) {
|
|
|
|
foreach ($parsed_docblock->tags['psalm-taint-escape'] as $param) {
|
2020-05-29 04:14:41 +02:00
|
|
|
$param = trim($param);
|
|
|
|
$var_comment->removed_taints[] = $param;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($parsed_docblock->tags['psalm-internal'])) {
|
|
|
|
$psalm_internal = reset($parsed_docblock->tags['psalm-internal']);
|
|
|
|
|
|
|
|
if (!$psalm_internal) {
|
|
|
|
throw new DocblockParseException('psalm-internal annotation used without specifying namespace');
|
|
|
|
}
|
|
|
|
|
|
|
|
$var_comment->psalm_internal = reset($parsed_docblock->tags['psalm-internal']);
|
2020-07-26 16:47:48 +02:00
|
|
|
$var_comment->internal = true;
|
2020-05-29 04:14:41 +02:00
|
|
|
}
|
2021-01-31 17:32:24 +01:00
|
|
|
|
|
|
|
if (isset($parsed_docblock->tags['psalm-suppress'])) {
|
|
|
|
$var_comment->suppressed_issues = $parsed_docblock->tags['psalm-suppress'];
|
|
|
|
}
|
2020-05-29 04:14:41 +02:00
|
|
|
}
|
|
|
|
|
2020-08-23 19:52:31 +02:00
|
|
|
/**
|
|
|
|
* @psalm-pure
|
|
|
|
*/
|
2020-11-05 05:25:08 +01:00
|
|
|
public static function sanitizeDocblockType(string $docblock_type) : string
|
2020-04-03 20:56:11 +02:00
|
|
|
{
|
|
|
|
$docblock_type = preg_replace('@^[ \t]*\*@m', '', $docblock_type);
|
|
|
|
$docblock_type = preg_replace('/,\n\s+\}/', '}', $docblock_type);
|
|
|
|
return str_replace("\n", '', $docblock_type);
|
|
|
|
}
|
|
|
|
|
2016-10-28 06:11:16 +02:00
|
|
|
/**
|
2017-05-27 02:16:18 +02:00
|
|
|
* @throws DocblockParseException if an invalid string is found
|
|
|
|
*
|
2021-03-23 06:30:51 +01:00
|
|
|
* @return non-empty-list<string>
|
2020-08-23 19:52:31 +02:00
|
|
|
*
|
|
|
|
* @psalm-pure
|
2016-10-28 06:11:16 +02:00
|
|
|
*/
|
2020-09-12 17:24:05 +02:00
|
|
|
public static function splitDocLine(string $return_block): array
|
2016-10-28 06:11:16 +02:00
|
|
|
{
|
|
|
|
$brackets = '';
|
|
|
|
|
|
|
|
$type = '';
|
|
|
|
|
2018-03-27 04:13:10 +02:00
|
|
|
$expects_callable_return = false;
|
|
|
|
|
2019-06-02 00:44:59 +02:00
|
|
|
$return_block = str_replace("\t", ' ', $return_block);
|
2018-03-27 04:13:10 +02:00
|
|
|
|
2018-05-20 23:19:53 +02:00
|
|
|
$quote_char = null;
|
|
|
|
$escaped = false;
|
|
|
|
|
2018-03-27 04:13:10 +02:00
|
|
|
for ($i = 0, $l = strlen($return_block); $i < $l; ++$i) {
|
2016-10-28 06:11:16 +02:00
|
|
|
$char = $return_block[$i];
|
2018-03-27 04:13:10 +02:00
|
|
|
$next_char = $i < $l - 1 ? $return_block[$i + 1] : null;
|
2019-02-01 13:50:48 +01:00
|
|
|
$last_char = $i > 0 ? $return_block[$i - 1] : null;
|
2016-10-28 06:11:16 +02:00
|
|
|
|
2018-05-20 23:19:53 +02:00
|
|
|
if ($quote_char) {
|
2021-05-22 18:36:02 +02:00
|
|
|
if ($char === $quote_char && !$escaped) {
|
2018-05-20 23:19:53 +02:00
|
|
|
$quote_char = null;
|
|
|
|
|
|
|
|
$type .= $char;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($char === '\\' && !$escaped && ($next_char === $quote_char || $next_char === '\\')) {
|
|
|
|
$escaped = true;
|
|
|
|
|
|
|
|
$type .= $char;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
$escaped = false;
|
|
|
|
|
|
|
|
$type .= $char;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($char === '"' || $char === '\'') {
|
|
|
|
$quote_char = $char;
|
|
|
|
|
|
|
|
$type .= $char;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-02-01 13:50:48 +01:00
|
|
|
if ($char === ':' && $last_char === ')') {
|
2019-02-01 14:58:52 +01:00
|
|
|
$expects_callable_return = true;
|
2019-02-01 13:50:48 +01:00
|
|
|
|
|
|
|
$type .= $char;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-10-28 06:11:16 +02:00
|
|
|
if ($char === '[' || $char === '{' || $char === '(' || $char === '<') {
|
|
|
|
$brackets .= $char;
|
2016-11-02 07:29:00 +01:00
|
|
|
} elseif ($char === ']' || $char === '}' || $char === ')' || $char === '>') {
|
2016-10-28 06:11:16 +02:00
|
|
|
$last_bracket = substr($brackets, -1);
|
|
|
|
$brackets = substr($brackets, 0, -1);
|
|
|
|
|
|
|
|
if (($char === ']' && $last_bracket !== '[')
|
|
|
|
|| ($char === '}' && $last_bracket !== '{')
|
|
|
|
|| ($char === ')' && $last_bracket !== '(')
|
|
|
|
|| ($char === '>' && $last_bracket !== '<')
|
|
|
|
) {
|
2016-11-02 07:29:00 +01:00
|
|
|
throw new DocblockParseException('Invalid string ' . $return_block);
|
2016-10-28 06:11:16 +02:00
|
|
|
}
|
2018-08-23 04:53:44 +02:00
|
|
|
} elseif ($char === ' ') {
|
2019-02-01 14:58:52 +01:00
|
|
|
if ($brackets) {
|
|
|
|
$expects_callable_return = false;
|
2019-06-01 23:22:33 +02:00
|
|
|
$type .= ' ';
|
2016-10-28 06:11:16 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-05-16 19:52:58 +02:00
|
|
|
if ($next_char === '|' || $next_char === '&') {
|
|
|
|
$nexter_char = $i < $l - 2 ? $return_block[$i + 2] : null;
|
|
|
|
|
|
|
|
if ($nexter_char === ' ') {
|
|
|
|
++$i;
|
2019-06-06 19:57:00 +02:00
|
|
|
$type .= $next_char . ' ';
|
2019-05-16 19:52:58 +02:00
|
|
|
continue;
|
|
|
|
}
|
2018-08-23 04:53:44 +02:00
|
|
|
}
|
|
|
|
|
2019-05-16 19:52:58 +02:00
|
|
|
if ($last_char === '|' || $last_char === '&') {
|
2019-06-06 19:57:00 +02:00
|
|
|
$type .= ' ';
|
2018-08-23 04:53:44 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-03-27 04:13:10 +02:00
|
|
|
if ($next_char === ':') {
|
|
|
|
++$i;
|
2019-06-06 19:57:00 +02:00
|
|
|
$type .= ' :';
|
2018-03-27 04:13:10 +02:00
|
|
|
$expects_callable_return = true;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($expects_callable_return) {
|
2019-06-06 20:27:49 +02:00
|
|
|
$type .= ' ';
|
2018-03-27 04:13:10 +02:00
|
|
|
$expects_callable_return = false;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-06-02 00:44:59 +02:00
|
|
|
$remaining = trim(preg_replace('@^[ \t]*\* *@m', ' ', substr($return_block, $i + 1)));
|
2016-11-01 05:39:41 +01:00
|
|
|
|
|
|
|
if ($remaining) {
|
2019-06-02 00:44:59 +02:00
|
|
|
return array_merge([rtrim($type)], preg_split('/[ \s]+/', $remaining));
|
2016-11-01 05:39:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return [$type];
|
2016-10-28 06:11:16 +02:00
|
|
|
}
|
|
|
|
|
2019-02-01 14:58:52 +01:00
|
|
|
$expects_callable_return = false;
|
2019-02-01 13:50:48 +01:00
|
|
|
|
2016-10-28 06:11:16 +02:00
|
|
|
$type .= $char;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [$type];
|
|
|
|
}
|
2016-06-24 00:45:46 +02:00
|
|
|
}
|