| 1 |
<?php |
| 2 |
|
| 3 |
namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation; |
| 4 |
|
| 5 |
/** |
| 6 |
* A dedicated Calculation singleton for formula parsing only. |
| 7 |
* |
| 8 |
* This class provides an isolated instance specifically for parsing formulas |
| 9 |
* without branch pruning, avoiding state conflicts with the main Calculation |
| 10 |
* singleton used for cell value calculations. |
| 11 |
* |
| 12 |
* @internal |
| 13 |
*/ |
| 14 |
final class CalculationParserOnly extends Calculation |
| 15 |
{ |
| 16 |
/** |
| 17 |
* Instance of this class. |
| 18 |
*/ |
| 19 |
private static ?CalculationParserOnly $parserInstance = null; |
| 20 |
|
| 21 |
/** |
| 22 |
* Branch pruning is disabled by default for parsing-only operations. |
| 23 |
*/ |
| 24 |
protected bool $branchPruningEnabled = false; |
| 25 |
|
| 26 |
/** |
| 27 |
* Get the singleton instance of this parser-only calculator. |
| 28 |
*/ |
| 29 |
public static function getParserInstance(): self |
| 30 |
{ |
| 31 |
if (!self::$parserInstance) { |
| 32 |
self::$parserInstance = new self(); |
| 33 |
} |
| 34 |
|
| 35 |
return self::$parserInstance; |
| 36 |
} |
| 37 |
|
| 38 |
/** @param mixed $enabled Unused, property will always be false in this class */ |
| 39 |
public function setBranchPruningEnabled($enabled): self |
| 40 |
{ |
| 41 |
return $this; |
| 42 |
} |
| 43 |
} |
| 44 |
|