Skip to content

Commit d9dfc5b

Browse files
committed
fix(prelude): add optional return array_unique
Signed-off-by: azjezz <[email protected]>
1 parent 450cf58 commit d9dfc5b

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/** @param non-empty-list<non-empty-string> $l */
4+
function takeList(array $l): void {
5+
foreach ($l as $v) {
6+
echo $v;
7+
}
8+
}
9+
10+
/**
11+
* @param non-empty-string $x
12+
* @param non-empty-string ...$y
13+
*/
14+
function foo(string $x, string ...$y): void {
15+
$a = array_unique([$x, ...$y]);
16+
$c = array_values($a);
17+
takeList($c);
18+
}

crates/analyzer/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ test_case!(accessing_undefined_class_constant);
3535
test_case!(argument_count);
3636
test_case!(array_list_reconciliation);
3737
test_case!(array_shape_fields);
38+
test_case!(array_unique_non_empty);
3839
test_case!(assert_concrete_to_template_type);
3940
test_case!(assert_generic_array_key_is_array_key);
4041
test_case!(bare_identifier_in_array_access);

crates/prelude/assets/extensions/standard.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4574,7 +4574,7 @@ function array_rand(array $array, int $num = 1): array|string|int
45744574
* @param array<K, V> $array
45754575
* @param int<0, 5> $flags
45764576
*
4577-
* @return array<K, V>
4577+
* @return ($array is non-empty-array|non-empty-list ? non-empty-array<K, V> : array<K, V>)
45784578
*
45794579
* @pure
45804580
*/

0 commit comments

Comments
 (0)