File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 34
34
"autoload" : {
35
35
"psr-4" : {
36
36
"WordPress\\ AiClient\\ " : " src/"
37
- }
37
+ },
38
+ "files" : [
39
+ " src/polyfills.php"
40
+ ]
38
41
},
39
42
"autoload-dev" : {
40
43
"psr-4" : {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * Polyfills for PHP functions that may not be available in older versions.
5
+ *
6
+ * @since n.e.x.t
7
+ */
8
+
9
+ declare (strict_types=1 );
10
+
11
+ if (!function_exists ('array_is_list ' )) {
12
+ /**
13
+ * Checks whether a given array is a list.
14
+ *
15
+ * An array is considered a list if its keys consist of consecutive numbers from 0 to count($array)-1.
16
+ *
17
+ * @param array<mixed> $array The array to check.
18
+ * @return bool True if the array is a list, false otherwise.
19
+ *
20
+ * @since n.e.x.t
21
+ */
22
+ function array_is_list (array $ array ): bool
23
+ {
24
+ if ($ array === []) {
25
+ return true ;
26
+ }
27
+
28
+ $ expectedKey = 0 ;
29
+ foreach (array_keys ($ array ) as $ key ) {
30
+ if ($ key !== $ expectedKey ) {
31
+ return false ;
32
+ }
33
+ $ expectedKey ++;
34
+ }
35
+
36
+ return true ;
37
+ }
38
+ }
You can’t perform that action at this time.
0 commit comments