Skip to content

Commit 48b5d83

Browse files
authored
Merge pull request #2802 from PHPOffice/Performance-Experimental-Changes
Simplify validation of columnId/rowId values when creating a CellAddress object
2 parents fde7730 + e043cf3 commit 48b5d83

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/PhpSpreadsheet/Calculation/Functions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,8 @@ public static function trimTrailingRange(string $coordinate): string
705705

706706
public static function trimSheetFromCellReference(string $coordinate): string
707707
{
708-
while (strpos($coordinate, '!') !== false) {
709-
$coordinate = substr($coordinate, strpos($coordinate, '!') + 1);
708+
if (strpos($coordinate, '!') !== false) {
709+
$coordinate = substr($coordinate, strrpos($coordinate, '!') + 1);
710710
}
711711

712712
return $coordinate;

src/PhpSpreadsheet/Cell/CellAddress.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,9 @@ public function __construct(string $cellAddress, ?Worksheet $worksheet = null)
4747
*/
4848
private static function validateColumnAndRow($columnId, $rowId): void
4949
{
50-
$array = [$columnId, $rowId];
51-
array_walk(
52-
$array,
53-
function ($value): void {
54-
if (!is_numeric($value) || $value <= 0) {
55-
throw new Exception('Row and Column Ids must be positive integer values');
56-
}
57-
}
58-
);
50+
if (!is_numeric($columnId) || $columnId <= 0 || !is_numeric($rowId) || $rowId <= 0) {
51+
throw new Exception('Row and Column Ids must be positive integer values');
52+
}
5953
}
6054

6155
/**

0 commit comments

Comments
 (0)