mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge pull request #6064 from ElisDN/negative-numbers
Negative number literals
This commit is contained in:
commit
04c9d60371
@ -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])
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user