mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Merge pull request #9339 from edsrzf/is-numeric-negated
This commit is contained in:
commit
d934875532
@ -1292,6 +1292,10 @@ class SimpleNegatedAssertionReconciler extends Reconciler
|
||||
} elseif ($type instanceof TArrayKey) {
|
||||
$redundant = false;
|
||||
$non_numeric_types[] = new TString();
|
||||
} elseif ($type instanceof TScalar) {
|
||||
$redundant = false;
|
||||
$non_numeric_types[] = new TString();
|
||||
$non_numeric_types[] = new TBool();
|
||||
} elseif (!$type->isNumericType()) {
|
||||
$non_numeric_types[] = $type;
|
||||
} else {
|
||||
|
@ -197,6 +197,20 @@ class ConditionalTest extends TestCase
|
||||
'$a' => 'string',
|
||||
],
|
||||
],
|
||||
'typeRefinementonWithNegatedIsNumeric' => [
|
||||
'code' => '<?php
|
||||
/**
|
||||
* @param scalar $v
|
||||
* @return bool|string
|
||||
*/
|
||||
function toString($v)
|
||||
{
|
||||
if (is_numeric($v)) {
|
||||
return false;
|
||||
}
|
||||
return $v;
|
||||
}',
|
||||
],
|
||||
'typeRefinementWithStringOrTrue' => [
|
||||
'code' => '<?php
|
||||
$a = rand(0, 5) > 4 ? "hello" : true;
|
||||
|
Loading…
Reference in New Issue
Block a user