File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
tests/PHPStan/Analyser/nsrt Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,29 @@ function last(array $array): void
3535 }
3636 assertType ('array<int> ' , $ array );
3737}
38+
39+ function maybeArray (array $ array , mixed $ mixed ): void
40+ {
41+ $ arrayOrMixed = rand (0 , 1 ) ? $ array : $ mixed ;
42+
43+ if (array_key_last ($ arrayOrMixed ) !== null ) {
44+ assertType ('mixed ' , $ arrayOrMixed );
45+ } else {
46+ assertType ('mixed ' , $ arrayOrMixed );
47+ }
48+ assertType ('mixed ' , $ arrayOrMixed );
49+ }
50+
51+ function mixedLast (mixed $ mixed ): void
52+ {
53+ if (is_array ($ mixed )) {
54+ return ;
55+ }
56+
57+ if (array_key_last ($ mixed ) !== null ) {
58+ assertType ('mixed~array<mixed, mixed> ' , $ mixed );
59+ } else {
60+ assertType ('mixed~array<mixed, mixed> ' , $ mixed );
61+ }
62+ assertType ('mixed~array<mixed, mixed> ' , $ mixed );
63+ }
You can’t perform that action at this time.
0 commit comments