1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Allow assignment to numeric string via assertion

This commit is contained in:
Matthew Brown 2018-05-12 19:56:17 -04:00
parent dbc0e6dfcb
commit 8e90334428
2 changed files with 14 additions and 0 deletions

View File

@ -110,6 +110,9 @@ abstract class Atomic
case 'class-string': case 'class-string':
return new TClassString(); return new TClassString();
case 'numeric-string':
return new TNumericString();
case '$this': case '$this':
return new TNamedObject('static'); return new TNamedObject('static');

View File

@ -775,6 +775,17 @@ class TypeReconciliationTest extends TestCase
return false; return false;
}', }',
], ],
'numericStringAssertion' => [
'<?php
/**
* @param mixed $a
*/
function foo($a, string $b) : void {
if (is_numeric($b) && $a === $b) {
echo $a;
}
}'
],
]; ];
} }