Skip to content
Permalink
Browse files

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

  • Loading branch information
muglug committed Jan 10, 2020
1 parent d22b132 commit 03030d4887418bb63317370a44b33af1fdd64bf1
Showing with 21 additions and 3 deletions.
  1. +6 −3 src/Psalm/Type.php
  2. +15 −0 tests/MagicMethodAnnotationTest.php
@@ -1074,9 +1074,12 @@ public static function fixUpLocalType(
$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;
@@ -544,6 +544,21 @@ public function __call(string $s, array $args) {}
$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);'
],
];
}

0 comments on commit 03030d4

Please sign in to comment.
You can’t perform that action at this time.