1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00

Fix negative numbers

This commit is contained in:
ElisDN 2021-07-08 14:08:35 +03:00
parent bbbfa69378
commit 61b78e117f
3 changed files with 41 additions and 0 deletions

View File

@ -384,6 +384,10 @@ class TypeTokenizer
continue; continue;
} }
if ($string_type_token[0][0] === '-' && is_numeric($string_type_token[0])) {
continue;
}
if (isset($type_tokens[$i + 1]) if (isset($type_tokens[$i + 1])
&& $type_tokens[$i + 1][0] === ':' && $type_tokens[$i + 1][0] === ':'
&& isset($type_tokens[$i - 1]) && isset($type_tokens[$i - 1])

View File

@ -703,6 +703,34 @@ class MagicMethodAnnotationTest extends TestCase
(new \Foo\G)->randomInt(); (new \Foo\G)->randomInt();
}' }'
], ],
'negativeInDefault' => [
'<?php
/**
* @method void foo($a = -0.1, $b = -12)
*/
class G
{
public function __call(string $method, array $attributes): void
{
}
}
(new G)->foo();'
],
'namespacedNegativeInDefault' => [
'<?php
namespace Foo {
/**
* @method void foo($a = -0.1, $b = -12)
*/
class G
{
public function __call(string $method, array $attributes): void
{
}
}
(new G)->foo();
}'
],
'namespacedUnion' => [ 'namespacedUnion' => [
'<?php '<?php
namespace Foo; namespace Foo;

View File

@ -607,6 +607,15 @@ class ValueTest extends \Psalm\Tests\TestCase
private $type = "easy"; private $type = "easy";
}' }'
], ],
'supportMultipleValues' => [
'<?php
class A {
/**
* @var 0|-1|1
*/
private $type = -1;
}'
],
'typecastTrueToInt' => [ 'typecastTrueToInt' => [
'<?php '<?php
/** /**