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

Merge pull request #6064 from ElisDN/negative-numbers

Negative number literals
This commit is contained in:
Bruce Weirdan 2021-07-08 20:50:21 +03:00 committed by GitHub
commit 04c9d60371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 0 deletions

View File

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

View File

@ -703,6 +703,34 @@ class MagicMethodAnnotationTest extends TestCase
(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' => [
'<?php
namespace Foo;

View File

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