Skip to content

Commit c7ed571

Browse files
herndlmondrejmirtes
authored andcommitted
Add a couple of simple ConstantArrayType casting tests
1 parent c0c4092 commit c7ed571

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/PHPStan/Analyser/data/strval.php

+20
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,23 @@ function nonEmptyArrayTest(array $a): void
9191
assertType('1.0', floatval($a));
9292
assertType('true', boolval($a));
9393
}
94+
95+
/**
96+
* @param array{} $a
97+
* @param array{foo: mixed, bar?: mixed} $b
98+
* @param array{foo?: mixed, bar?: mixed} $c
99+
*/
100+
function constantArrayTest(array $a, array $b, array $c): void
101+
{
102+
assertType('0', intval($a));
103+
assertType('0.0', floatval($a));
104+
assertType('false', boolval($a));
105+
106+
assertType('1', intval($b));
107+
assertType('1.0', floatval($b));
108+
assertType('true', boolval($b));
109+
110+
assertType('0|1', intval($c));
111+
assertType('0.0|1.0', floatval($c));
112+
assertType('bool', boolval($c));
113+
}

0 commit comments

Comments
 (0)