From f255672e40e4d6ea96c3e717aed54530d5ef0b83 Mon Sep 17 00:00:00 2001 From: Martin Herndl Date: Tue, 15 Feb 2022 20:11:07 +0100 Subject: [PATCH] Add a couple more interesting test cases --- tests/PHPStan/Analyser/data/bug-6329.php | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/PHPStan/Analyser/data/bug-6329.php b/tests/PHPStan/Analyser/data/bug-6329.php index 27590b3d7a..c6b49e87e4 100644 --- a/tests/PHPStan/Analyser/data/bug-6329.php +++ b/tests/PHPStan/Analyser/data/bug-6329.php @@ -158,3 +158,28 @@ function inverse($a, $b, $c): void assertType('non-empty-array|null', $c); } } + +/** + * @param mixed $a + * @param mixed $b + * @param mixed $c + * @param mixed $d + */ +function combinations($a, $b, $c, $d): void +{ + if (is_string($a) && '' !== $a || is_int($a) && $a > 0 || null === $a) { + assertType('int<1, max>|non-empty-string|null', $a); + } + if ((!is_string($b) || '' === $b) && (!is_int($b) || $b <= 0) && null !== $b) { + } else { + assertType('int<1, max>|non-empty-string|null', $b); + } + + if (is_array($c) && $c === array_filter($c, 'is_string', ARRAY_FILTER_USE_KEY) || null === $c) { + assertType('array|null', $c); + } + if ((!is_array($d) || $d !== array_filter($d, 'is_string', ARRAY_FILTER_USE_KEY)) && null !== $d) { + } else { + assertType('array|null', $d); + } +}