| 1 |
<?php |
| 2 |
|
| 3 |
namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\LookupRef; |
| 4 |
|
| 5 |
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError; |
| 6 |
|
| 7 |
class Vstack |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Excel function VSTACK. |
| 11 |
* |
| 12 |
* @return mixed[] |
| 13 |
* @param mixed ...$inputData |
| 14 |
*/ |
| 15 |
public static function vstack(...$inputData) |
| 16 |
{ |
| 17 |
$returnMatrix = []; |
| 18 |
|
| 19 |
$columns = 0; |
| 20 |
foreach ($inputData as $matrix) { |
| 21 |
if (!is_array($matrix)) { |
| 22 |
$count = 1; |
| 23 |
} else { |
| 24 |
$count = count(reset($matrix)); //* @phpstan-ignore argument.type (reset can theoretically return mixed not array) |
| 25 |
} |
| 26 |
$columns = max($columns, $count); |
| 27 |
} |
| 28 |
|
| 29 |
foreach ($inputData as $matrix) { |
| 30 |
if (!is_array($matrix)) { |
| 31 |
$matrix = [$matrix]; |
| 32 |
} |
| 33 |
foreach ($matrix as $row) { |
| 34 |
if (!is_array($row)) { |
| 35 |
$row = [$row]; |
| 36 |
} |
| 37 |
$returnMatrix[] = array_values(array_pad($row, $columns, ExcelError::NA())); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
return $returnMatrix; |
| 42 |
} |
| 43 |
} |
| 44 |
|