1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Fix #2583 - don’t convert scalar terms in @method annotations

This commit is contained in:
Brown 2020-01-10 11:29:10 -05:00
parent d22b13262f
commit 03030d4887
2 changed files with 21 additions and 3 deletions

View File

@ -1074,9 +1074,12 @@ abstract class Type
$string_type_token[0] = preg_replace('/(.+)\$.*/', '$1', $string_type_token[0]);
}
$type_tokens[$i][0]
= $string_type_token[0]
= self::fixScalarTerms($string_type_token[0]);
$fixed_token = !isset($type_tokens[$i + 1]) || $type_tokens[$i + 1][0] !== '('
? self::fixScalarTerms($string_type_token[0])
: $string_type_token[0];
$type_tokens[$i][0] = $fixed_token;
$string_type_token[0] = $fixed_token;
if ($string_type_token[0] === 'self' && $self_fqcln) {
$type_tokens[$i][0] = $self_fqcln;

View File

@ -544,6 +544,21 @@ class MagicMethodAnnotationTest extends TestCase
$child->setInteger(function() : void {});
}',
],
'allowMethodsNamedBooleanAndInteger' => [
'<?php
/**
* @method boolean(int $foo) : bool
* @method integer(int $foo) : bool
*/
class Child {
public function __call(string $name, array $args) {}
}
$child = new Child();
$child->boolean(5);
$child->integer(5);'
],
];
}