289209cfc6b716c584e75be3a55e669b95a8795d
[m6w6/pecl-ci] / gen-matrix.php
1 <?php
2
3 return function() {
4 foreach (func_get_args() as $array) {
5 $apc = [];
6 foreach ($array as $key => $values) {
7 if (is_numeric($key) && is_string($values)) {
8 // switch on yes/no
9 $key = $values;
10 $values = ["no", "yes"];
11 } else if (is_numeric($key) && is_array($values)) {
12 // mutually enasbled options
13 $vpc = [];
14 foreach ($values as $yes) {
15 $mpc = "$yes=yes ";
16 foreach ($values as $no) {
17 if ($yes === $no) {
18 continue;
19 }
20 $mpc .= "$no=no ";
21 }
22 $vpc[] = $mpc;
23 }
24 $key = null;
25 $values = $vpc;
26 }
27
28 if (empty($apc)) {
29 // seed
30 foreach ((array) $values as $val) {
31 $apc[] = strlen($key) ? "$key=$val" : $val;
32 }
33 } else {
34 // combine
35 $cpc = $apc;
36 $apc = [];
37 foreach ((array) $values as $val) {
38 foreach ($cpc as $e) {
39 $apc[] = strlen($key) ? "$e $key=$val" : "$e $val";
40 }
41 }
42 }
43 }
44 $xpc[] = $apc;
45 }
46 return $xpc;
47 };