Skip to content

Commit eeedd1c

Browse files
rvanvelzenondrejmirtes
authored andcommitted
Add test for conditional types involving accessory types
The `arrayKeys()` case doesn't make it completely obvious because `non-empty-list` and `list` overlap.
1 parent 2b3d282 commit eeedd1c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/PHPStan/Analyser/data/conditional-types.php

+18
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@ public function testArrayKeys(array $array, array $nonEmptyArray, array $intArra
3636
assertType('array<int, *NEVER*>', $this->arrayKeys($emptyArray));
3737
}
3838

39+
/**
40+
* @return ($array is non-empty-array ? true : false)
41+
*/
42+
abstract public function accessory(array $array): bool;
43+
44+
/**
45+
* @param array $array
46+
* @param non-empty-array $nonEmptyArray
47+
* @param array{} $emptyArray
48+
*/
49+
public function testAccessory(array $array, array $nonEmptyArray, array $emptyArray): void
50+
{
51+
assertType('bool', $this->accessory($array));
52+
assertType('true', $this->accessory($nonEmptyArray));
53+
assertType('false', $this->accessory($emptyArray));
54+
assertType('bool', $this->accessory($_GET['array']));
55+
}
56+
3957
/**
4058
* @return ($as_float is true ? float : string)
4159
*/

0 commit comments

Comments
 (0)