-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve intersect and union of SubtractableTypes
Converts non-SubtractableTypes to SubtractableTypes in union to not loose subtracted type information. Sorts the SubtractableTypes in intersect to not loose subtracted type information if SubtractableTypes are intersected where not all of them have subtracted types configured.
- Loading branch information
1 parent
04c8ebd
commit 68e6443
Showing
7 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Bug6672; | ||
|
||
use function PHPStan\Testing\assertType; | ||
|
||
function foo(int $a, ?int $b, int $c, ?int $d, ?int $e, ?int $f): void | ||
{ | ||
if ($a > 17) { | ||
assertType('int<18, max>', $a); | ||
} else { | ||
assertType('int<min, 17>', $a); | ||
} | ||
|
||
if ($b > 17 || $b === null) { | ||
assertType('int<18, max>|null', $b); | ||
} else { | ||
assertType('int<min, 17>', $b); | ||
} | ||
|
||
if ($c < 17) { | ||
assertType('int<min, 16>', $c); | ||
} else { | ||
assertType('int<17, max>', $c); | ||
} | ||
|
||
if ($d < 17 || $d === null) { | ||
assertType('int<min, 16>|null', $d); | ||
} else { | ||
assertType('int<17, max>', $d); | ||
} | ||
|
||
if ($e >= 17 && $e <= 19 || $e === null) { | ||
assertType('int<17, 19>|null', $e); | ||
} else { | ||
assertType('int<min, 16>|int<20, max>', $e); | ||
} | ||
|
||
if ($f < 17 || $f > 19 || $f === null) { | ||
assertType('int<min, 16>|int<20, max>|null', $f); | ||
} else { | ||
assertType('int<17, 19>', $f); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters