1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Use psalm-return in place of return if available

This commit is contained in:
Matthew Brown 2016-10-03 21:36:42 -04:00
parent f3ee908232
commit ae75296469
2 changed files with 9 additions and 4 deletions

View File

@ -62,8 +62,13 @@ class CommentChecker
$info = ['return_type' => null, 'params' => [], 'deprecated' => false, 'suppress' => []];
if (isset($comments['specials']['return'])) {
$return_blocks = preg_split('/[\s]+/', $comments['specials']['return'][0]);
if (isset($comments['specials']['return']) || isset($comments['specials']['psalm-return'])) {
$return_blocks = preg_split(
'/[\s]+/',
isset($comments['specials']['psalm-return'])
? $comments['specials']['psalm-return'][0]
: $comments['specials']['return'][0]
);
if (preg_match('/^' . self::TYPE_REGEX . '$/', $return_blocks[0])
&& !preg_match('/\[[^\]]+\]/', $return_blocks[0])

View File

@ -4180,9 +4180,9 @@ class StatementsChecker
// Parse @specials.
$matches = null;
$have_specials = preg_match_all('/^\s?@(\w+)\s*([^\n]*)/m', $docblock, $matches, PREG_SET_ORDER);
$have_specials = preg_match_all('/^\s?@([\w\-:]+)\s*([^\n]*)/m', $docblock, $matches, PREG_SET_ORDER);
if ($have_specials) {
$docblock = preg_replace('/^\s?@(\w+)\s*([^\n]*)/m', '', $docblock);
$docblock = preg_replace('/^\s?@([\w\-:]+)\s*([^\n]*)/m', '', $docblock);
foreach ($matches as $match) {
list($_, $type, $data) = $match;