mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #1545 - improve handling of negated binary ops
This commit is contained in:
parent
7848e97f36
commit
a9b8952ea2
@ -127,6 +127,20 @@ class Algebra
|
||||
return self::combineOredClauses($left_clauses, $right_clauses);
|
||||
}
|
||||
|
||||
if ($conditional instanceof PhpParser\Node\Expr\BooleanNot
|
||||
&& $conditional->expr instanceof PhpParser\Node\Expr\BinaryOp
|
||||
) {
|
||||
$negated_clauses = self::getFormula(
|
||||
$conditional->expr,
|
||||
$this_class_name,
|
||||
$source,
|
||||
$codebase,
|
||||
!$inside_negation
|
||||
);
|
||||
|
||||
return self::negateFormula($negated_clauses);
|
||||
}
|
||||
|
||||
AssertionFinder::scrapeAssertions(
|
||||
$conditional,
|
||||
$this_class_name,
|
||||
|
@ -902,6 +902,22 @@ class TypeAlgebraTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'invertEquation' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param mixed $width
|
||||
* @param mixed $height
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
function Foo($width, $height) : void {
|
||||
if (!(is_int($width) || is_float($width)) || !(is_int($height) || is_float($height))) {
|
||||
throw new RuntimeException("bad");
|
||||
}
|
||||
|
||||
echo sprintf("padding-top:%s%%;", 100 * ($height/$width));
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user