@@ -3486,6 +3486,13 @@ private function _processTokenStack($tokens, $cellID = NULL, PHPExcel_Cell $pCel
3486
3486
3487
3487
3488
3488
private function _validateBinaryOperand ($ cellID , &$ operand , &$ stack ) {
3489
+ if (is_array ($ operand )) {
3490
+ if ((count ($ operand , COUNT_RECURSIVE ) - count ($ operand )) == 1 ) {
3491
+ do {
3492
+ $ operand = array_pop ($ operand );
3493
+ } while (is_array ($ operand ));
3494
+ }
3495
+ }
3489
3496
// Numbers, matrices and booleans can pass straight through, as they're already valid
3490
3497
if (is_string ($ operand )) {
3491
3498
// We only need special validations for the operand if it is a string
@@ -3591,25 +3598,13 @@ private function _executeNumericBinaryOperation($cellID,$operand1,$operand2,$ope
3591
3598
if (!$ this ->_validateBinaryOperand ($ cellID ,$ operand1 ,$ stack )) return FALSE ;
3592
3599
if (!$ this ->_validateBinaryOperand ($ cellID ,$ operand2 ,$ stack )) return FALSE ;
3593
3600
3594
- $ executeMatrixOperation = FALSE ;
3595
3601
// If either of the operands is a matrix, we need to treat them both as matrices
3596
3602
// (converting the other operand to a matrix if need be); then perform the required
3597
3603
// matrix operation
3598
3604
if ((is_array ($ operand1 )) || (is_array ($ operand2 ))) {
3599
- // Ensure that both operands are arrays/matrices
3600
- $ executeMatrixOperation = TRUE ;
3601
- $ mSize = array ();
3602
- list ($ mSize [],$ mSize [],$ mSize [],$ mSize []) = self ::_checkMatrixOperands ($ operand1 ,$ operand2 ,2 );
3603
-
3604
- // But if they're both single cell matrices, then we can treat them as simple values
3605
- if (array_sum ($ mSize ) == 4 ) {
3606
- $ executeMatrixOperation = FALSE ;
3607
- $ operand1 = $ operand1 [0 ][0 ];
3608
- $ operand2 = $ operand2 [0 ][0 ];
3609
- }
3610
- }
3605
+ // Ensure that both operands are arrays/matrices of the same size
3606
+ self ::_checkMatrixOperands ($ operand1 , $ operand2 , 2 );
3611
3607
3612
- if ($ executeMatrixOperation ) {
3613
3608
try {
3614
3609
// Convert operand 1 from a PHP array to a matrix
3615
3610
$ matrix = new PHPExcel_Shared_JAMA_Matrix ($ operand1 );
0 commit comments