mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 09:37:59 +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) {
|
} elseif ($type instanceof TArrayKey) {
|
||||||
$redundant = false;
|
$redundant = false;
|
||||||
$non_numeric_types[] = new TString();
|
$non_numeric_types[] = new TString();
|
||||||
|
} elseif ($type instanceof TScalar) {
|
||||||
|
$redundant = false;
|
||||||
|
$non_numeric_types[] = new TString();
|
||||||
|
$non_numeric_types[] = new TBool();
|
||||||
} elseif (!$type->isNumericType()) {
|
} elseif (!$type->isNumericType()) {
|
||||||
$non_numeric_types[] = $type;
|
$non_numeric_types[] = $type;
|
||||||
} else {
|
} else {
|
||||||
|
@ -197,6 +197,20 @@ class ConditionalTest extends TestCase
|
|||||||
'$a' => 'string',
|
'$a' => 'string',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'typeRefinementonWithNegatedIsNumeric' => [
|
||||||
|
'code' => '<?php
|
||||||
|
/**
|
||||||
|
* @param scalar $v
|
||||||
|
* @return bool|string
|
||||||
|
*/
|
||||||
|
function toString($v)
|
||||||
|
{
|
||||||
|
if (is_numeric($v)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $v;
|
||||||
|
}',
|
||||||
|
],
|
||||||
'typeRefinementWithStringOrTrue' => [
|
'typeRefinementWithStringOrTrue' => [
|
||||||
'code' => '<?php
|
'code' => '<?php
|
||||||
$a = rand(0, 5) > 4 ? "hello" : true;
|
$a = rand(0, 5) > 4 ? "hello" : true;
|
||||||
|
Loading…
Reference in New Issue
Block a user