See Release Notes
Long Term Support Release
<?php namespace PhpOffice\PhpSpreadsheet\Calculation;> use PhpOffice\PhpSpreadsheet\Calculation\Engine\BranchPruner;use PhpOffice\PhpSpreadsheet\Calculation\Engine\CyclicReferenceStack; use PhpOffice\PhpSpreadsheet\Calculation\Engine\Logger;> use PhpOffice\PhpSpreadsheet\Calculation\Engine\Operands;use PhpOffice\PhpSpreadsheet\Calculation\Token\Stack;> use PhpOffice\PhpSpreadsheet\Cell\AddressRange;use PhpOffice\PhpSpreadsheet\Cell\Cell; use PhpOffice\PhpSpreadsheet\Cell\Coordinate;< use PhpOffice\PhpSpreadsheet\NamedRange;> use PhpOffice\PhpSpreadsheet\Cell\DataType; > use PhpOffice\PhpSpreadsheet\DefinedName; > use PhpOffice\PhpSpreadsheet\ReferenceHelper;use PhpOffice\PhpSpreadsheet\Shared; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;> use ReflectionClassConstant; > use ReflectionMethod; class Calculation > use ReflectionParameter; { > use Throwable;/** Constants */ /** Regular Expressions */ // Numeric operand const CALCULATION_REGEXP_NUMBER = '[-+]?\d*\.?\d+(e[-+]?\d+)?'; // String operand const CALCULATION_REGEXP_STRING = '"(?:[^"]|"")*"'; // Opening bracket const CALCULATION_REGEXP_OPENBRACE = '\('; // Function (allow for the old @ symbol that could be used to prefix a function, but we'll ignore it)< const CALCULATION_REGEXP_FUNCTION = '@?(?:_xlfn\.)?([A-Z][A-Z0-9\.]*)[\s]*\(';> const CALCULATION_REGEXP_FUNCTION = '@?(?:_xlfn\.)?(?:_xlws\.)?([\p{L}][\p{L}\p{N}\.]*)[\s]*\(';// Cell reference (cell or range of cells, with or without a sheet reference)< const CALCULATION_REGEXP_CELLREF = '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?\$?\b([a-z]{1,3})\$?(\d{1,7})(?![\w.])'; < // Named Range of cells < const CALCULATION_REGEXP_NAMEDRANGE = '((([^\s,!&%^\/\*\+<>=-]*)|(\'[^\']*\')|(\"[^\"]*\"))!)?([_A-Z][_A-Z0-9\.]*)';> const CALCULATION_REGEXP_CELLREF = '((([^\s,!&%^\/\*\+<>=:`-]*)|(\'(?:[^\']|\'[^!])+?\')|(\"(?:[^\"]|\"[^!])+?\"))!)?\$?\b([a-z]{1,3})\$?(\d{1,7})(?![\w.])'; > // Cell reference (with or without a sheet reference) ensuring absolute/relative > const CALCULATION_REGEXP_CELLREF_RELATIVE = '((([^\s\(,!&%^\/\*\+<>=:`-]*)|(\'(?:[^\']|\'[^!])+?\')|(\"(?:[^\"]|\"[^!])+?\"))!)?(\$?\b[a-z]{1,3})(\$?\d{1,7})(?![\w.])'; > const CALCULATION_REGEXP_COLUMN_RANGE = '(((([^\s\(,!&%^\/\*\+<>=:`-]*)|(\'(?:[^\']|\'[^!])+?\')|(\".(?:[^\"]|\"[^!])?\"))!)?(\$?[a-z]{1,3})):(?![.*])'; > const CALCULATION_REGEXP_ROW_RANGE = '(((([^\s\(,!&%^\/\*\+<>=:`-]*)|(\'(?:[^\']|\'[^!])+?\')|(\"(?:[^\"]|\"[^!])+?\"))!)?(\$?[1-9][0-9]{0,6})):(?![.*])'; > // Cell reference (with or without a sheet reference) ensuring absolute/relative > // Cell ranges ensuring absolute/relative > const CALCULATION_REGEXP_COLUMNRANGE_RELATIVE = '(\$?[a-z]{1,3}):(\$?[a-z]{1,3})'; > const CALCULATION_REGEXP_ROWRANGE_RELATIVE = '(\$?\d{1,7}):(\$?\d{1,7})'; > // Defined Names: Named Range of cells, or Named Formulae > const CALCULATION_REGEXP_DEFINEDNAME = '((([^\s,!&%^\/\*\+<>=-]*)|(\'(?:[^\']|\'[^!])+?\')|(\"(?:[^\"]|\"[^!])+?\"))!)?([_\p{L}][_\p{L}\p{N}\.]*)'; > // Structured Reference (Fully Qualified and Unqualified) > const CALCULATION_REGEXP_STRUCTURED_REFERENCE = '([\p{L}_\\\\][\p{L}\p{N}\._]+)?(\[(?:[^\d\]+-])?)';// Error const CALCULATION_REGEXP_ERROR = '\#[A-Z][A-Z0_\/]*[!\?]?'; /** constants */ const RETURN_ARRAY_AS_ERROR = 'error'; const RETURN_ARRAY_AS_VALUE = 'value'; const RETURN_ARRAY_AS_ARRAY = 'array';> const FORMULA_OPEN_FUNCTION_BRACE = '('; private static $returnArrayAsType = self::RETURN_ARRAY_AS_VALUE; > const FORMULA_CLOSE_FUNCTION_BRACE = ')'; > const FORMULA_OPEN_MATRIX_BRACE = '{'; /** > const FORMULA_CLOSE_MATRIX_BRACE = '}'; * Instance of this class. > const FORMULA_STRING_QUOTE = '"'; * > * @var Calculation > /** @var string */< * @var Calculation> * @var ?Calculationprivate static $instance; /** * Instance of the spreadsheet this Calculation Engine is using. *< * @var Spreadsheet> * @var ?Spreadsheet*/ private $spreadsheet; /** * Calculation cache. * * @var array */ private $calculationCache = []; /** * Calculation cache enabled. * * @var bool */ private $calculationCacheEnabled = true; /**< * Used to generate unique store keys. < * < * @var int> * @var BranchPruner*/< private $branchStoreKeyCounter = 0;> private $branchPruner;> /** private $branchPruningEnabled = true; > * @var bool > *//** * List of operators that can be used within formulae * The true/false value indicates whether it is a binary operator or a unary operator.< * < * @var array*/< private static $operators = [> private const CALCULATION_OPERATORS = ['+' => true, '-' => true, '*' => true, '/' => true, '^' => true, '&' => true, '%' => false, '~' => false, '>' => true, '<' => true, '=' => true, '>=' => true,< '<=' => true, '<>' => true, '|' => true, ':' => true,> '<=' => true, '<>' => true, '∩' => true, '∪' => true, > ':' => true,]; /** * List of binary operators (those that expect two operands).< * < * @var array*/< private static $binaryOperators = [> private const BINARY_OPERATORS = ['+' => true, '-' => true, '*' => true, '/' => true, '^' => true, '&' => true, '>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true,< '|' => true, ':' => true,> '∩' => true, '∪' => true, ':' => true,]; /** * The debug log generated by the calculation engine. * * @var Logger */ private $debugLog; /** * Flag to determine how formula errors should be handled * If true, then a user error will be triggered * If false, then an exception will be thrown. *< * @var bool> * @var ?bool > * > * @deprecated 1.25.2 use setSuppressFormulaErrors() instead*/< public $suppressFormulaErrors = false;> public $suppressFormulaErrors; > > /** @var bool */ > private $suppressFormulaErrorsNew = false;/** * Error message for any error that was raised/thrown by the calculation engine. *< * @var string> * @var null|string*/ public $formulaError; /**> * Reference Helper. * An array of the nested cell references accessed by the calculation engine, used for the debug log. > * * > * @var ReferenceHelper * @var CyclicReferenceStack > */ */ > private static $referenceHelper; private $cyclicReferenceStack; > > /**private $cellStack = [];> /** @var array *//** * Current iteration counter for cyclic formulae * If the value is 0 (or less) then cyclic formulae will throw an exception, * otherwise they will iterate to the limit defined here before returning a result. * * @var int */ private $cyclicFormulaCounter = 1;> /** @var string */private $cyclicFormulaCell = ''; /** * Number of iterations for cyclic formulae. * * @var int */ public $cyclicFormulaCount = 1; /**< * Epsilon Precision used for comparisons in calculations. < * < * @var float < */ < private $delta = 0.1e-12; < < /*** The current locale setting. * * @var string */ private static $localeLanguage = 'en_us'; // US English (default locale) /** * List of available locale settings * Note that this is read for the locale subdirectory only when requested. * * @var string[] */ private static $validLocaleLanguages = [ 'en', // English (default language) ]; /** * Locale-specific argument separator for function arguments. * * @var string */ private static $localeArgumentSeparator = ',';> /** @var array */private static $localeFunctions = []; /** * Locale-specific translations for Excel constants (True, False and Null). *< * @var string[]> * @var array<string, string>*/< public static $localeBoolean = [> private static $localeBoolean = ['TRUE' => 'TRUE', 'FALSE' => 'FALSE', 'NULL' => 'NULL', ];> public static function getLocaleBoolean(string $index): string /** > { * Excel constant string translations to their PHP equivalents > return self::$localeBoolean[$index]; * Constant conversion from text name/value to actual (datatyped) value. > } * >< * @var string[]> * @var array<string, mixed>*/ private static $excelConstants = [ 'TRUE' => true, 'FALSE' => false, 'NULL' => null, ];< // PhpSpreadsheet functions> public static function keyInExcelConstants(string $key): bool > { > return array_key_exists($key, self::$excelConstants); > } > > /** @return mixed */ > public static function getExcelConstants(string $key) > { > return self::$excelConstants[$key]; > } > > /** > * Array of functions usable on Spreadsheet. > * In theory, this could be const rather than static; > * however, Phpstan breaks trying to analyze it when attempted. > * > *@var array > */private static $phpSpreadsheetFunctions = [ 'ABS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'abs',> 'functionCall' => [MathTrig\Absolute::class, 'evaluate'],'argumentCount' => '1', ], 'ACCRINT' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'ACCRINT'], < 'argumentCount' => '4-7',> 'functionCall' => [Financial\Securities\AccruedInterest::class, 'periodic'], > 'argumentCount' => '4-8',], 'ACCRINTM' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'ACCRINTM'],> 'functionCall' => [Financial\Securities\AccruedInterest::class, 'atMaturity'],'argumentCount' => '3-5', ], 'ACOS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'acos',> 'functionCall' => [MathTrig\Trig\Cosine::class, 'acos'],'argumentCount' => '1', ], 'ACOSH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'acosh',> 'functionCall' => [MathTrig\Trig\Cosine::class, 'acosh'],'argumentCount' => '1', ], 'ACOT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'ACOT'],> 'functionCall' => [MathTrig\Trig\Cotangent::class, 'acot'],'argumentCount' => '1', ], 'ACOTH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'ACOTH'],> 'functionCall' => [MathTrig\Trig\Cotangent::class, 'acoth'],'argumentCount' => '1', ], 'ADDRESS' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'cellAddress'],> 'functionCall' => [LookupRef\Address::class, 'cell'],'argumentCount' => '2-5', ],> 'AGGREGATE' => [ 'AMORDEGRC' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_FINANCIAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Financial::class, 'AMORDEGRC'], > 'argumentCount' => '3+', 'argumentCount' => '6,7', > ],< 'functionCall' => [Financial::class, 'AMORDEGRC'],> 'functionCall' => [Financial\Amortization::class, 'AMORDEGRC'],'AMORLINC' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'AMORLINC'],> 'functionCall' => [Financial\Amortization::class, 'AMORLINC'],'argumentCount' => '6,7', ],> 'ANCHORARRAY' => [ 'AND' => [ > 'category' => Category::CATEGORY_UNCATEGORISED, 'category' => Category::CATEGORY_LOGICAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Logical::class, 'logicalAnd'], > 'argumentCount' => '*', 'argumentCount' => '1+', > ],< 'functionCall' => [Logical::class, 'logicalAnd'],> 'functionCall' => [Logical\Operations::class, 'logicalAnd'],'AREAS' => [> 'ARABIC' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'functionCall' => [Functions::class, 'DUMMY'], > 'functionCall' => [MathTrig\Arabic::class, 'evaluate'], 'argumentCount' => '1', > 'argumentCount' => '1', ], > ],'ASC' => [> 'ARRAYTOTEXT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'functionCall' => [Functions::class, 'DUMMY'], > 'functionCall' => [TextData\Text::class, 'fromArray'], 'argumentCount' => '1', > 'argumentCount' => '1,2', ], > ],'ASIN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'asin',> 'functionCall' => [MathTrig\Trig\Sine::class, 'asin'],'argumentCount' => '1', ], 'ASINH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'asinh',> 'functionCall' => [MathTrig\Trig\Sine::class, 'asinh'],'argumentCount' => '1', ], 'ATAN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'atan',> 'functionCall' => [MathTrig\Trig\Tangent::class, 'atan'],'argumentCount' => '1', ], 'ATAN2' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'ATAN2'],> 'functionCall' => [MathTrig\Trig\Tangent::class, 'atan2'],'argumentCount' => '2', ], 'ATANH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'atanh',> 'functionCall' => [MathTrig\Trig\Tangent::class, 'atanh'],'argumentCount' => '1', ], 'AVEDEV' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'AVEDEV'],> 'functionCall' => [Statistical\Averages::class, 'averageDeviations'],'argumentCount' => '1+', ], 'AVERAGE' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'AVERAGE'],> 'functionCall' => [Statistical\Averages::class, 'average'],'argumentCount' => '1+', ], 'AVERAGEA' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'AVERAGEA'],> 'functionCall' => [Statistical\Averages::class, 'averageA'],'argumentCount' => '1+', ], 'AVERAGEIF' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'AVERAGEIF'],> 'functionCall' => [Statistical\Conditional::class, 'AVERAGEIF'],'argumentCount' => '2,3', ], 'AVERAGEIFS' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Functions::class, 'DUMMY'],> 'functionCall' => [Statistical\Conditional::class, 'AVERAGEIFS'],'argumentCount' => '3+', ], 'BAHTTEXT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1', ],> 'BASE' => [ 'BESSELI' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_ENGINEERING, > 'functionCall' => [MathTrig\Base::class, 'evaluate'], 'functionCall' => [Engineering::class, 'BESSELI'], > 'argumentCount' => '2,3', 'argumentCount' => '2', > ],< 'functionCall' => [Engineering::class, 'BESSELI'],> 'functionCall' => [Engineering\BesselI::class, 'BESSELI'],'BESSELJ' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'BESSELJ'],> 'functionCall' => [Engineering\BesselJ::class, 'BESSELJ'],'argumentCount' => '2', ], 'BESSELK' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'BESSELK'],> 'functionCall' => [Engineering\BesselK::class, 'BESSELK'],'argumentCount' => '2', ], 'BESSELY' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'BESSELY'],> 'functionCall' => [Engineering\BesselY::class, 'BESSELY'],'argumentCount' => '2', ], 'BETADIST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'BETADIST'],> 'functionCall' => [Statistical\Distributions\Beta::class, 'distribution'],'argumentCount' => '3-5', ],> 'BETA.DIST' => [ 'BETAINV' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Statistical::class, 'BETAINV'], > 'argumentCount' => '4-6', 'argumentCount' => '3-5', > ],< 'functionCall' => [Statistical::class, 'BETAINV'],> 'functionCall' => [Statistical\Distributions\Beta::class, 'inverse'], > 'argumentCount' => '3-5', > ], > 'BETA.INV' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Beta::class, 'inverse'],'BIN2DEC' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'BINTODEC'],> 'functionCall' => [Engineering\ConvertBinary::class, 'toDecimal'],'argumentCount' => '1', ], 'BIN2HEX' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'BINTOHEX'],> 'functionCall' => [Engineering\ConvertBinary::class, 'toHex'],'argumentCount' => '1,2', ], 'BIN2OCT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'BINTOOCT'],> 'functionCall' => [Engineering\ConvertBinary::class, 'toOctal'],'argumentCount' => '1,2', ], 'BINOMDIST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'BINOMDIST'],> 'functionCall' => [Statistical\Distributions\Binomial::class, 'distribution'], > 'argumentCount' => '4', > ], > 'BINOM.DIST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Binomial::class, 'distribution'],'argumentCount' => '4', ],> 'BINOM.DIST.RANGE' => [ 'BITAND' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_ENGINEERING, > 'functionCall' => [Statistical\Distributions\Binomial::class, 'range'], 'functionCall' => [Engineering::class, 'BITAND'], > 'argumentCount' => '3,4', 'argumentCount' => '2', > ], ], > 'BINOM.INV' => [ 'BITOR' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_ENGINEERING, > 'functionCall' => [Statistical\Distributions\Binomial::class, 'inverse'], 'functionCall' => [Engineering::class, 'BITOR'], > 'argumentCount' => '3', 'argumentCount' => '2', > ],< 'functionCall' => [Engineering::class, 'BITAND'],> 'functionCall' => [Engineering\BitWise::class, 'BITAND'],< 'functionCall' => [Engineering::class, 'BITOR'],> 'functionCall' => [Engineering\BitWise::class, 'BITOR'],'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'BITOR'],> 'functionCall' => [Engineering\BitWise::class, 'BITXOR'],'argumentCount' => '2', ], 'BITLSHIFT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'BITLSHIFT'],> 'functionCall' => [Engineering\BitWise::class, 'BITLSHIFT'],'argumentCount' => '2', ], 'BITRSHIFT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'BITRSHIFT'],> 'functionCall' => [Engineering\BitWise::class, 'BITRSHIFT'],'argumentCount' => '2', ],> 'BYCOL' => [ 'CEILING' => [ > 'category' => Category::CATEGORY_LOGICAL, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [MathTrig::class, 'CEILING'], > 'argumentCount' => '*', 'argumentCount' => '2', > ], ], > 'BYROW' => [ 'CELL' => [ > 'category' => Category::CATEGORY_LOGICAL, 'category' => Category::CATEGORY_INFORMATION, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '*', 'argumentCount' => '1,2', > ],< 'functionCall' => [MathTrig::class, 'CEILING'], < 'argumentCount' => '2',> 'functionCall' => [MathTrig\Ceiling::class, 'ceiling'], > 'argumentCount' => '1-2', // 2 for Excel, 1-2 for Ods/Gnumeric > ], > 'CEILING.MATH' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [MathTrig\Ceiling::class, 'math'], > 'argumentCount' => '1-3', > ], > 'CEILING.PRECISE' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [MathTrig\Ceiling::class, 'precise'], > 'argumentCount' => '1,2','category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'CHARACTER'],> 'functionCall' => [TextData\CharacterConvert::class, 'character'],'argumentCount' => '1', ], 'CHIDIST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'CHIDIST'],> 'functionCall' => [Statistical\Distributions\ChiSquared::class, 'distributionRightTail'], > 'argumentCount' => '2', > ], > 'CHISQ.DIST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\ChiSquared::class, 'distributionLeftTail'], > 'argumentCount' => '3', > ], > 'CHISQ.DIST.RT' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\ChiSquared::class, 'distributionRightTail'],'argumentCount' => '2', ], 'CHIINV' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'CHIINV'],> 'functionCall' => [Statistical\Distributions\ChiSquared::class, 'inverseRightTail'], > 'argumentCount' => '2', > ], > 'CHISQ.INV' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\ChiSquared::class, 'inverseLeftTail'], > 'argumentCount' => '2', > ], > 'CHISQ.INV.RT' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\ChiSquared::class, 'inverseRightTail'],'argumentCount' => '2', ], 'CHITEST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Functions::class, 'DUMMY'],> 'functionCall' => [Statistical\Distributions\ChiSquared::class, 'test'], > 'argumentCount' => '2', > ], > 'CHISQ.TEST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\ChiSquared::class, 'test'],'argumentCount' => '2', ], 'CHOOSE' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'CHOOSE'],> 'functionCall' => [LookupRef\Selection::class, 'CHOOSE'], > 'argumentCount' => '2+', > ], > 'CHOOSECOLS' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2+', > ], > 'CHOOSEROWS' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'],'argumentCount' => '2+', ], 'CLEAN' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'TRIMNONPRINTABLE'],> 'functionCall' => [TextData\Trim::class, 'nonPrintable'],'argumentCount' => '1', ], 'CODE' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'ASCIICODE'],> 'functionCall' => [TextData\CharacterConvert::class, 'code'],'argumentCount' => '1', ], 'COLUMN' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'COLUMN'],> 'functionCall' => [LookupRef\RowColumnInformation::class, 'COLUMN'],'argumentCount' => '-1',> 'passCellReference' => true,'passByReference' => [true], ], 'COLUMNS' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'COLUMNS'],> 'functionCall' => [LookupRef\RowColumnInformation::class, 'COLUMNS'],'argumentCount' => '1', ], 'COMBIN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'COMBIN'],> 'functionCall' => [MathTrig\Combinations::class, 'withoutRepetition'], > 'argumentCount' => '2', > ], > 'COMBINA' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [MathTrig\Combinations::class, 'withRepetition'],'argumentCount' => '2', ], 'COMPLEX' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'COMPLEX'],> 'functionCall' => [Engineering\Complex::class, 'COMPLEX'],'argumentCount' => '2,3', ], 'CONCAT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'CONCATENATE'],> 'functionCall' => [TextData\Concatenate::class, 'CONCATENATE'],'argumentCount' => '1+', ], 'CONCATENATE' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'CONCATENATE'],> 'functionCall' => [TextData\Concatenate::class, 'CONCATENATE'],'argumentCount' => '1+', ], 'CONFIDENCE' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'CONFIDENCE'],> 'functionCall' => [Statistical\Confidence::class, 'CONFIDENCE'], > 'argumentCount' => '3', > ], > 'CONFIDENCE.NORM' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Confidence::class, 'CONFIDENCE'], > 'argumentCount' => '3', > ], > 'CONFIDENCE.T' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'],'argumentCount' => '3', ], 'CONVERT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'CONVERTUOM'],> 'functionCall' => [Engineering\ConvertUOM::class, 'CONVERT'],'argumentCount' => '3', ], 'CORREL' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'CORREL'],> 'functionCall' => [Statistical\Trends::class, 'CORREL'],'argumentCount' => '2', ], 'COS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'cos',> 'functionCall' => [MathTrig\Trig\Cosine::class, 'cos'],'argumentCount' => '1', ], 'COSH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'cosh',> 'functionCall' => [MathTrig\Trig\Cosine::class, 'cosh'],'argumentCount' => '1', ], 'COT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'COT'],> 'functionCall' => [MathTrig\Trig\Cotangent::class, 'cot'],'argumentCount' => '1', ], 'COTH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'COTH'],> 'functionCall' => [MathTrig\Trig\Cotangent::class, 'coth'],'argumentCount' => '1', ], 'COUNT' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'COUNT'],> 'functionCall' => [Statistical\Counts::class, 'COUNT'],'argumentCount' => '1+', ], 'COUNTA' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'COUNTA'],> 'functionCall' => [Statistical\Counts::class, 'COUNTA'],'argumentCount' => '1+', ], 'COUNTBLANK' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'COUNTBLANK'],> 'functionCall' => [Statistical\Counts::class, 'COUNTBLANK'],'argumentCount' => '1', ], 'COUNTIF' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'COUNTIF'],> 'functionCall' => [Statistical\Conditional::class, 'COUNTIF'],'argumentCount' => '2', ], 'COUNTIFS' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'COUNTIFS'],> 'functionCall' => [Statistical\Conditional::class, 'COUNTIFS'],'argumentCount' => '2+', ], 'COUPDAYBS' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'COUPDAYBS'],> 'functionCall' => [Financial\Coupons::class, 'COUPDAYBS'],'argumentCount' => '3,4', ], 'COUPDAYS' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'COUPDAYS'],> 'functionCall' => [Financial\Coupons::class, 'COUPDAYS'],'argumentCount' => '3,4', ], 'COUPDAYSNC' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'COUPDAYSNC'],> 'functionCall' => [Financial\Coupons::class, 'COUPDAYSNC'],'argumentCount' => '3,4', ], 'COUPNCD' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'COUPNCD'],> 'functionCall' => [Financial\Coupons::class, 'COUPNCD'],'argumentCount' => '3,4', ], 'COUPNUM' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'COUPNUM'],> 'functionCall' => [Financial\Coupons::class, 'COUPNUM'],'argumentCount' => '3,4', ], 'COUPPCD' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'COUPPCD'],> 'functionCall' => [Financial\Coupons::class, 'COUPPCD'],'argumentCount' => '3,4', ], 'COVAR' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'COVAR'],> 'functionCall' => [Statistical\Trends::class, 'COVAR'], > 'argumentCount' => '2', > ], > 'COVARIANCE.P' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Trends::class, 'COVAR'], > 'argumentCount' => '2', > ], > 'COVARIANCE.S' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'],'argumentCount' => '2', ], 'CRITBINOM' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'CRITBINOM'],> 'functionCall' => [Statistical\Distributions\Binomial::class, 'inverse'],'argumentCount' => '3', ], 'CSC' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'CSC'],> 'functionCall' => [MathTrig\Trig\Cosecant::class, 'csc'],'argumentCount' => '1', ], 'CSCH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'CSCH'],> 'functionCall' => [MathTrig\Trig\Cosecant::class, 'csch'],'argumentCount' => '1', ], 'CUBEKPIMEMBER' => [ 'category' => Category::CATEGORY_CUBE, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '?', ], 'CUBEMEMBER' => [ 'category' => Category::CATEGORY_CUBE, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '?', ], 'CUBEMEMBERPROPERTY' => [ 'category' => Category::CATEGORY_CUBE, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '?', ], 'CUBERANKEDMEMBER' => [ 'category' => Category::CATEGORY_CUBE, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '?', ], 'CUBESET' => [ 'category' => Category::CATEGORY_CUBE, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '?', ], 'CUBESETCOUNT' => [ 'category' => Category::CATEGORY_CUBE, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '?', ], 'CUBEVALUE' => [ 'category' => Category::CATEGORY_CUBE, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '?', ], 'CUMIPMT' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'CUMIPMT'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic\Cumulative::class, 'interest'],'argumentCount' => '6', ], 'CUMPRINC' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'CUMPRINC'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic\Cumulative::class, 'principal'],'argumentCount' => '6', ], 'DATE' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'DATE'],> 'functionCall' => [DateTimeExcel\Date::class, 'fromYMD'],'argumentCount' => '3', ], 'DATEDIF' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'DATEDIF'],> 'functionCall' => [DateTimeExcel\Difference::class, 'interval'],'argumentCount' => '2,3', ],> 'DATESTRING' => [ 'DATEVALUE' => [ > 'category' => Category::CATEGORY_DATE_AND_TIME, 'category' => Category::CATEGORY_DATE_AND_TIME, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [DateTime::class, 'DATEVALUE'], > 'argumentCount' => '?', 'argumentCount' => '1', > ],< 'functionCall' => [DateTime::class, 'DATEVALUE'],> 'functionCall' => [DateTimeExcel\DateValue::class, 'fromString'],'DAVERAGE' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DAVERAGE'],> 'functionCall' => [Database\DAverage::class, 'evaluate'],'argumentCount' => '3', ], 'DAY' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'DAYOFMONTH'],> 'functionCall' => [DateTimeExcel\DateParts::class, 'day'],'argumentCount' => '1', ], 'DAYS' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'DAYS'],> 'functionCall' => [DateTimeExcel\Days::class, 'between'],'argumentCount' => '2', ], 'DAYS360' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'DAYS360'],> 'functionCall' => [DateTimeExcel\Days360::class, 'between'],'argumentCount' => '2,3', ], 'DB' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'DB'],> 'functionCall' => [Financial\Depreciation::class, 'DB'],'argumentCount' => '4,5', ],> 'DBCS' => [ 'DCOUNT' => [ > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'category' => Category::CATEGORY_DATABASE, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Database::class, 'DCOUNT'], > 'argumentCount' => '1', 'argumentCount' => '3', > ],< 'functionCall' => [Database::class, 'DCOUNT'],> 'functionCall' => [Database\DCount::class, 'evaluate'],'DCOUNTA' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DCOUNTA'],> 'functionCall' => [Database\DCountA::class, 'evaluate'],'argumentCount' => '3', ], 'DDB' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'DDB'],> 'functionCall' => [Financial\Depreciation::class, 'DDB'],'argumentCount' => '4,5', ], 'DEC2BIN' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'DECTOBIN'],> 'functionCall' => [Engineering\ConvertDecimal::class, 'toBinary'],'argumentCount' => '1,2', ], 'DEC2HEX' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'DECTOHEX'],> 'functionCall' => [Engineering\ConvertDecimal::class, 'toHex'],'argumentCount' => '1,2', ], 'DEC2OCT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'DECTOOCT'],> 'functionCall' => [Engineering\ConvertDecimal::class, 'toOctal'],'argumentCount' => '1,2', ],> 'DECIMAL' => [ 'DEGREES' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => 'rad2deg', > 'argumentCount' => '2', 'argumentCount' => '1', > ],< 'functionCall' => 'rad2deg',> 'functionCall' => [MathTrig\Angle::class, 'toDegrees'],'DELTA' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'DELTA'],> 'functionCall' => [Engineering\Compare::class, 'DELTA'],'argumentCount' => '1,2', ], 'DEVSQ' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'DEVSQ'],> 'functionCall' => [Statistical\Deviations::class, 'sumSquares'],'argumentCount' => '1+', ], 'DGET' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DGET'],> 'functionCall' => [Database\DGet::class, 'evaluate'],'argumentCount' => '3', ], 'DISC' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'DISC'],> 'functionCall' => [Financial\Securities\Rates::class, 'discount'],'argumentCount' => '4,5', ], 'DMAX' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DMAX'],> 'functionCall' => [Database\DMax::class, 'evaluate'],'argumentCount' => '3', ], 'DMIN' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DMIN'],> 'functionCall' => [Database\DMin::class, 'evaluate'],'argumentCount' => '3', ], 'DOLLAR' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'DOLLAR'],> 'functionCall' => [TextData\Format::class, 'DOLLAR'],'argumentCount' => '1,2', ], 'DOLLARDE' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'DOLLARDE'],> 'functionCall' => [Financial\Dollar::class, 'decimal'],'argumentCount' => '2', ], 'DOLLARFR' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'DOLLARFR'],> 'functionCall' => [Financial\Dollar::class, 'fractional'],'argumentCount' => '2', ], 'DPRODUCT' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DPRODUCT'],> 'functionCall' => [Database\DProduct::class, 'evaluate'],'argumentCount' => '3', ],> 'DROP' => [ 'DSTDEV' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_DATABASE, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Database::class, 'DSTDEV'], > 'argumentCount' => '2-3', 'argumentCount' => '3', > ],< 'functionCall' => [Database::class, 'DSTDEV'],> 'functionCall' => [Database\DStDev::class, 'evaluate'],'DSTDEVP' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DSTDEVP'],> 'functionCall' => [Database\DStDevP::class, 'evaluate'],'argumentCount' => '3', ], 'DSUM' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DSUM'],> 'functionCall' => [Database\DSum::class, 'evaluate'],'argumentCount' => '3', ], 'DURATION' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '5,6', ], 'DVAR' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DVAR'],> 'functionCall' => [Database\DVar::class, 'evaluate'],'argumentCount' => '3', ], 'DVARP' => [ 'category' => Category::CATEGORY_DATABASE,< 'functionCall' => [Database::class, 'DVARP'],> 'functionCall' => [Database\DVarP::class, 'evaluate'],'argumentCount' => '3', ],> 'ECMA.CEILING' => [ 'EDATE' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_DATE_AND_TIME, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [DateTime::class, 'EDATE'], > 'argumentCount' => '1,2', 'argumentCount' => '2', > ],< 'functionCall' => [DateTime::class, 'EDATE'],> 'functionCall' => [DateTimeExcel\Month::class, 'adjust'],'EFFECT' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'EFFECT'],> 'functionCall' => [Financial\InterestRate::class, 'effective'],'argumentCount' => '2', ],> 'ENCODEURL' => [ 'EOMONTH' => [ > 'category' => Category::CATEGORY_WEB, 'category' => Category::CATEGORY_DATE_AND_TIME, > 'functionCall' => [Web\Service::class, 'urlEncode'], 'functionCall' => [DateTime::class, 'EOMONTH'], > 'argumentCount' => '1', 'argumentCount' => '2', > ],< 'functionCall' => [DateTime::class, 'EOMONTH'],> 'functionCall' => [DateTimeExcel\Month::class, 'lastDay'],'ERF' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'ERF'],> 'functionCall' => [Engineering\Erf::class, 'ERF'],'argumentCount' => '1,2', ], 'ERF.PRECISE' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'ERFPRECISE'],> 'functionCall' => [Engineering\Erf::class, 'ERFPRECISE'],'argumentCount' => '1', ], 'ERFC' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'ERFC'],> 'functionCall' => [Engineering\ErfC::class, 'ERFC'],'argumentCount' => '1', ], 'ERFC.PRECISE' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'ERFC'],> 'functionCall' => [Engineering\ErfC::class, 'ERFC'],'argumentCount' => '1', ], 'ERROR.TYPE' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'errorType'],> 'functionCall' => [Information\ExcelError::class, 'type'],'argumentCount' => '1', ], 'EVEN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'EVEN'],> 'functionCall' => [MathTrig\Round::class, 'even'],'argumentCount' => '1', ], 'EXACT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'EXACT'],> 'functionCall' => [TextData\Text::class, 'exact'],'argumentCount' => '2', ], 'EXP' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'exp',> 'functionCall' => [MathTrig\Exp::class, 'evaluate'],'argumentCount' => '1', ],> 'EXPAND' => [ 'EXPONDIST' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Statistical::class, 'EXPONDIST'], > 'argumentCount' => '2-4', 'argumentCount' => '3', > ],< 'functionCall' => [Statistical::class, 'EXPONDIST'],> 'functionCall' => [Statistical\Distributions\Exponential::class, 'distribution'], > 'argumentCount' => '3', > ], > 'EXPON.DIST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Exponential::class, 'distribution'],'FACT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'FACT'],> 'functionCall' => [MathTrig\Factorial::class, 'fact'],'argumentCount' => '1', ], 'FACTDOUBLE' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'FACTDOUBLE'],> 'functionCall' => [MathTrig\Factorial::class, 'factDouble'],'argumentCount' => '1', ], 'FALSE' => [ 'category' => Category::CATEGORY_LOGICAL,< 'functionCall' => [Logical::class, 'FALSE'],> 'functionCall' => [Logical\Boolean::class, 'FALSE'],'argumentCount' => '0', ], 'FDIST' => [ 'category' => Category::CATEGORY_STATISTICAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '3', ],> 'F.DIST' => [ 'FIND' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'functionCall' => [Statistical\Distributions\F::class, 'distribution'], 'functionCall' => [TextData::class, 'SEARCHSENSITIVE'], > 'argumentCount' => '4', 'argumentCount' => '2,3', > ], ], > 'F.DIST.RT' => [ 'FINDB' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [TextData::class, 'SEARCHSENSITIVE'], > 'argumentCount' => '3', 'argumentCount' => '2,3', > ], ], > 'FILTER' => [ 'FINV' => [ > 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [LookupRef\Filter::class, 'filter'], 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2-3', 'argumentCount' => '3', > ], ], > 'FILTERXML' => [ 'FISHER' => [ > 'category' => Category::CATEGORY_WEB, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Statistical::class, 'FISHER'], > 'argumentCount' => '2', 'argumentCount' => '1', > ],< 'functionCall' => [TextData::class, 'SEARCHSENSITIVE'],> 'functionCall' => [TextData\Search::class, 'sensitive'],< 'functionCall' => [TextData::class, 'SEARCHSENSITIVE'],> 'functionCall' => [TextData\Search::class, 'sensitive'],'category' => Category::CATEGORY_STATISTICAL,> 'F.INV' => [ 'functionCall' => [Statistical::class, 'FISHERINV'], > 'category' => Category::CATEGORY_STATISTICAL, 'argumentCount' => '1', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '3', 'FIXED' => [ > ], 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'F.INV.RT' => [ 'functionCall' => [TextData::class, 'FIXEDFORMAT'], > 'category' => Category::CATEGORY_STATISTICAL, 'argumentCount' => '1-3', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '3', 'FLOOR' => [ > ],< 'functionCall' => [Statistical::class, 'FISHER'],> 'functionCall' => [Statistical\Distributions\Fisher::class, 'distribution'],< 'functionCall' => [Statistical::class, 'FISHERINV'],> 'functionCall' => [Statistical\Distributions\Fisher::class, 'inverse'],< 'functionCall' => [TextData::class, 'FIXEDFORMAT'],> 'functionCall' => [TextData\Format::class, 'FIXEDFORMAT'],< 'functionCall' => [MathTrig::class, 'FLOOR'], < 'argumentCount' => '2',> 'functionCall' => [MathTrig\Floor::class, 'floor'], > 'argumentCount' => '1-2', // Excel requries 2, Ods/Gnumeric 1-2 > ], > 'FLOOR.MATH' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [MathTrig\Floor::class, 'math'], > 'argumentCount' => '1-3', > ], > 'FLOOR.PRECISE' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [MathTrig\Floor::class, 'precise'], > 'argumentCount' => '1-2','category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'FORECAST'],> 'functionCall' => [Statistical\Trends::class, 'FORECAST'], > 'argumentCount' => '3', > ], > 'FORECAST.ETS' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '3-6', > ], > 'FORECAST.ETS.CONFINT' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '3-6', > ], > 'FORECAST.ETS.SEASONALITY' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2-4', > ], > 'FORECAST.ETS.STAT' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '3-6', > ], > 'FORECAST.LINEAR' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Trends::class, 'FORECAST'],'argumentCount' => '3', ], 'FORMULATEXT' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'FORMULATEXT'],> 'functionCall' => [LookupRef\Formula::class, 'text'],'argumentCount' => '1', 'passCellReference' => true, 'passByReference' => [true], ], 'FREQUENCY' => [ 'category' => Category::CATEGORY_STATISTICAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '2', ], 'FTEST' => [ 'category' => Category::CATEGORY_STATISTICAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '2', ],> 'F.TEST' => [ 'FV' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_FINANCIAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Financial::class, 'FV'], > 'argumentCount' => '2', 'argumentCount' => '3-5', > ],< 'functionCall' => [Financial::class, 'FV'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic::class, 'futureValue'],'FVSCHEDULE' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'FVSCHEDULE'],> 'functionCall' => [Financial\CashFlow\Single::class, 'futureValue'],'argumentCount' => '2', ],> 'GAMMA' => [ 'GAMMADIST' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Gamma::class, 'gamma'], 'functionCall' => [Statistical::class, 'GAMMADIST'], > 'argumentCount' => '1', 'argumentCount' => '4', > ],< 'functionCall' => [Statistical::class, 'GAMMADIST'],> 'functionCall' => [Statistical\Distributions\Gamma::class, 'distribution'], > 'argumentCount' => '4', > ], > 'GAMMA.DIST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Gamma::class, 'distribution'],'GAMMAINV' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'GAMMAINV'],> 'functionCall' => [Statistical\Distributions\Gamma::class, 'inverse'], > 'argumentCount' => '3', > ], > 'GAMMA.INV' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Gamma::class, 'inverse'],'argumentCount' => '3', ], 'GAMMALN' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'GAMMALN'],> 'functionCall' => [Statistical\Distributions\Gamma::class, 'ln'], > 'argumentCount' => '1', > ], > 'GAMMALN.PRECISE' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Gamma::class, 'ln'], > 'argumentCount' => '1', > ], > 'GAUSS' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\StandardNormal::class, 'gauss'],'argumentCount' => '1', ], 'GCD' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'GCD'],> 'functionCall' => [MathTrig\Gcd::class, 'evaluate'],'argumentCount' => '1+', ], 'GEOMEAN' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'GEOMEAN'],> 'functionCall' => [Statistical\Averages\Mean::class, 'geometric'],'argumentCount' => '1+', ], 'GESTEP' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'GESTEP'],> 'functionCall' => [Engineering\Compare::class, 'GESTEP'],'argumentCount' => '1,2', ], 'GETPIVOTDATA' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '2+', ], 'GROWTH' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'GROWTH'],> 'functionCall' => [Statistical\Trends::class, 'GROWTH'],'argumentCount' => '1-4', ], 'HARMEAN' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'HARMEAN'],> 'functionCall' => [Statistical\Averages\Mean::class, 'harmonic'],'argumentCount' => '1+', ], 'HEX2BIN' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'HEXTOBIN'],> 'functionCall' => [Engineering\ConvertHex::class, 'toBinary'],'argumentCount' => '1,2', ], 'HEX2DEC' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'HEXTODEC'],> 'functionCall' => [Engineering\ConvertHex::class, 'toDecimal'],'argumentCount' => '1', ], 'HEX2OCT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'HEXTOOCT'],> 'functionCall' => [Engineering\ConvertHex::class, 'toOctal'],'argumentCount' => '1,2', ], 'HLOOKUP' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'HLOOKUP'],> 'functionCall' => [LookupRef\HLookup::class, 'lookup'],'argumentCount' => '3,4', ], 'HOUR' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'HOUROFDAY'],> 'functionCall' => [DateTimeExcel\TimeParts::class, 'hour'],'argumentCount' => '1', ],> 'HSTACK' => [ 'HYPERLINK' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [LookupRef::class, 'HYPERLINK'], > 'argumentCount' => '1+', 'argumentCount' => '1,2', > ],< 'functionCall' => [LookupRef::class, 'HYPERLINK'],> 'functionCall' => [LookupRef\Hyperlink::class, 'set'],], 'HYPGEOMDIST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'HYPGEOMDIST'],> 'functionCall' => [Statistical\Distributions\HyperGeometric::class, 'distribution'],'argumentCount' => '4', ],> 'HYPGEOM.DIST' => [ 'IF' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_LOGICAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Logical::class, 'statementIf'], > 'argumentCount' => '5', 'argumentCount' => '1-3', > ],< 'functionCall' => [Logical::class, 'statementIf'],> 'functionCall' => [Logical\Conditional::class, 'statementIf'],'IFERROR' => [ 'category' => Category::CATEGORY_LOGICAL,< 'functionCall' => [Logical::class, 'IFERROR'],> 'functionCall' => [Logical\Conditional::class, 'IFERROR'],'argumentCount' => '2', ], 'IFNA' => [ 'category' => Category::CATEGORY_LOGICAL,< 'functionCall' => [Logical::class, 'IFNA'],> 'functionCall' => [Logical\Conditional::class, 'IFNA'],'argumentCount' => '2', ],> 'IFS' => [ 'IMABS' => [ > 'category' => Category::CATEGORY_LOGICAL, 'category' => Category::CATEGORY_ENGINEERING, > 'functionCall' => [Logical\Conditional::class, 'IFS'], 'functionCall' => [Engineering::class, 'IMABS'], > 'argumentCount' => '2+', 'argumentCount' => '1', > ],< 'functionCall' => [Engineering::class, 'IMABS'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMABS'],'IMAGINARY' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMAGINARY'],> 'functionCall' => [Engineering\Complex::class, 'IMAGINARY'],'argumentCount' => '1', ], 'IMARGUMENT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMARGUMENT'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMARGUMENT'],'argumentCount' => '1', ], 'IMCONJUGATE' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMCONJUGATE'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCONJUGATE'],'argumentCount' => '1', ], 'IMCOS' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMCOS'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCOS'],'argumentCount' => '1', ], 'IMCOSH' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMCOSH'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCOSH'],'argumentCount' => '1', ], 'IMCOT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMCOT'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCOT'],'argumentCount' => '1', ], 'IMCSC' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMCSC'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCSC'],'argumentCount' => '1', ], 'IMCSCH' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMCSCH'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMCSCH'],'argumentCount' => '1', ], 'IMDIV' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMDIV'],> 'functionCall' => [Engineering\ComplexOperations::class, 'IMDIV'],'argumentCount' => '2', ], 'IMEXP' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMEXP'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMEXP'],'argumentCount' => '1', ], 'IMLN' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMLN'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMLN'],'argumentCount' => '1', ], 'IMLOG10' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMLOG10'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMLOG10'],'argumentCount' => '1', ], 'IMLOG2' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMLOG2'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMLOG2'],'argumentCount' => '1', ], 'IMPOWER' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMPOWER'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMPOWER'],'argumentCount' => '2', ], 'IMPRODUCT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMPRODUCT'],> 'functionCall' => [Engineering\ComplexOperations::class, 'IMPRODUCT'],'argumentCount' => '1+', ], 'IMREAL' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMREAL'],> 'functionCall' => [Engineering\Complex::class, 'IMREAL'],'argumentCount' => '1', ], 'IMSEC' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMSEC'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSEC'],'argumentCount' => '1', ], 'IMSECH' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMSECH'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSECH'],'argumentCount' => '1', ], 'IMSIN' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMSIN'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSIN'],'argumentCount' => '1', ], 'IMSINH' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMSINH'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSINH'],'argumentCount' => '1', ], 'IMSQRT' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMSQRT'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMSQRT'],'argumentCount' => '1', ], 'IMSUB' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMSUB'],> 'functionCall' => [Engineering\ComplexOperations::class, 'IMSUB'],'argumentCount' => '2', ], 'IMSUM' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMSUM'],> 'functionCall' => [Engineering\ComplexOperations::class, 'IMSUM'],'argumentCount' => '1+', ], 'IMTAN' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'IMTAN'],> 'functionCall' => [Engineering\ComplexFunctions::class, 'IMTAN'],'argumentCount' => '1', ], 'INDEX' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'INDEX'], < 'argumentCount' => '1-4',> 'functionCall' => [LookupRef\Matrix::class, 'index'], > 'argumentCount' => '2-4',], 'INDIRECT' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'INDIRECT'],> 'functionCall' => [LookupRef\Indirect::class, 'INDIRECT'],'argumentCount' => '1,2', 'passCellReference' => true, ], 'INFO' => [ 'category' => Category::CATEGORY_INFORMATION, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1', ], 'INT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'INT'],> 'functionCall' => [MathTrig\IntClass::class, 'evaluate'],'argumentCount' => '1', ], 'INTERCEPT' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'INTERCEPT'],> 'functionCall' => [Statistical\Trends::class, 'INTERCEPT'],'argumentCount' => '2', ], 'INTRATE' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'INTRATE'],> 'functionCall' => [Financial\Securities\Rates::class, 'interest'],'argumentCount' => '4,5', ], 'IPMT' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'IPMT'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic\Interest::class, 'payment'],'argumentCount' => '4-6', ], 'IRR' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'IRR'],> 'functionCall' => [Financial\CashFlow\Variable\Periodic::class, 'rate'],'argumentCount' => '1,2', ], 'ISBLANK' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isBlank'],> 'functionCall' => [Information\Value::class, 'isBlank'],'argumentCount' => '1', ], 'ISERR' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isErr'],> 'functionCall' => [Information\ErrorValue::class, 'isErr'],'argumentCount' => '1', ], 'ISERROR' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isError'],> 'functionCall' => [Information\ErrorValue::class, 'isError'],'argumentCount' => '1', ], 'ISEVEN' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isEven'],> 'functionCall' => [Information\Value::class, 'isEven'],'argumentCount' => '1', ], 'ISFORMULA' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isFormula'],> 'functionCall' => [Information\Value::class, 'isFormula'],'argumentCount' => '1', 'passCellReference' => true, 'passByReference' => [true], ], 'ISLOGICAL' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isLogical'],> 'functionCall' => [Information\Value::class, 'isLogical'],'argumentCount' => '1', ], 'ISNA' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isNa'],> 'functionCall' => [Information\ErrorValue::class, 'isNa'],'argumentCount' => '1', ], 'ISNONTEXT' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isNonText'],> 'functionCall' => [Information\Value::class, 'isNonText'],'argumentCount' => '1', ], 'ISNUMBER' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isNumber'],> 'functionCall' => [Information\Value::class, 'isNumber'],'argumentCount' => '1', ],> 'ISO.CEILING' => [ 'ISODD' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_INFORMATION, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Functions::class, 'isOdd'], > 'argumentCount' => '1,2', 'argumentCount' => '1', > ],< 'functionCall' => [Functions::class, 'isOdd'],> 'functionCall' => [Information\Value::class, 'isOdd'],'ISOWEEKNUM' => [> 'ISOMITTED' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, > 'category' => Category::CATEGORY_INFORMATION, 'functionCall' => [DateTime::class, 'ISOWEEKNUM'], > 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1', > 'argumentCount' => '*', ], > ],< 'functionCall' => [DateTime::class, 'ISOWEEKNUM'],> 'functionCall' => [DateTimeExcel\Week::class, 'isoWeekNumber'],'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'ISPMT'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic\Interest::class, 'schedulePayment'],'argumentCount' => '4', ], 'ISREF' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'DUMMY'],> 'functionCall' => [Information\Value::class, 'isRef'],'argumentCount' => '1',> 'passCellReference' => true, ], > 'passByReference' => [true],'ISTEXT' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'isText'],> 'functionCall' => [Information\Value::class, 'isText'],'argumentCount' => '1', ],> 'ISTHAIDIGIT' => [ 'JIS' => [ > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '?', 'argumentCount' => '1', > ],], 'KURT' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'KURT'],> 'functionCall' => [Statistical\Deviations::class, 'kurtosis'],'argumentCount' => '1+', ],> 'LAMBDA' => [ 'LARGE' => [ > 'category' => Category::CATEGORY_LOGICAL, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Statistical::class, 'LARGE'], > 'argumentCount' => '*', 'argumentCount' => '2', > ],< 'functionCall' => [Statistical::class, 'LARGE'],> 'functionCall' => [Statistical\Size::class, 'large'],'LCM' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'LCM'],> 'functionCall' => [MathTrig\Lcm::class, 'evaluate'],'argumentCount' => '1+', ], 'LEFT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'LEFT'],> 'functionCall' => [TextData\Extract::class, 'left'],'argumentCount' => '1,2', ], 'LEFTB' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'LEFT'],> 'functionCall' => [TextData\Extract::class, 'left'],'argumentCount' => '1,2', ], 'LEN' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'STRINGLENGTH'],> 'functionCall' => [TextData\Text::class, 'length'],'argumentCount' => '1', ], 'LENB' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'STRINGLENGTH'],> 'functionCall' => [TextData\Text::class, 'length'],'argumentCount' => '1', ],> 'LET' => [ 'LINEST' => [ > 'category' => Category::CATEGORY_LOGICAL, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Statistical::class, 'LINEST'], > 'argumentCount' => '*', 'argumentCount' => '1-4', > ],< 'functionCall' => [Statistical::class, 'LINEST'],> 'functionCall' => [Statistical\Trends::class, 'LINEST'],'LN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'log',> 'functionCall' => [MathTrig\Logarithms::class, 'natural'],'argumentCount' => '1', ], 'LOG' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'logBase'],> 'functionCall' => [MathTrig\Logarithms::class, 'withBase'],'argumentCount' => '1,2', ], 'LOG10' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'log10',> 'functionCall' => [MathTrig\Logarithms::class, 'base10'],'argumentCount' => '1', ], 'LOGEST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'LOGEST'],> 'functionCall' => [Statistical\Trends::class, 'LOGEST'],'argumentCount' => '1-4', ], 'LOGINV' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'LOGINV'],> 'functionCall' => [Statistical\Distributions\LogNormal::class, 'inverse'],'argumentCount' => '3', ], 'LOGNORMDIST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'LOGNORMDIST'],> 'functionCall' => [Statistical\Distributions\LogNormal::class, 'cumulative'], > 'argumentCount' => '3', > ], > 'LOGNORM.DIST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\LogNormal::class, 'distribution'], > 'argumentCount' => '4', > ], > 'LOGNORM.INV' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\LogNormal::class, 'inverse'],'argumentCount' => '3', ], 'LOOKUP' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'LOOKUP'],> 'functionCall' => [LookupRef\Lookup::class, 'lookup'],'argumentCount' => '2,3', ], 'LOWER' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'LOWERCASE'],> 'functionCall' => [TextData\CaseConvert::class, 'lower'],'argumentCount' => '1', ],> 'MAKEARRAY' => [ 'MATCH' => [ > 'category' => Category::CATEGORY_LOGICAL, 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [LookupRef::class, 'MATCH'], > 'argumentCount' => '*', 'argumentCount' => '2,3', > ], ], > 'MAP' => [ 'MAX' => [ > 'category' => Category::CATEGORY_LOGICAL, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Statistical::class, 'MAX'], > 'argumentCount' => '*', 'argumentCount' => '1+', > ],< 'functionCall' => [LookupRef::class, 'MATCH'],> 'functionCall' => [LookupRef\ExcelMatch::class, 'MATCH'],< 'functionCall' => [Statistical::class, 'MAX'],> 'functionCall' => [Statistical\Maximum::class, 'max'],'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'MAXA'],> 'functionCall' => [Statistical\Maximum::class, 'maxA'],'argumentCount' => '1+', ], 'MAXIFS' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'MAXIFS'],> 'functionCall' => [Statistical\Conditional::class, 'MAXIFS'],'argumentCount' => '3+', ], 'MDETERM' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'MDETERM'],> 'functionCall' => [MathTrig\MatrixFunctions::class, 'determinant'],'argumentCount' => '1', ], 'MDURATION' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '5,6', ], 'MEDIAN' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'MEDIAN'],> 'functionCall' => [Statistical\Averages::class, 'median'],'argumentCount' => '1+', ], 'MEDIANIF' => [ 'category' => Category::CATEGORY_STATISTICAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '2+', ], 'MID' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'MID'],> 'functionCall' => [TextData\Extract::class, 'mid'],'argumentCount' => '3', ], 'MIDB' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'MID'],> 'functionCall' => [TextData\Extract::class, 'mid'],'argumentCount' => '3', ], 'MIN' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'MIN'],> 'functionCall' => [Statistical\Minimum::class, 'min'],'argumentCount' => '1+', ], 'MINA' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'MINA'],> 'functionCall' => [Statistical\Minimum::class, 'minA'],'argumentCount' => '1+', ], 'MINIFS' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'MINIFS'],> 'functionCall' => [Statistical\Conditional::class, 'MINIFS'],'argumentCount' => '3+', ], 'MINUTE' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'MINUTE'],> 'functionCall' => [DateTimeExcel\TimeParts::class, 'minute'],'argumentCount' => '1', ], 'MINVERSE' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'MINVERSE'],> 'functionCall' => [MathTrig\MatrixFunctions::class, 'inverse'],'argumentCount' => '1', ], 'MIRR' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'MIRR'],> 'functionCall' => [Financial\CashFlow\Variable\Periodic::class, 'modifiedRate'],'argumentCount' => '3', ], 'MMULT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'MMULT'],> 'functionCall' => [MathTrig\MatrixFunctions::class, 'multiply'],'argumentCount' => '2', ], 'MOD' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'MOD'],> 'functionCall' => [MathTrig\Operations::class, 'mod'],'argumentCount' => '2', ], 'MODE' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'MODE'],> 'functionCall' => [Statistical\Averages::class, 'mode'], > 'argumentCount' => '1+', > ], > 'MODE.MULT' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'],'argumentCount' => '1+', ], 'MODE.SNGL' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'MODE'],> 'functionCall' => [Statistical\Averages::class, 'mode'],'argumentCount' => '1+', ], 'MONTH' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'MONTHOFYEAR'],> 'functionCall' => [DateTimeExcel\DateParts::class, 'month'],'argumentCount' => '1', ], 'MROUND' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'MROUND'],> 'functionCall' => [MathTrig\Round::class, 'multiple'],'argumentCount' => '2', ], 'MULTINOMIAL' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'MULTINOMIAL'],> 'functionCall' => [MathTrig\Factorial::class, 'multinomial'],'argumentCount' => '1+', ],> 'MUNIT' => [ 'N' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_INFORMATION, > 'functionCall' => [MathTrig\MatrixFunctions::class, 'identity'], 'functionCall' => [Functions::class, 'n'], > 'argumentCount' => '1', 'argumentCount' => '1', > ],< 'functionCall' => [Functions::class, 'n'],> 'functionCall' => [Information\Value::class, 'asNumber'],'NA' => [ 'category' => Category::CATEGORY_INFORMATION,< 'functionCall' => [Functions::class, 'NA'],> 'functionCall' => [Information\ExcelError::class, 'NA'],'argumentCount' => '0', ], 'NEGBINOMDIST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'NEGBINOMDIST'],> 'functionCall' => [Statistical\Distributions\Binomial::class, 'negative'],'argumentCount' => '3', ],> 'NEGBINOM.DIST' => [ 'NETWORKDAYS' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_DATE_AND_TIME, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [DateTime::class, 'NETWORKDAYS'], > 'argumentCount' => '4', 'argumentCount' => '2+', > ],< 'functionCall' => [DateTime::class, 'NETWORKDAYS'], < 'argumentCount' => '2+',> 'functionCall' => [DateTimeExcel\NetworkDays::class, 'count'], > 'argumentCount' => '2-3', > ], > 'NETWORKDAYS.INTL' => [ > 'category' => Category::CATEGORY_DATE_AND_TIME, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2-4','category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'NOMINAL'],> 'functionCall' => [Financial\InterestRate::class, 'nominal'],'argumentCount' => '2', ], 'NORMDIST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'NORMDIST'],> 'functionCall' => [Statistical\Distributions\Normal::class, 'distribution'], > 'argumentCount' => '4', > ], > 'NORM.DIST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Normal::class, 'distribution'],'argumentCount' => '4', ], 'NORMINV' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'NORMINV'],> 'functionCall' => [Statistical\Distributions\Normal::class, 'inverse'], > 'argumentCount' => '3', > ], > 'NORM.INV' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Normal::class, 'inverse'],'argumentCount' => '3', ], 'NORMSDIST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'NORMSDIST'],> 'functionCall' => [Statistical\Distributions\StandardNormal::class, 'cumulative'],'argumentCount' => '1', ],> 'NORM.S.DIST' => [ 'NORMSINV' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\StandardNormal::class, 'distribution'], 'functionCall' => [Statistical::class, 'NORMSINV'], > 'argumentCount' => '1,2', 'argumentCount' => '1', > ],< 'functionCall' => [Statistical::class, 'NORMSINV'],> 'functionCall' => [Statistical\Distributions\StandardNormal::class, 'inverse'], > 'argumentCount' => '1', > ], > 'NORM.S.INV' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\StandardNormal::class, 'inverse'],'NOT' => [ 'category' => Category::CATEGORY_LOGICAL,< 'functionCall' => [Logical::class, 'NOT'],> 'functionCall' => [Logical\Operations::class, 'NOT'],'argumentCount' => '1', ], 'NOW' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'DATETIMENOW'],> 'functionCall' => [DateTimeExcel\Current::class, 'now'],'argumentCount' => '0', ], 'NPER' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'NPER'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic::class, 'periods'],'argumentCount' => '3-5', ], 'NPV' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'NPV'],> 'functionCall' => [Financial\CashFlow\Variable\Periodic::class, 'presentValue'],'argumentCount' => '2+', ],> 'NUMBERSTRING' => [ 'NUMBERVALUE' => [ > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [TextData::class, 'NUMBERVALUE'], > 'argumentCount' => '?', 'argumentCount' => '1+', > ],< 'functionCall' => [TextData::class, 'NUMBERVALUE'],> 'functionCall' => [TextData\Format::class, 'NUMBERVALUE'],'OCT2BIN' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'OCTTOBIN'],> 'functionCall' => [Engineering\ConvertOctal::class, 'toBinary'],'argumentCount' => '1,2', ], 'OCT2DEC' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'OCTTODEC'],> 'functionCall' => [Engineering\ConvertOctal::class, 'toDecimal'],'argumentCount' => '1', ], 'OCT2HEX' => [ 'category' => Category::CATEGORY_ENGINEERING,< 'functionCall' => [Engineering::class, 'OCTTOHEX'],> 'functionCall' => [Engineering\ConvertOctal::class, 'toHex'],'argumentCount' => '1,2', ], 'ODD' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'ODD'],> 'functionCall' => [MathTrig\Round::class, 'odd'],'argumentCount' => '1', ], 'ODDFPRICE' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '8,9', ], 'ODDFYIELD' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '8,9', ], 'ODDLPRICE' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '7,8', ], 'ODDLYIELD' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '7,8', ], 'OFFSET' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'OFFSET'],> 'functionCall' => [LookupRef\Offset::class, 'OFFSET'],'argumentCount' => '3-5', 'passCellReference' => true, 'passByReference' => [true], ], 'OR' => [ 'category' => Category::CATEGORY_LOGICAL,< 'functionCall' => [Logical::class, 'logicalOr'],> 'functionCall' => [Logical\Operations::class, 'logicalOr'],'argumentCount' => '1+', ], 'PDURATION' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'PDURATION'],> 'functionCall' => [Financial\CashFlow\Single::class, 'periods'],'argumentCount' => '3', ], 'PEARSON' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'CORREL'],> 'functionCall' => [Statistical\Trends::class, 'CORREL'],'argumentCount' => '2', ], 'PERCENTILE' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'PERCENTILE'],> 'functionCall' => [Statistical\Percentiles::class, 'PERCENTILE'], > 'argumentCount' => '2', > ], > 'PERCENTILE.EXC' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2', > ], > 'PERCENTILE.INC' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Percentiles::class, 'PERCENTILE'],'argumentCount' => '2', ], 'PERCENTRANK' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'PERCENTRANK'],> 'functionCall' => [Statistical\Percentiles::class, 'PERCENTRANK'], > 'argumentCount' => '2,3', > ], > 'PERCENTRANK.EXC' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2,3', > ], > 'PERCENTRANK.INC' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Percentiles::class, 'PERCENTRANK'],'argumentCount' => '2,3', ], 'PERMUT' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'PERMUT'],> 'functionCall' => [Statistical\Permutations::class, 'PERMUT'], > 'argumentCount' => '2', > ], > 'PERMUTATIONA' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Permutations::class, 'PERMUTATIONA'],'argumentCount' => '2', ], 'PHONETIC' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1', ],> 'PHI' => [ 'PI' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => 'pi', > 'argumentCount' => '1', 'argumentCount' => '0', > ],], 'PMT' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'PMT'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic\Payments::class, 'annuity'],'argumentCount' => '3-5', ], 'POISSON' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'POISSON'],> 'functionCall' => [Statistical\Distributions\Poisson::class, 'distribution'], > 'argumentCount' => '3', > ], > 'POISSON.DIST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Poisson::class, 'distribution'],'argumentCount' => '3', ], 'POWER' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'POWER'],> 'functionCall' => [MathTrig\Operations::class, 'power'],'argumentCount' => '2', ], 'PPMT' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'PPMT'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic\Payments::class, 'interestPayment'],'argumentCount' => '4-6', ], 'PRICE' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'PRICE'],> 'functionCall' => [Financial\Securities\Price::class, 'price'],'argumentCount' => '6,7', ], 'PRICEDISC' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'PRICEDISC'],> 'functionCall' => [Financial\Securities\Price::class, 'priceDiscounted'],'argumentCount' => '4,5', ], 'PRICEMAT' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'PRICEMAT'],> 'functionCall' => [Financial\Securities\Price::class, 'priceAtMaturity'],'argumentCount' => '5,6', ], 'PROB' => [ 'category' => Category::CATEGORY_STATISTICAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '3,4', ], 'PRODUCT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'PRODUCT'],> 'functionCall' => [MathTrig\Operations::class, 'product'],'argumentCount' => '1+', ], 'PROPER' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'PROPERCASE'],> 'functionCall' => [TextData\CaseConvert::class, 'proper'],'argumentCount' => '1', ], 'PV' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'PV'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic::class, 'presentValue'],'argumentCount' => '3-5', ], 'QUARTILE' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'QUARTILE'],> 'functionCall' => [Statistical\Percentiles::class, 'QUARTILE'], > 'argumentCount' => '2', > ], > 'QUARTILE.EXC' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2', > ], > 'QUARTILE.INC' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Percentiles::class, 'QUARTILE'],'argumentCount' => '2', ], 'QUOTIENT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'QUOTIENT'],> 'functionCall' => [MathTrig\Operations::class, 'quotient'],'argumentCount' => '2', ], 'RADIANS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'deg2rad',> 'functionCall' => [MathTrig\Angle::class, 'toRadians'],'argumentCount' => '1', ], 'RAND' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'RAND'],> 'functionCall' => [MathTrig\Random::class, 'rand'],'argumentCount' => '0', ],> 'RANDARRAY' => [ 'RANDBETWEEN' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [MathTrig\Random::class, 'randArray'], 'functionCall' => [MathTrig::class, 'RAND'], > 'argumentCount' => '0-5', 'argumentCount' => '2', > ],< 'functionCall' => [MathTrig::class, 'RAND'],> 'functionCall' => [MathTrig\Random::class, 'randBetween'],'RANK' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'RANK'],> 'functionCall' => [Statistical\Percentiles::class, 'RANK'], > 'argumentCount' => '2,3', > ], > 'RANK.AVG' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2,3', > ], > 'RANK.EQ' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Percentiles::class, 'RANK'],'argumentCount' => '2,3', ], 'RATE' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'RATE'],> 'functionCall' => [Financial\CashFlow\Constant\Periodic\Interest::class, 'rate'],'argumentCount' => '3-6', ], 'RECEIVED' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'RECEIVED'],> 'functionCall' => [Financial\Securities\Price::class, 'received'],'argumentCount' => '4-5', ],> 'REDUCE' => [ 'REPLACE' => [ > 'category' => Category::CATEGORY_LOGICAL, 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [TextData::class, 'REPLACE'], > 'argumentCount' => '*', 'argumentCount' => '4', > ],< 'functionCall' => [TextData::class, 'REPLACE'],> 'functionCall' => [TextData\Replace::class, 'replace'],'REPLACEB' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'REPLACE'],> 'functionCall' => [TextData\Replace::class, 'replace'],'argumentCount' => '4', ], 'REPT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => 'str_repeat',> 'functionCall' => [TextData\Concatenate::class, 'builtinREPT'],'argumentCount' => '2', ], 'RIGHT' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'RIGHT'],> 'functionCall' => [TextData\Extract::class, 'right'],'argumentCount' => '1,2', ], 'RIGHTB' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'RIGHT'],> 'functionCall' => [TextData\Extract::class, 'right'],'argumentCount' => '1,2', ], 'ROMAN' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'ROMAN'],> 'functionCall' => [MathTrig\Roman::class, 'evaluate'],'argumentCount' => '1,2', ], 'ROUND' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'round',> 'functionCall' => [MathTrig\Round::class, 'round'],'argumentCount' => '2', ],> 'ROUNDBAHTDOWN' => [ 'ROUNDDOWN' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [MathTrig::class, 'ROUNDDOWN'], > 'argumentCount' => '?', 'argumentCount' => '2', > ], ], > 'ROUNDBAHTUP' => [ 'ROUNDUP' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [MathTrig::class, 'ROUNDUP'], > 'argumentCount' => '?', 'argumentCount' => '2', > ],< 'functionCall' => [MathTrig::class, 'ROUNDDOWN'],> 'functionCall' => [MathTrig\Round::class, 'down'],< 'functionCall' => [MathTrig::class, 'ROUNDUP'],> 'functionCall' => [MathTrig\Round::class, 'up'],'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'ROW'],> 'functionCall' => [LookupRef\RowColumnInformation::class, 'ROW'],'argumentCount' => '-1',> 'passCellReference' => true,'passByReference' => [true], ], 'ROWS' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'ROWS'],> 'functionCall' => [LookupRef\RowColumnInformation::class, 'ROWS'],'argumentCount' => '1', ], 'RRI' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'RRI'],> 'functionCall' => [Financial\CashFlow\Single::class, 'interestRate'],'argumentCount' => '3', ], 'RSQ' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'RSQ'],> 'functionCall' => [Statistical\Trends::class, 'RSQ'],'argumentCount' => '2', ], 'RTD' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1+', ], 'SEARCH' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'SEARCHINSENSITIVE'],> 'functionCall' => [TextData\Search::class, 'insensitive'],'argumentCount' => '2,3', ],> 'SCAN' => [ 'SEARCHB' => [ > 'category' => Category::CATEGORY_LOGICAL, 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [TextData::class, 'SEARCHINSENSITIVE'], > 'argumentCount' => '*', 'argumentCount' => '2,3', > ],< 'functionCall' => [TextData::class, 'SEARCHINSENSITIVE'],> 'functionCall' => [TextData\Search::class, 'insensitive'],'SEC' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SEC'],> 'functionCall' => [MathTrig\Trig\Secant::class, 'sec'],'argumentCount' => '1', ], 'SECH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SECH'],> 'functionCall' => [MathTrig\Trig\Secant::class, 'sech'],'argumentCount' => '1', ], 'SECOND' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'SECOND'],> 'functionCall' => [DateTimeExcel\TimeParts::class, 'second'],'argumentCount' => '1', ],> 'SEQUENCE' => [ 'SERIESSUM' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [MathTrig\MatrixFunctions::class, 'sequence'], 'functionCall' => [MathTrig::class, 'SERIESSUM'], > 'argumentCount' => '1-4', 'argumentCount' => '4', > ],< 'functionCall' => [MathTrig::class, 'SERIESSUM'],> 'functionCall' => [MathTrig\SeriesSum::class, 'evaluate'],'SIGN' => [> 'SHEET' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'category' => Category::CATEGORY_INFORMATION, 'functionCall' => [MathTrig::class, 'SIGN'], > 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1', > 'argumentCount' => '0,1', ], > ], 'SIN' => [ > 'SHEETS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'category' => Category::CATEGORY_INFORMATION, 'functionCall' => 'sin', > 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1', > 'argumentCount' => '0,1', ], > ],< 'functionCall' => [MathTrig::class, 'SIGN'],> 'functionCall' => [MathTrig\Sign::class, 'evaluate'],< 'functionCall' => 'sin',> 'functionCall' => [MathTrig\Trig\Sine::class, 'sin'],'functionCall' => 'sinh',> 'SINGLE' => [ 'argumentCount' => '1', > 'category' => Category::CATEGORY_UNCATEGORISED, ], > 'functionCall' => [Functions::class, 'DUMMY'], 'SKEW' => [ > 'argumentCount' => '*', 'category' => Category::CATEGORY_STATISTICAL, > ],< 'functionCall' => 'sinh',> 'functionCall' => [MathTrig\Trig\Sine::class, 'sinh'],< 'functionCall' => [Statistical::class, 'SKEW'],> 'functionCall' => [Statistical\Deviations::class, 'skew'], > 'argumentCount' => '1+', > ], > 'SKEW.P' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'],], 'SLN' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'SLN'],> 'functionCall' => [Financial\Depreciation::class, 'SLN'],'argumentCount' => '3', ], 'SLOPE' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'SLOPE'],> 'functionCall' => [Statistical\Trends::class, 'SLOPE'],'argumentCount' => '2', ], 'SMALL' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'SMALL'],> 'functionCall' => [Statistical\Size::class, 'small'],'argumentCount' => '2', ],> 'SORT' => [ 'SQRT' => [ > 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [LookupRef\Sort::class, 'sort'], 'functionCall' => 'sqrt', > 'argumentCount' => '1-4', 'argumentCount' => '1', > ], ], > 'SORTBY' => [ 'SQRTPI' => [ > 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [LookupRef\Sort::class, 'sortBy'], 'functionCall' => [MathTrig::class, 'SQRTPI'], > 'argumentCount' => '2+', 'argumentCount' => '1', > ],< 'functionCall' => 'sqrt',> 'functionCall' => [MathTrig\Sqrt::class, 'sqrt'],< 'functionCall' => [MathTrig::class, 'SQRTPI'],> 'functionCall' => [MathTrig\Sqrt::class, 'pi'],'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'STANDARDIZE'],> 'functionCall' => [Statistical\Standardize::class, 'execute'],'argumentCount' => '3', ], 'STDEV' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'STDEV'],> 'functionCall' => [Statistical\StandardDeviations::class, 'STDEV'],'argumentCount' => '1+', ], 'STDEV.S' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'STDEV'],> 'functionCall' => [Statistical\StandardDeviations::class, 'STDEV'],'argumentCount' => '1+', ], 'STDEV.P' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'STDEVP'],> 'functionCall' => [Statistical\StandardDeviations::class, 'STDEVP'],'argumentCount' => '1+', ], 'STDEVA' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'STDEVA'],> 'functionCall' => [Statistical\StandardDeviations::class, 'STDEVA'],'argumentCount' => '1+', ], 'STDEVP' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'STDEVP'],> 'functionCall' => [Statistical\StandardDeviations::class, 'STDEVP'],'argumentCount' => '1+', ], 'STDEVPA' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'STDEVPA'],> 'functionCall' => [Statistical\StandardDeviations::class, 'STDEVPA'],'argumentCount' => '1+', ], 'STEYX' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'STEYX'],> 'functionCall' => [Statistical\Trends::class, 'STEYX'],'argumentCount' => '2', ], 'SUBSTITUTE' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'SUBSTITUTE'],> 'functionCall' => [TextData\Replace::class, 'substitute'],'argumentCount' => '3,4', ], 'SUBTOTAL' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SUBTOTAL'],> 'functionCall' => [MathTrig\Subtotal::class, 'evaluate'],'argumentCount' => '2+', 'passCellReference' => true, ], 'SUM' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SUM'],> 'functionCall' => [MathTrig\Sum::class, 'sumErroringStrings'],'argumentCount' => '1+', ], 'SUMIF' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SUMIF'],> 'functionCall' => [Statistical\Conditional::class, 'SUMIF'],'argumentCount' => '2,3', ], 'SUMIFS' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SUMIFS'],> 'functionCall' => [Statistical\Conditional::class, 'SUMIFS'],'argumentCount' => '3+', ], 'SUMPRODUCT' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SUMPRODUCT'],> 'functionCall' => [MathTrig\Sum::class, 'product'],'argumentCount' => '1+', ], 'SUMSQ' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SUMSQ'],> 'functionCall' => [MathTrig\SumSquares::class, 'sumSquare'],'argumentCount' => '1+', ], 'SUMX2MY2' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SUMX2MY2'],> 'functionCall' => [MathTrig\SumSquares::class, 'sumXSquaredMinusYSquared'],'argumentCount' => '2', ], 'SUMX2PY2' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SUMX2PY2'],> 'functionCall' => [MathTrig\SumSquares::class, 'sumXSquaredPlusYSquared'],'argumentCount' => '2', ], 'SUMXMY2' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => [MathTrig::class, 'SUMXMY2'],> 'functionCall' => [MathTrig\SumSquares::class, 'sumXMinusYSquared'],'argumentCount' => '2', ], 'SWITCH' => [ 'category' => Category::CATEGORY_LOGICAL,< 'functionCall' => [Logical::class, 'statementSwitch'],> 'functionCall' => [Logical\Conditional::class, 'statementSwitch'],'argumentCount' => '3+', ], 'SYD' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'SYD'],> 'functionCall' => [Financial\Depreciation::class, 'SYD'],'argumentCount' => '4', ], 'T' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA,< 'functionCall' => [TextData::class, 'RETURNSTRING'],> 'functionCall' => [TextData\Text::class, 'test'],'argumentCount' => '1', ],> 'TAKE' => [ 'TAN' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => 'tan', > 'argumentCount' => '2-3', 'argumentCount' => '1', > ],< 'functionCall' => 'tan',> 'functionCall' => [MathTrig\Trig\Tangent::class, 'tan'],'TANH' => [ 'category' => Category::CATEGORY_MATH_AND_TRIG,< 'functionCall' => 'tanh',> 'functionCall' => [MathTrig\Trig\Tangent::class, 'tanh'],'argumentCount' => '1', ], 'TBILLEQ' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'TBILLEQ'],> 'functionCall' => [Financial\TreasuryBill::class, 'bondEquivalentYield'],'argumentCount' => '3', ], 'TBILLPRICE' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'TBILLPRICE'],> 'functionCall' => [Financial\TreasuryBill::class, 'price'],'argumentCount' => '3', ], 'TBILLYIELD' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'TBILLYIELD'],> 'functionCall' => [Financial\TreasuryBill::class, 'yield'],'argumentCount' => '3', ], 'TDIST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'TDIST'],> 'functionCall' => [Statistical\Distributions\StudentT::class, 'distribution'],'argumentCount' => '3', ],> 'T.DIST' => [ 'TEXT' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [TextData::class, 'TEXTFORMAT'], > 'argumentCount' => '3', 'argumentCount' => '2', > ], ], > 'T.DIST.2T' => [ 'TEXTJOIN' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [TextData::class, 'TEXTJOIN'], > 'argumentCount' => '2', 'argumentCount' => '3+', > ], ], > 'T.DIST.RT' => [ 'TIME' => [ > 'category' => Category::CATEGORY_STATISTICAL, 'category' => Category::CATEGORY_DATE_AND_TIME, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [DateTime::class, 'TIME'], > 'argumentCount' => '2', 'argumentCount' => '3', > ],< 'functionCall' => [TextData::class, 'TEXTFORMAT'],> 'functionCall' => [TextData\Format::class, 'TEXTFORMAT'],'TIMEVALUE' => [> 'TEXTAFTER' => [ 'category' => Category::CATEGORY_DATE_AND_TIME, > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'functionCall' => [DateTime::class, 'TIMEVALUE'], > 'functionCall' => [TextData\Extract::class, 'after'], 'argumentCount' => '1', > 'argumentCount' => '2-6', ], > ], 'TINV' => [ > 'TEXTBEFORE' => [ 'category' => Category::CATEGORY_STATISTICAL, > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'functionCall' => [Statistical::class, 'TINV'], > 'functionCall' => [TextData\Extract::class, 'before'], 'argumentCount' => '2', > 'argumentCount' => '2-6', ], > ],< 'functionCall' => [TextData::class, 'TEXTJOIN'],> 'functionCall' => [TextData\Concatenate::class, 'TEXTJOIN'],'category' => Category::CATEGORY_DATE_AND_TIME,> 'TEXTSPLIT' => [ 'functionCall' => [DateTime::class, 'DATENOW'], > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'argumentCount' => '0', > 'functionCall' => [TextData\Text::class, 'split'], ], > 'argumentCount' => '2-6', 'TRANSPOSE' => [ > ], 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, > 'THAIDAYOFWEEK' => [ 'functionCall' => [LookupRef::class, 'TRANSPOSE'], > 'category' => Category::CATEGORY_DATE_AND_TIME, 'argumentCount' => '1', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '?', 'TREND' => [ > ], 'category' => Category::CATEGORY_STATISTICAL, > 'THAIDIGIT' => [ 'functionCall' => [Statistical::class, 'TREND'], > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'argumentCount' => '1-4', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '?', 'TRIM' => [ > ], 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'THAIMONTHOFYEAR' => [ 'functionCall' => [TextData::class, 'TRIMSPACES'], > 'category' => Category::CATEGORY_DATE_AND_TIME, 'argumentCount' => '1', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '?', 'TRIMMEAN' => [ > ], 'category' => Category::CATEGORY_STATISTICAL, > 'THAINUMSOUND' => [ 'functionCall' => [Statistical::class, 'TRIMMEAN'], > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'argumentCount' => '2', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '?', 'TRUE' => [ > ], 'category' => Category::CATEGORY_LOGICAL, > 'THAINUMSTRING' => [ 'functionCall' => [Logical::class, 'TRUE'], > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'argumentCount' => '0', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '?', 'TRUNC' => [ > ], 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'THAISTRINGLENGTH' => [ 'functionCall' => [MathTrig::class, 'TRUNC'], > 'category' => Category::CATEGORY_TEXT_AND_DATA, 'argumentCount' => '1,2', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '?', 'TTEST' => [ > ], 'category' => Category::CATEGORY_STATISTICAL, > 'THAIYEAR' => [ 'functionCall' => [Functions::class, 'DUMMY'], > 'category' => Category::CATEGORY_DATE_AND_TIME, 'argumentCount' => '4', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '?', 'TYPE' => [ > ],< 'functionCall' => [DateTime::class, 'TIME'],> 'functionCall' => [DateTimeExcel\Time::class, 'fromHMS'],< 'functionCall' => [DateTime::class, 'TIMEVALUE'],> 'functionCall' => [DateTimeExcel\TimeValue::class, 'fromString'],< 'functionCall' => [Statistical::class, 'TINV'],> 'functionCall' => [Statistical\Distributions\StudentT::class, 'inverse'], > 'argumentCount' => '2', > ], > 'T.INV' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\StudentT::class, 'inverse'], > 'argumentCount' => '2', > ], > 'T.INV.2T' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Functions::class, 'DUMMY'],< 'functionCall' => [DateTime::class, 'DATENOW'],> 'functionCall' => [DateTimeExcel\Current::class, 'today'],'UNICHAR' => [> 'TOCOL' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'functionCall' => [TextData::class, 'CHARACTER'], > 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1', > 'argumentCount' => '1-3', ], > ], 'UNICODE' => [ > 'TOROW' => [ 'category' => Category::CATEGORY_TEXT_AND_DATA, > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'functionCall' => [TextData::class, 'ASCIICODE'], > 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1', > 'argumentCount' => '1-3', ], > ],< 'functionCall' => [LookupRef::class, 'TRANSPOSE'],> 'functionCall' => [LookupRef\Matrix::class, 'transpose'],< 'functionCall' => [Statistical::class, 'TREND'],> 'functionCall' => [Statistical\Trends::class, 'TREND'],< 'functionCall' => [TextData::class, 'TRIMSPACES'],> 'functionCall' => [TextData\Trim::class, 'spaces'],< 'functionCall' => [Statistical::class, 'TRIMMEAN'],> 'functionCall' => [Statistical\Averages\Mean::class, 'trim'],< 'functionCall' => [Logical::class, 'TRUE'],> 'functionCall' => [Logical\Boolean::class, 'TRUE'],< 'functionCall' => [MathTrig::class, 'TRUNC'],> 'functionCall' => [MathTrig\Trunc::class, 'evaluate'],'category' => Category::CATEGORY_FINANCIAL,> 'T.TEST' => [ 'functionCall' => [Functions::class, 'DUMMY'], > 'category' => Category::CATEGORY_STATISTICAL, 'argumentCount' => '2', > 'functionCall' => [Functions::class, 'DUMMY'], ], > 'argumentCount' => '4', 'VALUE' => [ > ],< 'functionCall' => [Functions::class, 'TYPE'],> 'functionCall' => [Information\Value::class, 'type'],< 'functionCall' => [TextData::class, 'CHARACTER'],> 'functionCall' => [TextData\CharacterConvert::class, 'character'],< 'functionCall' => [TextData::class, 'ASCIICODE'],> 'functionCall' => [TextData\CharacterConvert::class, 'code'],],> 'UNIQUE' => [ 'VAR' => [ > 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [LookupRef\Unique::class, 'unique'], 'functionCall' => [Statistical::class, 'VARFunc'], > 'argumentCount' => '1+', 'argumentCount' => '1+', > ],< 'functionCall' => [TextData::class, 'UPPERCASE'],> 'functionCall' => [TextData\CaseConvert::class, 'upper'],< 'functionCall' => [Functions::class, 'DUMMY'],> 'functionCall' => [Financial\Dollar::class, 'format'],< 'functionCall' => [TextData::class, 'VALUE'],> 'functionCall' => [TextData\Format::class, 'VALUE'],'functionCall' => [Statistical::class, 'VARP'],> 'VALUETOTEXT' => [ 'argumentCount' => '1+', > 'category' => Category::CATEGORY_TEXT_AND_DATA, ], > 'functionCall' => [TextData\Format::class, 'valueToText'], 'VAR.S' => [ > 'argumentCount' => '1,2', 'category' => Category::CATEGORY_STATISTICAL, > ],< 'functionCall' => [Statistical::class, 'VARFunc'],> 'functionCall' => [Statistical\Variances::class, 'VAR'],< 'functionCall' => [Statistical::class, 'VARP'],> 'functionCall' => [Statistical\Variances::class, 'VARP'],< 'functionCall' => [Statistical::class, 'VARFunc'],> 'functionCall' => [Statistical\Variances::class, 'VAR'],'VARA' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'VARA'],> 'functionCall' => [Statistical\Variances::class, 'VARA'],'argumentCount' => '1+', ], 'VARP' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'VARP'],> 'functionCall' => [Statistical\Variances::class, 'VARP'],'argumentCount' => '1+', ], 'VARPA' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'VARPA'],> 'functionCall' => [Statistical\Variances::class, 'VARPA'],'argumentCount' => '1+', ], 'VDB' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '5-7', ], 'VLOOKUP' => [ 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE,< 'functionCall' => [LookupRef::class, 'VLOOKUP'],> 'functionCall' => [LookupRef\VLookup::class, 'lookup'],'argumentCount' => '3,4', ],> 'VSTACK' => [ 'WEEKDAY' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, 'category' => Category::CATEGORY_DATE_AND_TIME, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [DateTime::class, 'WEEKDAY'], > 'argumentCount' => '1+', 'argumentCount' => '1,2', > ], ], > 'WEBSERVICE' => [ 'WEEKNUM' => [ > 'category' => Category::CATEGORY_WEB, 'category' => Category::CATEGORY_DATE_AND_TIME, > 'functionCall' => [Web\Service::class, 'webService'], 'functionCall' => [DateTime::class, 'WEEKNUM'], > 'argumentCount' => '1', 'argumentCount' => '1,2', > ],< 'functionCall' => [DateTime::class, 'WEEKDAY'],> 'functionCall' => [DateTimeExcel\Week::class, 'day'],< 'functionCall' => [DateTime::class, 'WEEKNUM'],> 'functionCall' => [DateTimeExcel\Week::class, 'number'],'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'WEIBULL'],> 'functionCall' => [Statistical\Distributions\Weibull::class, 'distribution'], > 'argumentCount' => '4', > ], > 'WEIBULL.DIST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\Weibull::class, 'distribution'],'argumentCount' => '4', ], 'WORKDAY' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'WORKDAY'], < 'argumentCount' => '2+',> 'functionCall' => [DateTimeExcel\WorkDay::class, 'date'], > 'argumentCount' => '2-3', > ], > 'WORKDAY.INTL' => [ > 'category' => Category::CATEGORY_DATE_AND_TIME, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2-4', > ], > 'WRAPCOLS' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2-3', > ], > 'WRAPROWS' => [ > 'category' => Category::CATEGORY_MATH_AND_TRIG, > 'functionCall' => [Functions::class, 'DUMMY'], > 'argumentCount' => '2-3',], 'XIRR' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'XIRR'],> 'functionCall' => [Financial\CashFlow\Variable\NonPeriodic::class, 'rate'],'argumentCount' => '2,3', ],> 'XLOOKUP' => [ 'XNPV' => [ > 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'category' => Category::CATEGORY_FINANCIAL, > 'functionCall' => [Functions::class, 'DUMMY'], 'functionCall' => [Financial::class, 'XNPV'], > 'argumentCount' => '3-6', 'argumentCount' => '3', > ],< 'functionCall' => [Financial::class, 'XNPV'],> 'functionCall' => [Financial\CashFlow\Variable\NonPeriodic::class, 'presentValue'],'XOR' => [> 'XMATCH' => [ 'category' => Category::CATEGORY_LOGICAL, > 'category' => Category::CATEGORY_LOOKUP_AND_REFERENCE, 'functionCall' => [Logical::class, 'logicalXor'], > 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '1+', > 'argumentCount' => '2,3', ], > ],< 'functionCall' => [Logical::class, 'logicalXor'],> 'functionCall' => [Logical\Operations::class, 'logicalXor'],'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'YEAR'],> 'functionCall' => [DateTimeExcel\DateParts::class, 'year'],'argumentCount' => '1', ], 'YEARFRAC' => [ 'category' => Category::CATEGORY_DATE_AND_TIME,< 'functionCall' => [DateTime::class, 'YEARFRAC'],> 'functionCall' => [DateTimeExcel\YearFrac::class, 'fraction'],'argumentCount' => '2,3', ], 'YIELD' => [ 'category' => Category::CATEGORY_FINANCIAL, 'functionCall' => [Functions::class, 'DUMMY'], 'argumentCount' => '6,7', ], 'YIELDDISC' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'YIELDDISC'],> 'functionCall' => [Financial\Securities\Yields::class, 'yieldDiscounted'],'argumentCount' => '4,5', ], 'YIELDMAT' => [ 'category' => Category::CATEGORY_FINANCIAL,< 'functionCall' => [Financial::class, 'YIELDMAT'],> 'functionCall' => [Financial\Securities\Yields::class, 'yieldAtMaturity'],'argumentCount' => '5,6', ], 'ZTEST' => [ 'category' => Category::CATEGORY_STATISTICAL,< 'functionCall' => [Statistical::class, 'ZTEST'],> 'functionCall' => [Statistical\Distributions\StandardNormal::class, 'zTest'], > 'argumentCount' => '2-3', > ], > 'Z.TEST' => [ > 'category' => Category::CATEGORY_STATISTICAL, > 'functionCall' => [Statistical\Distributions\StandardNormal::class, 'zTest'],'argumentCount' => '2-3', ], ];< // Internal functions used for special control purposes> /** > * Internal functions used for special control purposes. > * > * @var array > */private static $controlFunctions = [ 'MKMATRIX' => [ 'argumentCount' => '*',< 'functionCall' => 'self::mkMatrix',> 'functionCall' => [Internal\MakeMatrix::class, 'make'], > ], > 'NAME.ERROR' => [ > 'argumentCount' => '*', > 'functionCall' => [Functions::class, 'NAME'], > ], > 'WILDCARDMATCH' => [ > 'argumentCount' => '2', > 'functionCall' => [Internal\WildcardMatch::class, 'compare'],], ];< public function __construct(Spreadsheet $spreadsheet = null)> public function __construct(?Spreadsheet $spreadsheet = null){< $this->delta = 1 * pow(10, 0 - ini_get('precision')); <$this->spreadsheet = $spreadsheet; $this->cyclicReferenceStack = new CyclicReferenceStack(); $this->debugLog = new Logger($this->cyclicReferenceStack);> $this->branchPruner = new BranchPruner($this->branchPruningEnabled); } > self::$referenceHelper = ReferenceHelper::getInstance();< private static function loadLocales()> private static function loadLocales(): void{ $localeFileDirectory = __DIR__ . '/locale/';< foreach (glob($localeFileDirectory . '*', GLOB_ONLYDIR) as $filename) {> $localeFileNames = glob($localeFileDirectory . '*', GLOB_ONLYDIR) ?: []; > foreach ($localeFileNames as $filename) {$filename = substr($filename, strlen($localeFileDirectory)); if ($filename != 'en') { self::$validLocaleLanguages[] = $filename; } } } /** * Get an instance of this class. *< * @param Spreadsheet $spreadsheet Injected spreadsheet for working with a PhpSpreadsheet Spreadsheet object, < * or NULL to create a standalone claculation engine < * < * @return Calculation> * @param ?Spreadsheet $spreadsheet Injected spreadsheet for working with a PhpSpreadsheet Spreadsheet object, > * or NULL to create a standalone calculation engine*/< public static function getInstance(Spreadsheet $spreadsheet = null)> public static function getInstance(?Spreadsheet $spreadsheet = null): self{ if ($spreadsheet !== null) { $instance = $spreadsheet->getCalculationEngine(); if (isset($instance)) { return $instance; } } if (!isset(self::$instance) || (self::$instance === null)) { self::$instance = new self(); } return self::$instance; } /** * Flush the calculation cache for any existing instance of this class * but only if a Calculation instance exists. */< public function flushInstance()> public function flushInstance(): void{ $this->clearCalculationCache();< $this->clearBranchStore();> $this->branchPruner->clearBranchStore();} /** * Get the Logger for this calculation engine instance. * * @return Logger */ public function getDebugLog() { return $this->debugLog; } /** * __clone implementation. Cloning should not be allowed in a Singleton!< * < * @throws Exception*/ final public function __clone() { throw new Exception('Cloning the calculation engine is not allowed!'); } /** * Return the locale-specific translation of TRUE. * * @return string locale-specific translation of TRUE */< public static function getTRUE()> public static function getTRUE(): string{ return self::$localeBoolean['TRUE']; } /** * Return the locale-specific translation of FALSE. * * @return string locale-specific translation of FALSE */< public static function getFALSE()> public static function getFALSE(): string{ return self::$localeBoolean['FALSE']; } /** * Set the Array Return Type (Array or Value of first element in the array). * * @param string $returnType Array return type * * @return bool Success or failure */ public static function setArrayReturnType($returnType) {< if (($returnType == self::RETURN_ARRAY_AS_VALUE) ||> if ( > ($returnType == self::RETURN_ARRAY_AS_VALUE) ||($returnType == self::RETURN_ARRAY_AS_ERROR) ||< ($returnType == self::RETURN_ARRAY_AS_ARRAY)) {> ($returnType == self::RETURN_ARRAY_AS_ARRAY) > ) {self::$returnArrayAsType = $returnType; return true; } return false; } /** * Return the Array Return Type (Array or Value of first element in the array). * * @return string $returnType Array return type */ public static function getArrayReturnType() { return self::$returnArrayAsType; } /** * Is calculation caching enabled? * * @return bool */ public function getCalculationCacheEnabled() { return $this->calculationCacheEnabled; } /** * Enable/disable calculation cache. *< * @param bool $pValue> * @param bool $calculationCacheEnabled*/< public function setCalculationCacheEnabled($pValue)> public function setCalculationCacheEnabled($calculationCacheEnabled): void{< $this->calculationCacheEnabled = $pValue;> $this->calculationCacheEnabled = $calculationCacheEnabled;$this->clearCalculationCache(); } /** * Enable calculation cache. */< public function enableCalculationCache()> public function enableCalculationCache(): void{ $this->setCalculationCacheEnabled(true); } /** * Disable calculation cache. */< public function disableCalculationCache()> public function disableCalculationCache(): void{ $this->setCalculationCacheEnabled(false); } /** * Clear calculation cache. */< public function clearCalculationCache()> public function clearCalculationCache(): void{ $this->calculationCache = []; } /** * Clear calculation cache for a specified worksheet. * * @param string $worksheetName */< public function clearCalculationCacheForWorksheet($worksheetName)> public function clearCalculationCacheForWorksheet($worksheetName): void{ if (isset($this->calculationCache[$worksheetName])) { unset($this->calculationCache[$worksheetName]); } } /** * Rename calculation cache for a specified worksheet. * * @param string $fromWorksheetName * @param string $toWorksheetName */< public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName)> public function renameCalculationCacheForWorksheet($fromWorksheetName, $toWorksheetName): void{ if (isset($this->calculationCache[$fromWorksheetName])) { $this->calculationCache[$toWorksheetName] = &$this->calculationCache[$fromWorksheetName]; unset($this->calculationCache[$fromWorksheetName]); } } /** * Enable/disable calculation cache. *< * @param bool $pValue* @param mixed $enabled */< public function setBranchPruningEnabled($enabled)> public function setBranchPruningEnabled($enabled): void{ $this->branchPruningEnabled = $enabled;> $this->branchPruner = new BranchPruner($this->branchPruningEnabled);}< public function enableBranchPruning()> public function enableBranchPruning(): void{ $this->setBranchPruningEnabled(true); }< public function disableBranchPruning()> public function disableBranchPruning(): void{ $this->setBranchPruningEnabled(false); }< public function clearBranchStore() < { < $this->branchStoreKeyCounter = 0; < } </** * Get the currently defined locale code. * * @return string */ public function getLocale() { return self::$localeLanguage; }> private function getLocaleFile(string $localeDir, string $locale, string $language, string $file): string /** > { * Set the locale code. > $localeFileName = $localeDir . str_replace('_', DIRECTORY_SEPARATOR, $locale) . * > DIRECTORY_SEPARATOR . $file; * @param string $locale The locale to use for formula translation, eg: 'en_us' > if (!file_exists($localeFileName)) { * > // If there isn't a locale specific file, look for a language specific file * @return bool > $localeFileName = $localeDir . $language . DIRECTORY_SEPARATOR . $file; */ > if (!file_exists($localeFileName)) { public function setLocale($locale) > throw new Exception('Locale file not found'); { > } // Identify our locale and language > } $language = $locale = strtolower($locale); > if (strpos($locale, '_') !== false) { > return $localeFileName; [$language] = explode('_', $locale); > } } >< public function setLocale($locale)> public function setLocale(string $locale)self::loadLocales(); }>// Test whether we have any language data for this language (any locale)< if (in_array($language, self::$validLocaleLanguages)) {> if (in_array($language, self::$validLocaleLanguages, true)) {// initialise language/locale settings self::$localeFunctions = []; self::$localeArgumentSeparator = ','; self::$localeBoolean = ['TRUE' => 'TRUE', 'FALSE' => 'FALSE', 'NULL' => 'NULL'];< // Default is English, if user isn't requesting english, then read the necessary data from the locale files < if ($locale != 'en_us') {> > // Default is US English, if user isn't requesting US english, then read the necessary data from the locale files > if ($locale !== 'en_us') { > $localeDir = implode(DIRECTORY_SEPARATOR, [__DIR__, 'locale', null]);// Search for a file with a list of function names for locale< $functionNamesFile = __DIR__ . '/locale/' . str_replace('_', DIRECTORY_SEPARATOR, $locale) . DIRECTORY_SEPARATOR . 'functions'; < if (!file_exists($functionNamesFile)) { < // If there isn't a locale specific function file, look for a language specific function file < $functionNamesFile = __DIR__ . '/locale/' . $language . DIRECTORY_SEPARATOR . 'functions'; < if (!file_exists($functionNamesFile)) {> try { > $functionNamesFile = $this->getLocaleFile($localeDir, $locale, $language, 'functions'); > } catch (Exception $e) {return false; }< }>// Retrieve the list of locale or language specific function names< $localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);> $localeFunctions = file($functionNamesFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: [];foreach ($localeFunctions as $localeFunction) { [$localeFunction] = explode('##', $localeFunction); // Strip out comments if (strpos($localeFunction, '=') !== false) {< [$fName, $lfName] = explode('=', $localeFunction); < $fName = trim($fName); < $lfName = trim($lfName); < if ((isset(self::$phpSpreadsheetFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {> [$fName, $lfName] = array_map('trim', explode('=', $localeFunction)); > if ((substr($fName, 0, 1) === '*' || isset(self::$phpSpreadsheetFunctions[$fName])) && ($lfName != '') && ($fName != $lfName)) {self::$localeFunctions[$fName] = $lfName; } } } // Default the TRUE and FALSE constants to the locale names of the TRUE() and FALSE() functions if (isset(self::$localeFunctions['TRUE'])) { self::$localeBoolean['TRUE'] = self::$localeFunctions['TRUE']; } if (isset(self::$localeFunctions['FALSE'])) { self::$localeBoolean['FALSE'] = self::$localeFunctions['FALSE']; }< $configFile = __DIR__ . '/locale/' . str_replace('_', DIRECTORY_SEPARATOR, $locale) . DIRECTORY_SEPARATOR . 'config'; < if (!file_exists($configFile)) { < $configFile = __DIR__ . '/locale/' . $language . DIRECTORY_SEPARATOR . 'config';> try { > $configFile = $this->getLocaleFile($localeDir, $locale, $language, 'config'); > } catch (Exception $e) { > return false;}< if (file_exists($configFile)) { < $localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);> > $localeSettings = file($configFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: [];foreach ($localeSettings as $localeSetting) { [$localeSetting] = explode('##', $localeSetting); // Strip out comments if (strpos($localeSetting, '=') !== false) {< [$settingName, $settingValue] = explode('=', $localeSetting); < $settingName = strtoupper(trim($settingName));> [$settingName, $settingValue] = array_map('trim', explode('=', $localeSetting)); > $settingName = strtoupper($settingName); > if ($settingValue !== '') {switch ($settingName) { case 'ARGUMENTSEPARATOR':< self::$localeArgumentSeparator = trim($settingValue);> self::$localeArgumentSeparator = $settingValue;break; } } } } } self::$functionReplaceFromExcel = self::$functionReplaceToExcel = self::$functionReplaceFromLocale = self::$functionReplaceToLocale = null; self::$localeLanguage = $locale; return true; } return false; }< /** < * @param string $fromSeparator < * @param string $toSeparator < * @param string $formula < * @param bool $inBraces < * < * @return string < */ < public static function translateSeparator($fromSeparator, $toSeparator, $formula, &$inBraces) < {> public static function translateSeparator( > string $fromSeparator, > string $toSeparator, > string $formula, > int &$inBracesLevel, > string $openBrace = self::FORMULA_OPEN_FUNCTION_BRACE, > string $closeBrace = self::FORMULA_CLOSE_FUNCTION_BRACE > ): string {$strlen = mb_strlen($formula); for ($i = 0; $i < $strlen; ++$i) { $chr = mb_substr($formula, $i, 1); switch ($chr) {< case '{': < $inBraces = true;> case $openBrace: > ++$inBracesLevel;break;< case '}': < $inBraces = false;> case $closeBrace: > --$inBracesLevel;break; case $fromSeparator:< if (!$inBraces) {> if ($inBracesLevel > 0) {$formula = mb_substr($formula, 0, $i) . $toSeparator . mb_substr($formula, $i + 1); } } } return $formula; }< /** < * @param string[] $from < * @param string[] $to < * @param string $formula < * @param string $fromSeparator < * @param string $toSeparator < * < * @return string < */ < private static function translateFormula(array $from, array $to, $formula, $fromSeparator, $toSeparator)> private static function translateFormulaBlock( > array $from, > array $to, > string $formula, > int &$inFunctionBracesLevel, > int &$inMatrixBracesLevel, > string $fromSeparator, > string $toSeparator > ): string { > // Function Names > $formula = (string) preg_replace($from, $to, $formula); > > // Temporarily adjust matrix separators so that they won't be confused with function arguments > $formula = self::translateSeparator(';', '|', $formula, $inMatrixBracesLevel, self::FORMULA_OPEN_MATRIX_BRACE, self::FORMULA_CLOSE_MATRIX_BRACE); > $formula = self::translateSeparator(',', '!', $formula, $inMatrixBracesLevel, self::FORMULA_OPEN_MATRIX_BRACE, self::FORMULA_CLOSE_MATRIX_BRACE); > // Function Argument Separators > $formula = self::translateSeparator($fromSeparator, $toSeparator, $formula, $inFunctionBracesLevel); > // Restore matrix separators > $formula = self::translateSeparator('|', ';', $formula, $inMatrixBracesLevel, self::FORMULA_OPEN_MATRIX_BRACE, self::FORMULA_CLOSE_MATRIX_BRACE); > $formula = self::translateSeparator('!', ',', $formula, $inMatrixBracesLevel, self::FORMULA_OPEN_MATRIX_BRACE, self::FORMULA_CLOSE_MATRIX_BRACE); > > return $formula; > } > > private static function translateFormula(array $from, array $to, string $formula, string $fromSeparator, string $toSeparator): string{< // Convert any Excel function names to the required language> // Convert any Excel function names and constant names to the required language; > // and adjust function argument separatorsif (self::$localeLanguage !== 'en_us') {< $inBraces = false; < // If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators < if (strpos($formula, '"') !== false) { < // So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded < // the formula < $temp = explode('"', $formula); < $i = false;> $inFunctionBracesLevel = 0; > $inMatrixBracesLevel = 0; > // If there is the possibility of separators within a quoted string, then we treat them as literals > if (strpos($formula, self::FORMULA_STRING_QUOTE) !== false) { > // So instead we skip replacing in any quoted strings by only replacing in every other array element > // after we've exploded the formula > $temp = explode(self::FORMULA_STRING_QUOTE, $formula); > $notWithinQuotes = false;foreach ($temp as &$value) {< // Only count/replace in alternating array entries < if ($i = !$i) { < $value = preg_replace($from, $to, $value); < $value = self::translateSeparator($fromSeparator, $toSeparator, $value, $inBraces);> // Only adjust in alternating array entries > $notWithinQuotes = $notWithinQuotes === false; > if ($notWithinQuotes === true) { > $value = self::translateFormulaBlock($from, $to, $value, $inFunctionBracesLevel, $inMatrixBracesLevel, $fromSeparator, $toSeparator);} } unset($value); // Then rebuild the formula string< $formula = implode('"', $temp);> $formula = implode(self::FORMULA_STRING_QUOTE, $temp);} else { // If there's no quoted strings, then we do a simple count/replace< $formula = preg_replace($from, $to, $formula); < $formula = self::translateSeparator($fromSeparator, $toSeparator, $formula, $inBraces);> $formula = self::translateFormulaBlock($from, $to, $formula, $inFunctionBracesLevel, $inMatrixBracesLevel, $fromSeparator, $toSeparator);} } return $formula; }< private static $functionReplaceFromExcel = null;> /** @var ?array */ > private static $functionReplaceFromExcel;< private static $functionReplaceToLocale = null;> /** @var ?array */ > private static $functionReplaceToLocale;> /** public function _translateFormulaToLocale($formula) > * @param string $formula { > * if (self::$functionReplaceFromExcel === null) { > * @return string self::$functionReplaceFromExcel = []; > */foreach (array_keys(self::$localeFunctions) as $excelFunctionName) {> // Build list of function names and constants for translation< self::$functionReplaceFromExcel[] = '/(@?[^\w\.])' . preg_quote($excelFunctionName, '/') . '([\s]*\()/Ui';> self::$functionReplaceFromExcel[] = '/(@?[^\w\.])' . preg_quote($excelFunctionName, '/') . '([\s]*\()/ui';} foreach (array_keys(self::$localeBoolean) as $excelBoolean) {< self::$functionReplaceFromExcel[] = '/(@?[^\w\.])' . preg_quote($excelBoolean, '/') . '([^\w\.])/Ui';> self::$functionReplaceFromExcel[] = '/(@?[^\w\.])' . preg_quote($excelBoolean, '/') . '([^\w\.])/ui';} } if (self::$functionReplaceToLocale === null) { self::$functionReplaceToLocale = []; foreach (self::$localeFunctions as $localeFunctionName) { self::$functionReplaceToLocale[] = '$1' . trim($localeFunctionName) . '$2'; } foreach (self::$localeBoolean as $localeBoolean) { self::$functionReplaceToLocale[] = '$1' . trim($localeBoolean) . '$2'; } }< return self::translateFormula(self::$functionReplaceFromExcel, self::$functionReplaceToLocale, $formula, ',', self::$localeArgumentSeparator);> return self::translateFormula( > self::$functionReplaceFromExcel, > self::$functionReplaceToLocale, > $formula, > ',', > self::$localeArgumentSeparator > );}< private static $functionReplaceFromLocale = null;> /** @var ?array */ > private static $functionReplaceFromLocale;< private static $functionReplaceToExcel = null;> /** @var ?array */ > private static $functionReplaceToExcel;> /** public function _translateFormulaToEnglish($formula) > * @param string $formula { > * if (self::$functionReplaceFromLocale === null) { > * @return string self::$functionReplaceFromLocale = []; > */foreach (self::$localeFunctions as $localeFunctionName) {< self::$functionReplaceFromLocale[] = '/(@?[^\w\.])' . preg_quote($localeFunctionName, '/') . '([\s]*\()/Ui';> self::$functionReplaceFromLocale[] = '/(@?[^\w\.])' . preg_quote($localeFunctionName, '/') . '([\s]*\()/ui';} foreach (self::$localeBoolean as $excelBoolean) {< self::$functionReplaceFromLocale[] = '/(@?[^\w\.])' . preg_quote($excelBoolean, '/') . '([^\w\.])/Ui';> self::$functionReplaceFromLocale[] = '/(@?[^\w\.])' . preg_quote($excelBoolean, '/') . '([^\w\.])/ui';} } if (self::$functionReplaceToExcel === null) { self::$functionReplaceToExcel = []; foreach (array_keys(self::$localeFunctions) as $excelFunctionName) { self::$functionReplaceToExcel[] = '$1' . trim($excelFunctionName) . '$2'; } foreach (array_keys(self::$localeBoolean) as $excelBoolean) { self::$functionReplaceToExcel[] = '$1' . trim($excelBoolean) . '$2'; } } return self::translateFormula(self::$functionReplaceFromLocale, self::$functionReplaceToExcel, $formula, self::$localeArgumentSeparator, ','); }> /** public static function localeFunc($function) > * @param string $function { > * if (self::$localeLanguage !== 'en_us') { > * @return string $functionName = trim($function, '('); > */if (isset(self::$localeFunctions[$functionName])) { $brace = ($functionName != $function); $function = self::$localeFunctions[$functionName]; if ($brace) { $function .= '('; } } } return $function; } /** * Wrap string values in quotes. * * @param mixed $value * * @return mixed */ public static function wrapResult($value) { if (is_string($value)) { // Error values cannot be "wrapped" if (preg_match('/^' . self::CALCULATION_REGEXP_ERROR . '$/i', $value, $match)) { // Return Excel errors "as is" return $value; }>// Return strings wrapped in quotes< return '"' . $value . '"'; < // Convert numeric errors to NaN error> return self::FORMULA_STRING_QUOTE . $value . self::FORMULA_STRING_QUOTE;} elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {< return Functions::NAN();> // Convert numeric errors to NaN error > return Information\ExcelError::NAN();} return $value; } /** * Remove quotes used as a wrapper to identify string values. * * @param mixed $value * * @return mixed */ public static function unwrapResult($value) { if (is_string($value)) {< if ((isset($value[0])) && ($value[0] == '"') && (substr($value, -1) == '"')) {> if ((isset($value[0])) && ($value[0] == self::FORMULA_STRING_QUOTE) && (substr($value, -1) == self::FORMULA_STRING_QUOTE)) {return substr($value, 1, -1); } // Convert numeric errors to NAN error } elseif ((is_float($value)) && ((is_nan($value)) || (is_infinite($value)))) {< return Functions::NAN();> return Information\ExcelError::NAN();} return $value; } /** * Calculate cell value (using formula from a cell ID) * Retained for backward compatibility. *< * @param Cell $pCell Cell to calculate < * < * @throws Exception> * @param Cell $cell Cell to calculate* * @return mixed */< public function calculate(Cell $pCell = null)> public function calculate(?Cell $cell = null){ try {< return $this->calculateCellValue($pCell);> return $this->calculateCellValue($cell);} catch (\Exception $e) { throw new Exception($e->getMessage()); } } /** * Calculate the value of a cell formula. *< * @param Cell $pCell Cell to calculate> * @param Cell $cell Cell to calculate* @param bool $resetLog Flag indicating whether the debug log should be reset or not *< * @throws \PhpOffice\PhpSpreadsheet\Exception < ** @return mixed */< public function calculateCellValue(Cell $pCell = null, $resetLog = true)> public function calculateCellValue(?Cell $cell = null, $resetLog = true){< if ($pCell === null) {> if ($cell === null) {return null; } $returnArrayAsType = self::$returnArrayAsType; if ($resetLog) { // Initialise the logging settings if requested $this->formulaError = null; $this->debugLog->clearLog(); $this->cyclicReferenceStack->clear(); $this->cyclicFormulaCounter = 1; self::$returnArrayAsType = self::RETURN_ARRAY_AS_ARRAY; } // Execute the calculation for the cell formula $this->cellStack[] = [< 'sheet' => $pCell->getWorksheet()->getTitle(), < 'cell' => $pCell->getCoordinate(),> 'sheet' => $cell->getWorksheet()->getTitle(), > 'cell' => $cell->getCoordinate(),];> $cellAddressAttempted = false; try { > $cellAddress = null; $result = self::unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell)); >< $result = self::unwrapResult($this->_calculateFormulaValue($pCell->getValue(), $pCell->getCoordinate(), $pCell));> $result = self::unwrapResult($this->_calculateFormulaValue($cell->getValue(), $cell->getCoordinate(), $cell)); > if ($this->spreadsheet === null) { > throw new Exception('null spreadsheet in calculateCellValue'); > } > $cellAddressAttempted = true;< $this->spreadsheet->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);> if ($cellAddress === null) { > throw new Exception('null cellAddress in calculateCellValue'); > } > $testSheet = $this->spreadsheet->getSheetByName($cellAddress['sheet']); > if ($testSheet === null) { > throw new Exception('worksheet not found in calculateCellValue'); > } > $testSheet->getCell($cellAddress['cell']);} catch (\Exception $e) {> if (!$cellAddressAttempted) {$cellAddress = array_pop($this->cellStack);< $this->spreadsheet->getSheetByName($cellAddress['sheet'])->getCell($cellAddress['cell']);> } > if ($this->spreadsheet !== null && is_array($cellAddress) && array_key_exists('sheet', $cellAddress)) { > $testSheet = $this->spreadsheet->getSheetByName($cellAddress['sheet']); > if ($testSheet !== null && array_key_exists('cell', $cellAddress)) { > $testSheet->getCell($cellAddress['cell']); > } > }< throw new Exception($e->getMessage());> throw new Exception($e->getMessage(), $e->getCode(), $e);} if ((is_array($result)) && (self::$returnArrayAsType != self::RETURN_ARRAY_AS_ARRAY)) { self::$returnArrayAsType = $returnArrayAsType; $testResult = Functions::flattenArray($result); if (self::$returnArrayAsType == self::RETURN_ARRAY_AS_ERROR) {< return Functions::VALUE();> return Information\ExcelError::VALUE();} // If there's only a single cell in the array, then we allow it if (count($testResult) != 1) { // If keys are numeric, then it's a matrix result rather than a cell range result, so we permit it $r = array_keys($result); $r = array_shift($r); if (!is_numeric($r)) {< return Functions::VALUE();> return Information\ExcelError::VALUE();} if (is_array($result[$r])) { $c = array_keys($result[$r]); $c = array_shift($c); if (!is_numeric($c)) {< return Functions::VALUE();> return Information\ExcelError::VALUE();} } } $result = array_shift($testResult); } self::$returnArrayAsType = $returnArrayAsType;< if ($result === null && $pCell->getWorksheet()->getSheetView()->getShowZeros()) {> if ($result === null && $cell->getWorksheet()->getSheetView()->getShowZeros()) {return 0; } elseif ((is_float($result)) && ((is_nan($result)) || (is_infinite($result)))) {< return Functions::NAN();> return Information\ExcelError::NAN();} return $result; } /** * Validate and parse a formula string. * * @param string $formula Formula to parse * * @return array|bool */ public function parseFormula($formula) { // Basic validation that this is indeed a formula // We return an empty array if not $formula = trim($formula); if ((!isset($formula[0])) || ($formula[0] != '=')) { return []; } $formula = ltrim(substr($formula, 1)); if (!isset($formula[0])) { return []; } // Parse the formula and return the token stack< return $this->_parseFormula($formula);> return $this->internalParseFormula($formula);} /** * Calculate the value of a formula. * * @param string $formula Formula to parse * @param string $cellID Address of the cell to calculate< * @param Cell $pCell Cell to calculate < * < * @throws \PhpOffice\PhpSpreadsheet\Exception> * @param Cell $cell Cell to calculate* * @return mixed */< public function calculateFormula($formula, $cellID = null, Cell $pCell = null)> public function calculateFormula($formula, $cellID = null, ?Cell $cell = null){ // Initialise the logging settings $this->formulaError = null; $this->debugLog->clearLog(); $this->cyclicReferenceStack->clear();< if ($this->spreadsheet !== null && $cellID === null && $pCell === null) {> $resetCache = $this->getCalculationCacheEnabled(); > if ($this->spreadsheet !== null && $cellID === null && $cell === null) {$cellID = 'A1';< $pCell = $this->spreadsheet->getActiveSheet()->getCell($cellID);> $cell = $this->spreadsheet->getActiveSheet()->getCell($cellID);} else { // Disable calculation cacheing because it only applies to cell calculations, not straight formulae // But don't actually flush any cache< $resetCache = $this->getCalculationCacheEnabled();$this->calculationCacheEnabled = false; } // Execute the calculation try {< $result = self::unwrapResult($this->_calculateFormulaValue($formula, $cellID, $pCell));> $result = self::unwrapResult($this->_calculateFormulaValue($formula, $cellID, $cell));} catch (\Exception $e) { throw new Exception($e->getMessage()); } if ($this->spreadsheet === null) { // Reset calculation cacheing to its previous state $this->calculationCacheEnabled = $resetCache; } return $result; } /**< * @param string $cellReference* @param mixed $cellValue< * < * @return bool*/< public function getValueFromCache($cellReference, &$cellValue)> public function getValueFromCache(string $cellReference, &$cellValue): bool{> $this->debugLog->writeDebugLog('Testing cache value for cell %s', $cellReference);// Is calculation cacheing enabled?< // Is the value present in calculation cache? < $this->debugLog->writeDebugLog('Testing cache value for cell ', $cellReference);> // If so, is the required value present in calculation cache?if (($this->calculationCacheEnabled) && (isset($this->calculationCache[$cellReference]))) {< $this->debugLog->writeDebugLog('Retrieving value for cell ', $cellReference, ' from cache');> $this->debugLog->writeDebugLog('Retrieving value for cell %s from cache', $cellReference);// Return the cached result $cellValue = $this->calculationCache[$cellReference]; return true; } return false; } /** * @param string $cellReference * @param mixed $cellValue */< public function saveValueToCache($cellReference, $cellValue)> public function saveValueToCache($cellReference, $cellValue): void{ if ($this->calculationCacheEnabled) { $this->calculationCache[$cellReference] = $cellValue; } } /** * Parse a cell formula and calculate its value. * * @param string $formula The formula to parse and calculate * @param string $cellID The ID (e.g. A3) of the cell that we are calculating< * @param Cell $pCell Cell to calculate < * < * @throws Exception> * @param Cell $cell Cell to calculate > * @param bool $ignoreQuotePrefix If set to true, evaluate the formyla even if the referenced cell is quote prefixed* * @return mixed */< public function _calculateFormulaValue($formula, $cellID = null, Cell $pCell = null)> public function _calculateFormulaValue($formula, $cellID = null, ?Cell $cell = null, bool $ignoreQuotePrefix = false){ $cellValue = null; // Quote-Prefixed cell values cannot be formulae, but are treated as strings< if ($pCell !== null && $pCell->getStyle()->getQuotePrefix() === true) {> if ($cell !== null && $ignoreQuotePrefix === false && $cell->getStyle()->getQuotePrefix() === true) {return self::wrapResult((string) $formula); } if (preg_match('/^=\s*cmd\s*\|/miu', $formula) !== 0) { return self::wrapResult($formula); } // Basic validation that this is indeed a formula // We simply return the cell value if not $formula = trim($formula); if ($formula[0] != '=') { return self::wrapResult($formula); } $formula = ltrim(substr($formula, 1)); if (!isset($formula[0])) { return self::wrapResult($formula); }< $pCellParent = ($pCell !== null) ? $pCell->getWorksheet() : null;> $pCellParent = ($cell !== null) ? $cell->getWorksheet() : null;$wsTitle = ($pCellParent !== null) ? $pCellParent->getTitle() : "\x00Wrk"; $wsCellReference = $wsTitle . '!' . $cellID; if (($cellID !== null) && ($this->getValueFromCache($wsCellReference, $cellValue))) { return $cellValue; }> $this->debugLog->writeDebugLog('Evaluating formula for cell %s', $wsCellReference);if (($wsTitle[0] !== "\x00") && ($this->cyclicReferenceStack->onStack($wsCellReference))) { if ($this->cyclicFormulaCount <= 0) { $this->cyclicFormulaCell = ''; return $this->raiseFormulaError('Cyclic Reference in Formula'); } elseif ($this->cyclicFormulaCell === $wsCellReference) { ++$this->cyclicFormulaCounter; if ($this->cyclicFormulaCounter >= $this->cyclicFormulaCount) { $this->cyclicFormulaCell = ''; return $cellValue; } } elseif ($this->cyclicFormulaCell == '') { if ($this->cyclicFormulaCounter >= $this->cyclicFormulaCount) { return $cellValue; } $this->cyclicFormulaCell = $wsCellReference; } }> $this->debugLog->writeDebugLog('Formula for cell %s is %s', $wsCellReference, $formula);// Parse the formula onto the token stack and calculate the value $this->cyclicReferenceStack->push($wsCellReference);< $cellValue = $this->processTokenStack($this->_parseFormula($formula, $pCell), $cellID, $pCell);> > $cellValue = $this->processTokenStack($this->internalParseFormula($formula, $cell), $cellID, $cell);$this->cyclicReferenceStack->pop(); // Save to calculation cache if ($cellID !== null) { $this->saveValueToCache($wsCellReference, $cellValue); } // Return the calculated value return $cellValue; } /** * Ensure that paired matrix operands are both matrices and of the same size. *< * @param mixed &$operand1 First matrix operand < * @param mixed &$operand2 Second matrix operand> * @param mixed $operand1 First matrix operand > * @param mixed $operand2 Second matrix operand* @param int $resize Flag indicating whether the matrices should be resized to match * and (if so), whether the smaller dimension should grow or the * larger should shrink. * 0 = no resize * 1 = shrink to fit * 2 = extend to fit * * @return array */ private static function checkMatrixOperands(&$operand1, &$operand2, $resize = 1) { // Examine each of the two operands, and turn them into an array if they aren't one already // Note that this function should only be called if one or both of the operand is already an array if (!is_array($operand1)) { [$matrixRows, $matrixColumns] = self::getMatrixDimensions($operand2); $operand1 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand1)); $resize = 0; } elseif (!is_array($operand2)) { [$matrixRows, $matrixColumns] = self::getMatrixDimensions($operand1); $operand2 = array_fill(0, $matrixRows, array_fill(0, $matrixColumns, $operand2)); $resize = 0; } [$matrix1Rows, $matrix1Columns] = self::getMatrixDimensions($operand1); [$matrix2Rows, $matrix2Columns] = self::getMatrixDimensions($operand2); if (($matrix1Rows == $matrix2Columns) && ($matrix2Rows == $matrix1Columns)) { $resize = 1; } if ($resize == 2) { // Given two matrices of (potentially) unequal size, convert the smaller in each dimension to match the larger self::resizeMatricesExtend($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); } elseif ($resize == 1) { // Given two matrices of (potentially) unequal size, convert the larger in each dimension to match the smaller self::resizeMatricesShrink($operand1, $operand2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns); } return [$matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns]; } /** * Read the dimensions of a matrix, and re-index it with straight numeric keys starting from row 0, column 0. *< * @param array &$matrix matrix operand> * @param array $matrix matrix operand* * @return int[] An array comprising the number of rows, and number of columns */ public static function getMatrixDimensions(array &$matrix) { $matrixRows = count($matrix); $matrixColumns = 0; foreach ($matrix as $rowKey => $rowValue) { if (!is_array($rowValue)) { $matrix[$rowKey] = [$rowValue]; $matrixColumns = max(1, $matrixColumns); } else { $matrix[$rowKey] = array_values($rowValue); $matrixColumns = max(count($rowValue), $matrixColumns); } } $matrix = array_values($matrix); return [$matrixRows, $matrixColumns]; } /** * Ensure that paired matrix operands are both matrices of the same size. *< * @param mixed &$matrix1 First matrix operand < * @param mixed &$matrix2 Second matrix operand> * @param mixed $matrix1 First matrix operand > * @param mixed $matrix2 Second matrix operand* @param int $matrix1Rows Row size of first matrix operand * @param int $matrix1Columns Column size of first matrix operand * @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand */< private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns)> private static function resizeMatricesShrink(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void{ if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Rows < $matrix1Rows) { for ($i = $matrix2Rows; $i < $matrix1Rows; ++$i) { unset($matrix1[$i]); } } if ($matrix2Columns < $matrix1Columns) { for ($i = 0; $i < $matrix1Rows; ++$i) { for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) { unset($matrix1[$i][$j]); } } } } if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) { if ($matrix1Rows < $matrix2Rows) { for ($i = $matrix1Rows; $i < $matrix2Rows; ++$i) { unset($matrix2[$i]); } } if ($matrix1Columns < $matrix2Columns) { for ($i = 0; $i < $matrix2Rows; ++$i) { for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) { unset($matrix2[$i][$j]); } } } } } /** * Ensure that paired matrix operands are both matrices of the same size. *< * @param mixed &$matrix1 First matrix operand < * @param mixed &$matrix2 Second matrix operand> * @param mixed $matrix1 First matrix operand > * @param mixed $matrix2 Second matrix operand* @param int $matrix1Rows Row size of first matrix operand * @param int $matrix1Columns Column size of first matrix operand * @param int $matrix2Rows Row size of second matrix operand * @param int $matrix2Columns Column size of second matrix operand */< private static function resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns)> private static function resizeMatricesExtend(&$matrix1, &$matrix2, $matrix1Rows, $matrix1Columns, $matrix2Rows, $matrix2Columns): void{ if (($matrix2Columns < $matrix1Columns) || ($matrix2Rows < $matrix1Rows)) { if ($matrix2Columns < $matrix1Columns) { for ($i = 0; $i < $matrix2Rows; ++$i) { $x = $matrix2[$i][$matrix2Columns - 1]; for ($j = $matrix2Columns; $j < $matrix1Columns; ++$j) { $matrix2[$i][$j] = $x; } } } if ($matrix2Rows < $matrix1Rows) { $x = $matrix2[$matrix2Rows - 1]; for ($i = 0; $i < $matrix1Rows; ++$i) { $matrix2[$i] = $x; } } } if (($matrix1Columns < $matrix2Columns) || ($matrix1Rows < $matrix2Rows)) { if ($matrix1Columns < $matrix2Columns) { for ($i = 0; $i < $matrix1Rows; ++$i) { $x = $matrix1[$i][$matrix1Columns - 1]; for ($j = $matrix1Columns; $j < $matrix2Columns; ++$j) { $matrix1[$i][$j] = $x; } } } if ($matrix1Rows < $matrix2Rows) { $x = $matrix1[$matrix1Rows - 1]; for ($i = 0; $i < $matrix2Rows; ++$i) { $matrix1[$i] = $x; } } } } /** * Format details of an operand for display in the log (based on operand type). * * @param mixed $value First matrix operand * * @return mixed */ private function showValue($value) { if ($this->debugLog->getWriteDebugLog()) { $testArray = Functions::flattenArray($value); if (count($testArray) == 1) { $value = array_pop($testArray); } if (is_array($value)) { $returnMatrix = []; $pad = $rpad = ', '; foreach ($value as $row) { if (is_array($row)) { $returnMatrix[] = implode($pad, array_map([$this, 'showValue'], $row)); $rpad = '; '; } else { $returnMatrix[] = $this->showValue($row); } } return '{ ' . implode($rpad, $returnMatrix) . ' }';< } elseif (is_string($value) && (trim($value, '"') == $value)) { < return '"' . $value . '"';> } elseif (is_string($value) && (trim($value, self::FORMULA_STRING_QUOTE) == $value)) { > return self::FORMULA_STRING_QUOTE . $value . self::FORMULA_STRING_QUOTE;} elseif (is_bool($value)) { return ($value) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE'];> } elseif ($value === null) { } > return self::$localeBoolean['NULL'];} return Functions::flattenSingleValue($value); } /** * Format type and details of an operand for display in the log (based on operand type). * * @param mixed $value First matrix operand * * @return null|string */ private function showTypeDetails($value) { if ($this->debugLog->getWriteDebugLog()) { $testArray = Functions::flattenArray($value); if (count($testArray) == 1) { $value = array_pop($testArray); } if ($value === null) { return 'a NULL value'; } elseif (is_float($value)) { $typeString = 'a floating point number'; } elseif (is_int($value)) { $typeString = 'an integer number'; } elseif (is_bool($value)) { $typeString = 'a boolean'; } elseif (is_array($value)) { $typeString = 'a matrix'; } else { if ($value == '') { return 'an empty string'; } elseif ($value[0] == '#') { return 'a ' . $value . ' error'; } $typeString = 'a string'; } return $typeString . ' with a value of ' . $this->showValue($value); }> } > return null;/** * @param string $formula *< * @return string> * @return false|string False indicates an error*/ private function convertMatrixReferences($formula) {< static $matrixReplaceFrom = ['{', ';', '}'];> static $matrixReplaceFrom = [self::FORMULA_OPEN_MATRIX_BRACE, ';', self::FORMULA_CLOSE_MATRIX_BRACE];static $matrixReplaceTo = ['MKMATRIX(MKMATRIX(', '),MKMATRIX(', '))']; // Convert any Excel matrix references to the MKMATRIX() function< if (strpos($formula, '{') !== false) {> if (strpos($formula, self::FORMULA_OPEN_MATRIX_BRACE) !== false) {// If there is the possibility of braces within a quoted string, then we don't treat those as matrix indicators< if (strpos($formula, '"') !== false) {> if (strpos($formula, self::FORMULA_STRING_QUOTE) !== false) {// So instead we skip replacing in any quoted strings by only replacing in every other array element after we've exploded // the formula< $temp = explode('"', $formula);> $temp = explode(self::FORMULA_STRING_QUOTE, $formula);// Open and Closed counts used for trapping mismatched braces in the formula $openCount = $closeCount = 0;< $i = false;> $notWithinQuotes = false;foreach ($temp as &$value) { // Only count/replace in alternating array entries< if ($i = !$i) { < $openCount += substr_count($value, '{'); < $closeCount += substr_count($value, '}');> $notWithinQuotes = $notWithinQuotes === false; > if ($notWithinQuotes === true) { > $openCount += substr_count($value, self::FORMULA_OPEN_MATRIX_BRACE); > $closeCount += substr_count($value, self::FORMULA_CLOSE_MATRIX_BRACE);$value = str_replace($matrixReplaceFrom, $matrixReplaceTo, $value); } } unset($value); // Then rebuild the formula string< $formula = implode('"', $temp);> $formula = implode(self::FORMULA_STRING_QUOTE, $temp);} else { // If there's no quoted strings, then we do a simple count/replace< $openCount = substr_count($formula, '{'); < $closeCount = substr_count($formula, '}');> $openCount = substr_count($formula, self::FORMULA_OPEN_MATRIX_BRACE); > $closeCount = substr_count($formula, self::FORMULA_CLOSE_MATRIX_BRACE);$formula = str_replace($matrixReplaceFrom, $matrixReplaceTo, $formula); } // Trap for mismatched braces and trigger an appropriate error if ($openCount < $closeCount) { if ($openCount > 0) { return $this->raiseFormulaError("Formula Error: Mismatched matrix braces '}'"); } return $this->raiseFormulaError("Formula Error: Unexpected '}' encountered"); } elseif ($openCount > $closeCount) { if ($closeCount > 0) { return $this->raiseFormulaError("Formula Error: Mismatched matrix braces '{'"); } return $this->raiseFormulaError("Formula Error: Unexpected '{' encountered"); } } return $formula; }< private static function mkMatrix(...$args) < { < return $args; < } < < // Binary Operators < // These operators always work on two values < // Array key is the operator, the value indicates whether this is a left or right associative operator> /** > * Binary Operators. > * These operators always work on two values. > * Array key is the operator, the value indicates whether this is a left or right associative operator. > * > * @var array > */private static $operatorAssociativity = [ '^' => 0, // Exponentiation '*' => 0, '/' => 0, // Multiplication and Division '+' => 0, '-' => 0, // Addition and Subtraction '&' => 0, // Concatenation< '|' => 0, ':' => 0, // Intersect and Range> '∪' => 0, '∩' => 0, ':' => 0, // Union, Intersect and Range'>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0, // Comparison ];< // Comparison (Boolean) Operators < // These operators work on two values, but always return a boolean result> /** > * Comparison (Boolean) Operators. > * These operators work on two values, but always return a boolean result. > * > * @var array > */private static $comparisonOperators = ['>' => true, '<' => true, '=' => true, '>=' => true, '<=' => true, '<>' => true];< // Operator Precedence < // This list includes all valid operators, whether binary (including boolean) or unary (such as %) < // Array key is the operator, the value is its precedence> /** > * Operator Precedence. > * This list includes all valid operators, whether binary (including boolean) or unary (such as %). > * Array key is the operator, the value is its precedence. > * > * @var array > */private static $operatorPrecedence = [< ':' => 8, // Range < '|' => 7, // Intersect> ':' => 9, // Range > '∩' => 8, // Intersect > '∪' => 7, // Union'~' => 6, // Negation '%' => 5, // Percentage '^' => 4, // Exponentiation '*' => 3, '/' => 3, // Multiplication and Division '+' => 2, '-' => 2, // Addition and Subtraction '&' => 1, // Concatenation '>' => 0, '<' => 0, '=' => 0, '>=' => 0, '<=' => 0, '<>' => 0, // Comparison ]; // Convert infix to postfix notation /** * @param string $formula< * @param null|\PhpOffice\PhpSpreadsheet\Cell\Cell $pCell*< * @return bool> * @return array<int, mixed>|false*/< private function _parseFormula($formula, Cell $pCell = null)> private function internalParseFormula($formula, ?Cell $cell = null){ if (($formula = $this->convertMatrixReferences(trim($formula))) === false) { return false; } // If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent worksheet), // so we store the parent worksheet so that we can re-attach it when necessary< $pCellParent = ($pCell !== null) ? $pCell->getWorksheet() : null;> $pCellParent = ($cell !== null) ? $cell->getWorksheet() : null;< $regexpMatchString = '/^(' . self::CALCULATION_REGEXP_FUNCTION . < '|' . self::CALCULATION_REGEXP_CELLREF . < '|' . self::CALCULATION_REGEXP_NUMBER . < '|' . self::CALCULATION_REGEXP_STRING . < '|' . self::CALCULATION_REGEXP_OPENBRACE . < '|' . self::CALCULATION_REGEXP_NAMEDRANGE . < '|' . self::CALCULATION_REGEXP_ERROR . < ')/si';> $regexpMatchString = '/^((?<string>' . self::CALCULATION_REGEXP_STRING . > ')|(?<function>' . self::CALCULATION_REGEXP_FUNCTION . > ')|(?<cellRef>' . self::CALCULATION_REGEXP_CELLREF . > ')|(?<colRange>' . self::CALCULATION_REGEXP_COLUMN_RANGE . > ')|(?<rowRange>' . self::CALCULATION_REGEXP_ROW_RANGE . > ')|(?<number>' . self::CALCULATION_REGEXP_NUMBER . > ')|(?<openBrace>' . self::CALCULATION_REGEXP_OPENBRACE . > ')|(?<structuredReference>' . self::CALCULATION_REGEXP_STRUCTURED_REFERENCE . > ')|(?<definedName>' . self::CALCULATION_REGEXP_DEFINEDNAME . > ')|(?<error>' . self::CALCULATION_REGEXP_ERROR . > '))/sui';// Start with initialisation $index = 0;< $stack = new Stack();> $stack = new Stack($this->branchPruner);$output = []; $expectingOperator = false; // We use this test in syntax-checking the expression to determine when a // - is a negation or + is a positive operator rather than an operation $expectingOperand = false; // We use this test in syntax-checking the expression to determine whether an operand // should be null in a function call< // IF branch pruning < // currently pending storeKey (last item of the storeKeysStack < $pendingStoreKey = null; < // stores a list of storeKeys (string[]) < $pendingStoreKeysStack = []; < $expectingConditionMap = []; // ['storeKey' => true, ...] < $expectingThenMap = []; // ['storeKey' => true, ...] < $expectingElseMap = []; // ['storeKey' => true, ...] < $parenthesisDepthMap = []; // ['storeKey' => 4, ...] <// The guts of the lexical parser // Loop through the formula extracting each operator and operand in turn while (true) { // Branch pruning: we adapt the output item to the context (it will // be used to limit its computation)< $currentCondition = null; < $currentOnlyIf = null; < $currentOnlyIfNot = null; < $previousStoreKey = null; < $pendingStoreKey = end($pendingStoreKeysStack); < < if ($this->branchPruningEnabled) { < // this is a condition ? < if (isset($expectingConditionMap[$pendingStoreKey]) && $expectingConditionMap[$pendingStoreKey]) { < $currentCondition = $pendingStoreKey; < $stackDepth = count($pendingStoreKeysStack); < if ($stackDepth > 1) { // nested if < $previousStoreKey = $pendingStoreKeysStack[$stackDepth - 2]; < } < } < if (isset($expectingThenMap[$pendingStoreKey]) && $expectingThenMap[$pendingStoreKey]) { < $currentOnlyIf = $pendingStoreKey; < } elseif (isset($previousStoreKey)) { < if (isset($expectingThenMap[$previousStoreKey]) && $expectingThenMap[$previousStoreKey]) { < $currentOnlyIf = $previousStoreKey; < } < } < if (isset($expectingElseMap[$pendingStoreKey]) && $expectingElseMap[$pendingStoreKey]) { < $currentOnlyIfNot = $pendingStoreKey; < } elseif (isset($previousStoreKey)) { < if (isset($expectingElseMap[$previousStoreKey]) && $expectingElseMap[$previousStoreKey]) { < $currentOnlyIfNot = $previousStoreKey; < } < } < }> $this->branchPruner->initialiseForLoop();$opCharacter = $formula[$index]; // Get the first character of the value at the current index position> if ((isset(self::$comparisonOperators[$opCharacter])) && (strlen($formula) > $index) && (isset(self::$comparisonOperators[$formula[$index + 1]]))) { > // Check for two-character operators (e.g. >=, <=, <>)$opCharacter .= $formula[++$index]; }> // Find out if we're currently at the beginning of a number, variable, cell/row/column reference, > // function, defined name, structured reference, parenthesis, error or operand // Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand > $isOperandOrFunction = (bool) preg_match($regexpMatchString, substr($formula, $index), $match);< // Find out if we're currently at the beginning of a number, variable, cell reference, function, parenthesis or operand < $isOperandOrFunction = preg_match($regexpMatchString, substr($formula, $index), $match); < < if ($opCharacter == '-' && !$expectingOperator) { // Is it a negation instead of a minus?> $expectingOperatorCopy = $expectingOperator; > if ($opCharacter === '-' && !$expectingOperator) { // Is it a negation instead of a minus?< $stack->push('Unary Operator', '~', null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);> $stack->push('Unary Operator', '~');++$index; // and drop the negation symbol< } elseif ($opCharacter == '%' && $expectingOperator) {> } elseif ($opCharacter === '%' && $expectingOperator) {// Put a percentage on the stack< $stack->push('Unary Operator', '%', null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);> $stack->push('Unary Operator', '%');++$index;< } elseif ($opCharacter == '+' && !$expectingOperator) { // Positive (unary plus rather than binary operator plus) can be discarded?> } elseif ($opCharacter === '+' && !$expectingOperator) { // Positive (unary plus rather than binary operator plus) can be discarded?++$index; // Drop the redundant plus symbol< } elseif ((($opCharacter == '~') || ($opCharacter == '|')) && (!$isOperandOrFunction)) { // We have to explicitly deny a tilde or pipe, because they are legal> } elseif ((($opCharacter === '~') || ($opCharacter === '∩') || ($opCharacter === '∪')) && (!$isOperandOrFunction)) { > // We have to explicitly deny a tilde, union or intersect because they are legalreturn $this->raiseFormulaError("Formula Error: Illegal character '~'"); // on the stack but not in the input expression< } elseif ((isset(self::$operators[$opCharacter]) or $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? < while ($stack->count() > 0 &&> } elseif ((isset(self::CALCULATION_OPERATORS[$opCharacter]) || $isOperandOrFunction) && $expectingOperator) { // Are we putting an operator on the stack? > while ( > $stack->count() > 0 &&($o2 = $stack->last()) &&< isset(self::$operators[$o2['value']]) && < @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) {> isset(self::CALCULATION_OPERATORS[$o2['value']]) && > @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']]) > ) {$output[] = $stack->pop(); // Swap operands and higher precedence operators from the stack to the output } // Finally put our current operator onto the stack< $stack->push('Binary Operator', $opCharacter, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);> $stack->push('Binary Operator', $opCharacter);++$index; $expectingOperator = false;< } elseif ($opCharacter == ')' && $expectingOperator) { // Are we expecting to close a parenthesis?> } elseif ($opCharacter === ')' && $expectingOperator) { // Are we expecting to close a parenthesis?$expectingOperand = false;< while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( < if ($o2 === null) { < return $this->raiseFormulaError('Formula Error: Unexpected closing brace ")"'); < }> while (($o2 = $stack->pop()) && $o2['value'] !== '(') { // Pop off the stack back to the last ($output[] = $o2; } $d = $stack->last(2); // Branch pruning we decrease the depth whether is it a function // call or a parenthesis< if (!empty($pendingStoreKey)) { < $parenthesisDepthMap[$pendingStoreKey] -= 1; < }> $this->branchPruner->decrementDepth();< if (is_array($d) && preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) { // Did this parenthesis just close a function? < if (!empty($pendingStoreKey) && $parenthesisDepthMap[$pendingStoreKey] == -1) { < // we are closing an IF( < if ($d['value'] != 'IF(') { < return $this->raiseFormulaError('Parser bug we should be in an "IF("'); < } < if ($expectingConditionMap[$pendingStoreKey]) { < return $this->raiseFormulaError('We should not be expecting a condition'); < } < $expectingThenMap[$pendingStoreKey] = false; < $expectingElseMap[$pendingStoreKey] = false; < $parenthesisDepthMap[$pendingStoreKey] -= 1; < array_pop($pendingStoreKeysStack); < unset($pendingStoreKey);> if (is_array($d) && preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $d['value'], $matches)) { > // Did this parenthesis just close a function? > try { > $this->branchPruner->closingBrace($d['value']); > } catch (Exception $e) { > return $this->raiseFormulaError($e->getMessage(), $e->getCode(), $e);} $functionName = $matches[1]; // Get the function name $d = $stack->pop();< $argumentCount = $d['value']; // See how many arguments there were (argument count is the next value stored on the stack)> $argumentCount = $d['value'] ?? 0; // See how many arguments there were (argument count is the next value stored on the stack)$output[] = $d; // Dump the argument count on the output $output[] = $stack->pop(); // Pop the function and push onto the output if (isset(self::$controlFunctions[$functionName])) { $expectedArgumentCount = self::$controlFunctions[$functionName]['argumentCount'];> // Scrutinizer says functionCall is unused after this assignment. $functionCall = self::$controlFunctions[$functionName]['functionCall']; > // It might be right, but I'm too lazy to confirm.} elseif (isset(self::$phpSpreadsheetFunctions[$functionName])) {> self::doNothing($functionCall);$expectedArgumentCount = self::$phpSpreadsheetFunctions[$functionName]['argumentCount']; $functionCall = self::$phpSpreadsheetFunctions[$functionName]['functionCall'];> self::doNothing($functionCall);} else { // did we somehow push a non-function on the stack? this should never happen return $this->raiseFormulaError('Formula Error: Internal error, non-function on stack'); } // Check the argument count $argumentCountError = false;> $expectedArgumentCountString = null;if (is_numeric($expectedArgumentCount)) { if ($expectedArgumentCount < 0) { if ($argumentCount > abs($expectedArgumentCount)) { $argumentCountError = true; $expectedArgumentCountString = 'no more than ' . abs($expectedArgumentCount); } } else { if ($argumentCount != $expectedArgumentCount) { $argumentCountError = true; $expectedArgumentCountString = $expectedArgumentCount; } } } elseif ($expectedArgumentCount != '*') { $isOperandOrFunction = preg_match('/(\d*)([-+,])(\d*)/', $expectedArgumentCount, $argMatch);< switch ($argMatch[2]) {> self::doNothing($isOperandOrFunction); > switch ($argMatch[2] ?? '') {case '+': if ($argumentCount < $argMatch[1]) { $argumentCountError = true; $expectedArgumentCountString = $argMatch[1] . ' or more '; } break; case '-': if (($argumentCount < $argMatch[1]) || ($argumentCount > $argMatch[3])) { $argumentCountError = true; $expectedArgumentCountString = 'between ' . $argMatch[1] . ' and ' . $argMatch[3]; } break; case ',': if (($argumentCount != $argMatch[1]) && ($argumentCount != $argMatch[3])) { $argumentCountError = true; $expectedArgumentCountString = 'either ' . $argMatch[1] . ' or ' . $argMatch[3]; } break; } } if ($argumentCountError) { return $this->raiseFormulaError("Formula Error: Wrong number of arguments for $functionName() function: $argumentCount given, " . $expectedArgumentCountString . ' expected'); } } ++$index;< } elseif ($opCharacter == ',') { // Is this the separator for function arguments? < if (!empty($pendingStoreKey) && < $parenthesisDepthMap[$pendingStoreKey] == 0 < ) { < // We must go to the IF next argument < if ($expectingConditionMap[$pendingStoreKey]) { < $expectingConditionMap[$pendingStoreKey] = false; < $expectingThenMap[$pendingStoreKey] = true; < } elseif ($expectingThenMap[$pendingStoreKey]) { < $expectingThenMap[$pendingStoreKey] = false; < $expectingElseMap[$pendingStoreKey] = true; < } elseif ($expectingElseMap[$pendingStoreKey]) { < return $this->raiseFormulaError('Reaching fourth argument of an IF'); < } < } < while (($o2 = $stack->pop()) && $o2['value'] != '(') { // Pop off the stack back to the last ( < if ($o2 === null) { < return $this->raiseFormulaError('Formula Error: Unexpected ,');> } elseif ($opCharacter === ',') { // Is this the separator for function arguments? > try { > $this->branchPruner->argumentSeparator(); > } catch (Exception $e) { > return $this->raiseFormulaError($e->getMessage(), $e->getCode(), $e);}> $output[] = $o2; // pop the argument expression stuff and push onto the output > while (($o2 = $stack->pop()) && $o2['value'] !== '(') { // Pop off the stack back to the last (} // If we've a comma when we're expecting an operand, then what we actually have is a null operand; // so push a null onto the stack if (($expectingOperand) || (!$expectingOperator)) {< $output[] = ['type' => 'NULL Value', 'value' => self::$excelConstants['NULL'], 'reference' => null];> $output[] = ['type' => 'Empty Argument', 'value' => self::$excelConstants['NULL'], 'reference' => 'NULL'];} // make sure there was a function $d = $stack->last(2);< if (!preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $d['value'], $matches)) {> if (!preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $d['value'] ?? '', $matches)) { > // Can we inject a dummy function at this point so that the braces at least have some context > // because at least the braces are paired up (at this stage in the formula) > // MS Excel allows this if the content is cell references; but doesn't allow actual values, > // but at this point, we can't differentiate (so allow both)return $this->raiseFormulaError('Formula Error: Unexpected ,'); }> $d = $stack->pop(); > /** @var array $d */< $itemStoreKey = $d['storeKey'] ?? null; < $itemOnlyIf = $d['onlyIf'] ?? null; < $itemOnlyIfNot = $d['onlyIfNot'] ?? null; < $stack->push($d['type'], ++$d['value'], $d['reference'], $itemStoreKey, $itemOnlyIf, $itemOnlyIfNot); // increment the argument count < $stack->push('Brace', '(', null, $itemStoreKey, $itemOnlyIf, $itemOnlyIfNot); // put the ( back on, we'll need to pop back to it again> ++$d['value']; // increment the argument count > > $stack->pushStackItem($d); > $stack->push('Brace', '('); // put the ( back on, we'll need to pop back to it again >$expectingOperator = false; $expectingOperand = true; ++$index;< } elseif ($opCharacter == '(' && !$expectingOperator) { < if (!empty($pendingStoreKey)) { // Branch pruning: we go deeper < $parenthesisDepthMap[$pendingStoreKey] += 1; < } < $stack->push('Brace', '(', null, $currentCondition, $currentOnlyIf, $currentOnlyIf);> } elseif ($opCharacter === '(' && !$expectingOperator) { > // Branch pruning: we go deeper > $this->branchPruner->incrementDepth(); > $stack->push('Brace', '(', null);++$index;< } elseif ($isOperandOrFunction && !$expectingOperator) { // do we now have a function/variable/number?> } elseif ($isOperandOrFunction && !$expectingOperatorCopy) { > // do we now have a function/variable/number?$expectingOperator = true; $expectingOperand = false; $val = $match[1]; $length = strlen($val);< if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $val, $matches)) { < $val = preg_replace('/\s/u', '', $val);> if (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $val, $matches)) { > $val = (string) preg_replace('/\s/u', '', $val);if (isset(self::$phpSpreadsheetFunctions[strtoupper($matches[1])]) || isset(self::$controlFunctions[strtoupper($matches[1])])) { // it's a function $valToUpper = strtoupper($val);> } else { // here $matches[1] will contain values like "IF" > $valToUpper = 'NAME.ERROR('; // and $val "IF(" > }< if ($this->branchPruningEnabled && ($valToUpper == 'IF(')) { // we handle a new if < $pendingStoreKey = $this->getUnusedBranchStoreKey(); < $pendingStoreKeysStack[] = $pendingStoreKey; < $expectingConditionMap[$pendingStoreKey] = true; < $parenthesisDepthMap[$pendingStoreKey] = 0; < } else { // this is not a if but we good deeper < if (!empty($pendingStoreKey) && array_key_exists($pendingStoreKey, $parenthesisDepthMap)) { < $parenthesisDepthMap[$pendingStoreKey] += 1; < } < }< $stack->push('Function', $valToUpper, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);> $this->branchPruner->functionCall($valToUpper); > > $stack->push('Function', $valToUpper);// tests if the function is closed right after opening< $ax = preg_match('/^\s*(\s*\))/ui', substr($formula, $index + $length), $amatch);> $ax = preg_match('/^\s*\)/u', substr($formula, $index + $length));if ($ax) {< $stack->push('Operand Count for Function ' . $valToUpper . ')', 0, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);> $stack->push('Operand Count for Function ' . $valToUpper . ')', 0);$expectingOperator = true; } else {< $stack->push('Operand Count for Function ' . $valToUpper . ')', 1, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);> $stack->push('Operand Count for Function ' . $valToUpper . ')', 1);$expectingOperator = false; } $stack->push('Brace', '(');< } else { // it's a var w/ implicit multiplication < $output[] = ['type' => 'Value', 'value' => $matches[1], 'reference' => null]; < } < } elseif (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $val, $matches)) {> } elseif (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/miu', $val, $matches)) {// Watch for this case-change when modifying to allow cell references in different worksheets... // Should only be applied to the actual cell column, not the worksheet name<// If the last entry on the stack was a : operator, then we have a cell range reference $testPrevOp = $stack->last(1);< if ($testPrevOp !== null && $testPrevOp['value'] == ':') {> if ($testPrevOp !== null && $testPrevOp['value'] === ':') {// If we have a worksheet reference, then we're playing with a 3D reference< if ($matches[2] == '') {> if ($matches[2] === '') {// Otherwise, we 'inherit' the worksheet reference from the start cell reference // The start of the cell range reference should be the last entry in $output< $startCellRef = $output[count($output) - 1]['value']; < preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $startCellRef, $startMatches); < if ($startMatches[2] > '') { < $val = $startMatches[2] . '!' . $val;> $rangeStartCellRef = $output[count($output) - 1]['value'] ?? ''; > if ($rangeStartCellRef === ':') { > // Do we have chained range operators? > $rangeStartCellRef = $output[count($output) - 2]['value'] ?? ''; > } > preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/miu', $rangeStartCellRef, $rangeStartMatches); > if (array_key_exists(2, $rangeStartMatches)) { > if ($rangeStartMatches[2] > '') { > $val = $rangeStartMatches[2] . '!' . $val; > } > } else { > $val = Information\ExcelError::REF();} } else {> $rangeStartCellRef = $output[count($output) - 1]['value'] ?? ''; return $this->raiseFormulaError('3D Range references are not yet supported'); > if ($rangeStartCellRef === ':') { } > // Do we have chained range operators? } > $rangeStartCellRef = $output[count($output) - 2]['value'] ?? ''; > } $outputItem = $stack->getStackItem('Cell Reference', $val, $val, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); > preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/miu', $rangeStartCellRef, $rangeStartMatches); > if ($rangeStartMatches[2] !== $matches[2]) {$output[] = $outputItem;> } elseif (strpos($val, '!') === false && $pCellParent !== null) { } else { // it's a variable, constant, string, number or boolean > $worksheet = $pCellParent->getTitle(); // If the last entry on the stack was a : operator, then we may have a row or column range reference > $val = "'{$worksheet}'!{$val}"; $testPrevOp = $stack->last(1); > } if ($testPrevOp !== null && $testPrevOp['value'] === ':') { > // unescape any apostrophes or double quotes in worksheet name $startRowColRef = $output[count($output) - 1]['value']; > $val = str_replace(["''", '""'], ["'", '"'], $val); [$rangeWS1, $startRowColRef] = Worksheet::extractSheetTitle($startRowColRef, true); > $outputItem = $stack->getStackItem('Cell Reference', $val, $val);< $outputItem = $stack->getStackItem('Cell Reference', $val, $val, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);> $output[] = $outputItem; > } elseif (preg_match('/^' . self::CALCULATION_REGEXP_STRUCTURED_REFERENCE . '$/miu', $val, $matches)) { > try { > $structuredReference = Operands\StructuredReference::fromParser($formula, $index, $matches); > } catch (Exception $e) { > return $this->raiseFormulaError($e->getMessage(), $e->getCode(), $e); > } > > $val = $structuredReference->value(); > $length = strlen($val); > $outputItem = $stack->getStackItem(Operands\StructuredReference::NAME, $structuredReference, null);< } else { // it's a variable, constant, string, number or boolean> $expectingOperator = true; > } else { > // it's a variable, constant, string, number or boolean > $localeConstant = false; > $stackItemType = 'Value'; > $stackItemReference = null; >< $startRowColRef = $output[count($output) - 1]['value'];> $stackItemType = 'Cell Reference'; > > if ( > !is_numeric($val) && > ((ctype_alpha($val) === false || strlen($val) > 3)) && > (preg_match('/^' . self::CALCULATION_REGEXP_DEFINEDNAME . '$/mui', $val) !== false) && > ($this->spreadsheet === null || $this->spreadsheet->getNamedRange($val) !== null) > ) { > $namedRange = ($this->spreadsheet === null) ? null : $this->spreadsheet->getNamedRange($val); > if ($namedRange !== null) { > $stackItemType = 'Defined Name'; > $address = str_replace('$', '', $namedRange->getValue()); > $stackItemReference = $val; > if (strpos($address, ':') !== false) { > // We'll need to manipulate the stack for an actual named range rather than a named cell > $fromTo = explode(':', $address); > $to = array_pop($fromTo); > foreach ($fromTo as $from) { > $output[] = $stack->getStackItem($stackItemType, $from, $stackItemReference); > $output[] = $stack->getStackItem('Binary Operator', ':'); > } > $address = $to; > } > $val = $address; > } > } elseif ($val === Information\ExcelError::REF()) { > $stackItemReference = $val; > } else { > $startRowColRef = $output[count($output) - 1]['value'] ?? '';< if ($rangeWS1 != '') {> if ($rangeWS1 !== '') {[$rangeWS2, $val] = Worksheet::extractSheetTitle($val, true);> $rangeSheetRef = trim($rangeSheetRef, "'");< if ($rangeWS2 != '') {> if ($rangeWS2 !== '') {$rangeWS2 .= '!'; } else { $rangeWS2 = $rangeWS1; }>$refSheet = $pCellParent;< if ($pCellParent !== null && $rangeSheetRef !== $pCellParent->getTitle()) { < $refSheet = $pCellParent->getParent()->getSheetByName($rangeSheetRef);> if ($pCellParent !== null && $rangeSheetRef !== '' && $rangeSheetRef !== $pCellParent->getTitle()) { > $refSheet = $pCellParent->getParentOrThrow()->getSheetByName($rangeSheetRef);}< if ((is_int($startRowColRef)) && (ctype_digit($val)) && < ($startRowColRef <= 1048576) && ($val <= 1048576)) {> > if (ctype_digit($val) && $val <= 1048576) {// Row range< $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestColumn() : 'XFD'; // Max 16,384 columns for Excel2007 < $output[count($output) - 1]['value'] = $rangeWS1 . 'A' . $startRowColRef; < $val = $rangeWS2 . $endRowColRef . $val; < } elseif ((ctype_alpha($startRowColRef)) && (ctype_alpha($val)) && < (strlen($startRowColRef) <= 3) && (strlen($val) <= 3)) {> $stackItemType = 'Row Reference'; > /** @var int $valx */ > $valx = $val; > $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestDataColumn($valx) : AddressRange::MAX_COLUMN; // Max 16,384 columns for Excel2007 > $val = "{$rangeWS2}{$endRowColRef}{$val}"; > } elseif (ctype_alpha($val) && strlen($val) <= 3) {// Column range< $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestRow() : 1048576; // Max 1,048,576 rows for Excel2007 < $output[count($output) - 1]['value'] = $rangeWS1 . strtoupper($startRowColRef) . '1'; < $val = $rangeWS2 . $val . $endRowColRef;> $stackItemType = 'Column Reference'; > $endRowColRef = ($refSheet !== null) ? $refSheet->getHighestDataRow($val) : AddressRange::MAX_ROW; // Max 1,048,576 rows for Excel2007 > $val = "{$rangeWS2}{$val}{$endRowColRef}";}> $stackItemReference = $val;}< < $localeConstant = false; < if ($opCharacter == '"') {> } elseif ($opCharacter === self::FORMULA_STRING_QUOTE) {// UnEscape any quotes within the string< $val = self::wrapResult(str_replace('""', '"', self::unwrapResult($val))); < } elseif (is_numeric($val)) { < if ((strpos($val, '.') !== false) || (stripos($val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) { < $val = (float) $val; < } else { < $val = (int) $val; < }> $val = self::wrapResult(str_replace('""', self::FORMULA_STRING_QUOTE, self::unwrapResult($val)));} elseif (isset(self::$excelConstants[trim(strtoupper($val))])) {> $stackItemType = 'Constant';$excelConstant = trim(strtoupper($val)); $val = self::$excelConstants[$excelConstant];> $stackItemReference = $excelConstant;} elseif (($localeConstant = array_search(trim(strtoupper($val)), self::$localeBoolean)) !== false) {> $stackItemType = 'Constant';$val = self::$excelConstants[$localeConstant];> $stackItemReference = $localeConstant; } > } elseif ( $details = $stack->getStackItem('Value', $val, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot); > preg_match('/^' . self::CALCULATION_REGEXP_ROW_RANGE . '/miu', substr($formula, $index), $rowRangeReference) if ($localeConstant) { > ) { $details['localeValue'] = $localeConstant; > $val = $rowRangeReference[1]; } > $length = strlen($rowRangeReference[1]); $output[] = $details; > $stackItemType = 'Row Reference'; } > // unescape any apostrophes or double quotes in worksheet name $index += $length; > $val = str_replace(["''", '""'], ["'", '"'], $val); } elseif ($opCharacter == '$') { // absolute row or column range > $column = 'A'; ++$index; > if (($testPrevOp !== null && $testPrevOp['value'] === ':') && $pCellParent !== null) { } elseif ($opCharacter == ')') { // miscellaneous error checking > $column = $pCellParent->getHighestDataColumn($val); if ($expectingOperand) { > } $output[] = ['type' => 'NULL Value', 'value' => self::$excelConstants['NULL'], 'reference' => null]; > $val = "{$rowRangeReference[2]}{$column}{$rowRangeReference[7]}"; $expectingOperand = false; > $stackItemReference = $val; $expectingOperator = true; > } elseif ( } else { > preg_match('/^' . self::CALCULATION_REGEXP_COLUMN_RANGE . '/miu', substr($formula, $index), $columnRangeReference) return $this->raiseFormulaError("Formula Error: Unexpected ')'"); > ) { } > $val = $columnRangeReference[1]; } elseif (isset(self::$operators[$opCharacter]) && !$expectingOperator) { > $length = strlen($val); return $this->raiseFormulaError("Formula Error: Unexpected operator '$opCharacter'"); > $stackItemType = 'Column Reference'; } else { // I don't even want to know what you did to get here > // unescape any apostrophes or double quotes in worksheet name return $this->raiseFormulaError('Formula Error: An unexpected error occured'); > $val = str_replace(["''", '""'], ["'", '"'], $val); } > $row = '1'; // Test for end of formula string > if (($testPrevOp !== null && $testPrevOp['value'] === ':') && $pCellParent !== null) { if ($index == strlen($formula)) { > $row = $pCellParent->getHighestDataRow($val); // Did we end with an operator?. > } // Only valid for the % unary operator > $val = "{$val}{$row}"; if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) { > $stackItemReference = $val; return $this->raiseFormulaError("Formula Error: Operator '$opCharacter' has no operands"); > } elseif (preg_match('/^' . self::CALCULATION_REGEXP_DEFINEDNAME . '.*/miu', $val, $match)) { } > $stackItemType = 'Defined Name'; > $stackItemReference = $val; break; > } elseif (is_numeric($val)) { } > if ((strpos((string) $val, '.') !== false) || (stripos((string) $val, 'e') !== false) || ($val > PHP_INT_MAX) || ($val < -PHP_INT_MAX)) { // Ignore white space > $val = (float) $val; while (($formula[$index] == "\n") || ($formula[$index] == "\r")) { > } else { ++$index; > $val = (int) $val; } > }< $details = $stack->getStackItem('Value', $val, null, $currentCondition, $currentOnlyIf, $currentOnlyIfNot);> > $details = $stack->getStackItem($stackItemType, $val, $stackItemReference);< } elseif ($opCharacter == '$') { // absolute row or column range> } elseif ($opCharacter === '$') { // absolute row or column range< } elseif ($opCharacter == ')') { // miscellaneous error checking> } elseif ($opCharacter === ')') { // miscellaneous error checking< $output[] = ['type' => 'NULL Value', 'value' => self::$excelConstants['NULL'], 'reference' => null];> $output[] = ['type' => 'Empty Argument', 'value' => self::$excelConstants['NULL'], 'reference' => 'NULL'];< } elseif (isset(self::$operators[$opCharacter]) && !$expectingOperator) {> } elseif (isset(self::CALCULATION_OPERATORS[$opCharacter]) && !$expectingOperator) {< return $this->raiseFormulaError('Formula Error: An unexpected error occured');> return $this->raiseFormulaError('Formula Error: An unexpected error occurred');< if ((isset(self::$operators[$opCharacter])) && ($opCharacter != '%')) {> if ((isset(self::CALCULATION_OPERATORS[$opCharacter])) && ($opCharacter != '%')) {< while (($formula[$index] == "\n") || ($formula[$index] == "\r")) {> while (($formula[$index] === "\n") || ($formula[$index] === "\r")) {< if ($formula[$index] == ' ') { < while ($formula[$index] == ' ') {> > if ($formula[$index] === ' ') { > while ($formula[$index] === ' ') {isset(self::$operators[$o2['value']]) &&>< // Cell References) then we have an INTERSECTION operator < if (($expectingOperator) && (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/Ui', substr($formula, $index), $match)) && < ($output[count($output) - 1]['type'] == 'Cell Reference')) { < while ($stack->count() > 0 &&> // Cell References, Defined Names or Structured References) then we have an INTERSECTION operator > $countOutputMinus1 = count($output) - 1; > if ( > ($expectingOperator) && > array_key_exists($countOutputMinus1, $output) && > is_array($output[$countOutputMinus1]) && > array_key_exists('type', $output[$countOutputMinus1]) && > ( > (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '.*/miu', substr($formula, $index), $match)) && > ($output[$countOutputMinus1]['type'] === 'Cell Reference') || > (preg_match('/^' . self::CALCULATION_REGEXP_DEFINEDNAME . '.*/miu', substr($formula, $index), $match)) && > ($output[$countOutputMinus1]['type'] === 'Defined Name' || $output[$countOutputMinus1]['type'] === 'Value') || > (preg_match('/^' . self::CALCULATION_REGEXP_STRUCTURED_REFERENCE . '.*/miu', substr($formula, $index), $match)) && > ($output[$countOutputMinus1]['type'] === Operands\StructuredReference::NAME || $output[$countOutputMinus1]['type'] === 'Value') > ) > ) { > while ( > $stack->count() > 0 &&< isset(self::$operators[$o2['value']]) && < @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']])) {> isset(self::CALCULATION_OPERATORS[$o2['value']]) && > @(self::$operatorAssociativity[$opCharacter] ? self::$operatorPrecedence[$opCharacter] < self::$operatorPrecedence[$o2['value']] : self::$operatorPrecedence[$opCharacter] <= self::$operatorPrecedence[$o2['value']]) > ) {< $stack->push('Binary Operator', '|'); // Put an Intersect Operator on the stack> $stack->push('Binary Operator', '∩'); // Put an Intersect Operator on the stack}< while (($op = $stack->pop()) !== null) { // pop everything off the stack and push onto output < if ((is_array($op) && $op['value'] == '(') || ($op === '(')) {> while (($op = $stack->pop()) !== null) { > // pop everything off the stack and push onto output > if ((is_array($op) && $op['value'] == '(')) {return $this->raiseFormulaError("Formula Error: Expecting ')'"); // if there are any opening braces on the stack, then braces were unbalanced } $output[] = $op; } return $output; }> /** private static function dataTestReference(&$operandData) > * @param array $operandData { > * $operand = $operandData['value']; > * @return mixed if (($operandData['reference'] === null) && (is_array($operand))) { > */$rKeys = array_keys($operand); $rowKey = array_shift($rKeys);> if (is_array($operand[$rowKey]) === false) { $cKeys = array_keys(array_keys($operand[$rowKey])); > $operandData['value'] = $operand[$rowKey]; $colKey = array_shift($cKeys); > if (ctype_upper($colKey)) { > return $operand[$rowKey]; $operandData['reference'] = $colKey . $rowKey; > } } >< if (ctype_upper($colKey)) {> if (ctype_upper("$colKey")) {return $operand; }< // evaluate postfix notation </** * @param mixed $tokens * @param null|string $cellID< * @param null|Cell $pCell*< * @return bool> * @return array<int, mixed>|false*/< private function processTokenStack($tokens, $cellID = null, Cell $pCell = null)> private function processTokenStack($tokens, $cellID = null, ?Cell $cell = null){< if ($tokens == false) {> if ($tokens === false) {return false; } // If we're using cell caching, then $pCell may well be flushed back to the cache (which detaches the parent cell collection), // so we store the parent cell collection so that we can re-attach it when necessary< $pCellWorksheet = ($pCell !== null) ? $pCell->getWorksheet() : null; < $pCellParent = ($pCell !== null) ? $pCell->getParent() : null; < $stack = new Stack();> $pCellWorksheet = ($cell !== null) ? $cell->getWorksheet() : null; > $pCellParent = ($cell !== null) ? $cell->getParent() : null; > $stack = new Stack($this->branchPruner);// Stores branches that have been pruned $fakedForBranchPruning = []; // help us to know when pruning ['branchTestId' => true/false] $branchStore = [];<// Loop through each token in turn foreach ($tokens as $tokenData) { $token = $tokenData['value'];<// Branch pruning: skip useless resolutions $storeKey = $tokenData['storeKey'] ?? null; if ($this->branchPruningEnabled && isset($tokenData['onlyIf'])) { $onlyIfStoreKey = $tokenData['onlyIf']; $storeValue = $branchStore[$onlyIfStoreKey] ?? null; $storeValueAsBool = ($storeValue === null) ? true : (bool) Functions::flattenSingleValue($storeValue); if (is_array($storeValue)) { $wrappedItem = end($storeValue);< $storeValue = end($wrappedItem);> $storeValue = is_array($wrappedItem) ? end($wrappedItem) : $wrappedItem;}< if (isset($storeValue) < && ( < !$storeValueAsBool < || Functions::isError($storeValue) < || ($storeValue === 'Pruned branch') < )> if ( > (isset($storeValue) || $tokenData['reference'] === 'NULL') > && (!$storeValueAsBool || Information\ErrorValue::isError($storeValue) || ($storeValue === 'Pruned branch'))) { // If branching value is not true, we don't need to compute if (!isset($fakedForBranchPruning['onlyIf-' . $onlyIfStoreKey])) { $stack->push('Value', 'Pruned branch (only if ' . $onlyIfStoreKey . ') ' . $token); $fakedForBranchPruning['onlyIf-' . $onlyIfStoreKey] = true; } if (isset($storeKey)) { // We are processing an if condition // We cascade the pruning to the depending branches $branchStore[$storeKey] = 'Pruned branch'; $fakedForBranchPruning['onlyIfNot-' . $storeKey] = true; $fakedForBranchPruning['onlyIf-' . $storeKey] = true; } continue; } } if ($this->branchPruningEnabled && isset($tokenData['onlyIfNot'])) { $onlyIfNotStoreKey = $tokenData['onlyIfNot']; $storeValue = $branchStore[$onlyIfNotStoreKey] ?? null; $storeValueAsBool = ($storeValue === null) ? true : (bool) Functions::flattenSingleValue($storeValue); if (is_array($storeValue)) { $wrappedItem = end($storeValue);< $storeValue = end($wrappedItem);> $storeValue = is_array($wrappedItem) ? end($wrappedItem) : $wrappedItem;}< if (isset($storeValue) < && ( < $storeValueAsBool < || Functions::isError($storeValue) < || ($storeValue === 'Pruned branch'))> > if ( > (isset($storeValue) || $tokenData['reference'] === 'NULL') > && ($storeValueAsBool || Information\ErrorValue::isError($storeValue) || ($storeValue === 'Pruned branch'))) { // If branching value is true, we don't need to compute if (!isset($fakedForBranchPruning['onlyIfNot-' . $onlyIfNotStoreKey])) { $stack->push('Value', 'Pruned branch (only if not ' . $onlyIfNotStoreKey . ') ' . $token); $fakedForBranchPruning['onlyIfNot-' . $onlyIfNotStoreKey] = true; } if (isset($storeKey)) { // We are processing an if condition // We cascade the pruning to the depending branches $branchStore[$storeKey] = 'Pruned branch'; $fakedForBranchPruning['onlyIfNot-' . $storeKey] = true; $fakedForBranchPruning['onlyIf-' . $storeKey] = true; } continue; } }> if ($token instanceof Operands\StructuredReference) { // if the token is a binary operator, pop the top two values off the stack, do the operation, and push the result back on the stack > if ($cell === null) { if (isset(self::$binaryOperators[$token])) { > return $this->raiseFormulaError('Structured References must exist in a Cell context'); // We must have two operands, error if we don't > } if (($operand2Data = $stack->pop()) === null) { > return $this->raiseFormulaError('Internal error - Operand value missing from stack'); > try { } > $cellRange = $token->parse($cell); if (($operand1Data = $stack->pop()) === null) { > if (strpos($cellRange, ':') !== false) { return $this->raiseFormulaError('Internal error - Operand value missing from stack'); > $this->debugLog->writeDebugLog('Evaluating Structured Reference %s as Cell Range %s', $token->value(), $cellRange); } > $rangeValue = self::getInstance($cell->getWorksheet()->getParent())->_calculateFormulaValue("={$cellRange}", $cellRange, $cell); > $stack->push('Value', $rangeValue); $operand1 = self::dataTestReference($operand1Data); > $this->debugLog->writeDebugLog('Evaluated Structured Reference %s as value %s', $token->value(), $this->showValue($rangeValue)); $operand2 = self::dataTestReference($operand2Data); > } else { > $this->debugLog->writeDebugLog('Evaluating Structured Reference %s as Cell %s', $token->value(), $cellRange); // Log what we're doing > $cellValue = $cell->getWorksheet()->getCell($cellRange)->getCalculatedValue(false); if ($token == ':') { > $stack->push('Cell Reference', $cellValue, $cellRange); $this->debugLog->writeDebugLog('Evaluating Range ', $this->showValue($operand1Data['reference']), ' ', $token, ' ', $this->showValue($operand2Data['reference'])); > $this->debugLog->writeDebugLog('Evaluated Structured Reference %s as value %s', $token->value(), $this->showValue($cellValue)); } else { > } $this->debugLog->writeDebugLog('Evaluating ', $this->showValue($operand1), ' ', $token, ' ', $this->showValue($operand2)); > } catch (Exception $e) { } > if ($e->getCode() === Exception::CALCULATION_ENGINE_PUSH_TO_STACK) { > $stack->push('Error', Information\ExcelError::REF(), null); // Process the operation in the appropriate manner > $this->debugLog->writeDebugLog('Evaluated Structured Reference %s as error value %s', $token->value(), Information\ExcelError::REF()); switch ($token) { > } else { // Comparison (Boolean) Operators > return $this->raiseFormulaError($e->getMessage(), $e->getCode(), $e); case '>': // Greater than > } case '<': // Less than > } case '>=': // Greater than or Equal to > } elseif (!is_numeric($token) && !is_object($token) && isset(self::BINARY_OPERATORS[$token])) {< if (isset(self::$binaryOperators[$token])) {< $this->debugLog->writeDebugLog('Evaluating Range ', $this->showValue($operand1Data['reference']), ' ', $token, ' ', $this->showValue($operand2Data['reference']));> $this->debugLog->writeDebugLog('Evaluating Range %s %s %s', $this->showValue($operand1Data['reference']), $token, $this->showValue($operand2Data['reference']));< $this->debugLog->writeDebugLog('Evaluating ', $this->showValue($operand1), ' ', $token, ' ', $this->showValue($operand2));> $this->debugLog->writeDebugLog('Evaluating %s %s %s', $this->showValue($operand1), $token, $this->showValue($operand2));< $result = $this->executeBinaryComparisonOperation($cellID, $operand1, $operand2, $token, $stack);> $result = $this->executeBinaryComparisonOperation($operand1, $operand2, (string) $token, $stack);if (isset($storeKey)) { $branchStore[$storeKey] = $result; } break; // Binary Operators case ':': // Range< if (strpos($operand1Data['reference'], '!') !== false) {> if ($operand1Data['type'] === 'Defined Name') { > if (preg_match('/$' . self::CALCULATION_REGEXP_DEFINEDNAME . '^/mui', $operand1Data['reference']) !== false && $this->spreadsheet !== null) { > $definedName = $this->spreadsheet->getNamedRange($operand1Data['reference']); > if ($definedName !== null) { > $operand1Data['reference'] = $operand1Data['value'] = str_replace('$', '', $definedName->getValue()); > } > } > } > if (strpos($operand1Data['reference'] ?? '', '!') !== false) {[$sheet1, $operand1Data['reference']] = Worksheet::extractSheetTitle($operand1Data['reference'], true); } else {< $sheet1 = ($pCellParent !== null) ? $pCellWorksheet->getTitle() : '';> $sheet1 = ($pCellWorksheet !== null) ? $pCellWorksheet->getTitle() : '';} [$sheet2, $operand2Data['reference']] = Worksheet::extractSheetTitle($operand2Data['reference'], true); if (empty($sheet2)) { $sheet2 = $sheet1; }< if ($sheet1 == $sheet2) { < if ($operand1Data['reference'] === null) { < if ((trim($operand1Data['value']) != '') && (is_numeric($operand1Data['value']))) { < $operand1Data['reference'] = $pCell->getColumn() . $operand1Data['value']; < } elseif (trim($operand1Data['reference']) == '') { < $operand1Data['reference'] = $pCell->getCoordinate(); < } else { < $operand1Data['reference'] = $operand1Data['value'] . $pCell->getRow(); < } < } < if ($operand2Data['reference'] === null) { < if ((trim($operand2Data['value']) != '') && (is_numeric($operand2Data['value']))) { < $operand2Data['reference'] = $pCell->getColumn() . $operand2Data['value']; < } elseif (trim($operand2Data['reference']) == '') { < $operand2Data['reference'] = $pCell->getCoordinate();> if (trim($sheet1, "'") === trim($sheet2, "'")) { > if ($operand1Data['reference'] === null && $cell !== null) { > if (is_array($operand1Data['value'])) { > $operand1Data['reference'] = $cell->getCoordinate(); > } elseif ((trim($operand1Data['value']) != '') && (is_numeric($operand1Data['value']))) { > $operand1Data['reference'] = $cell->getColumn() . $operand1Data['value']; > } elseif (trim($operand1Data['value']) == '') { > $operand1Data['reference'] = $cell->getCoordinate(); > } else { > $operand1Data['reference'] = $operand1Data['value'] . $cell->getRow(); > } > } > if ($operand2Data['reference'] === null && $cell !== null) { > if (is_array($operand2Data['value'])) { > $operand2Data['reference'] = $cell->getCoordinate(); > } elseif ((trim($operand2Data['value']) != '') && (is_numeric($operand2Data['value']))) { > $operand2Data['reference'] = $cell->getColumn() . $operand2Data['value']; > } elseif (trim($operand2Data['value']) == '') { > $operand2Data['reference'] = $cell->getCoordinate();} else {< $operand2Data['reference'] = $operand2Data['value'] . $pCell->getRow();> $operand2Data['reference'] = $operand2Data['value'] . $cell->getRow();} } $oData = array_merge(explode(':', $operand1Data['reference']), explode(':', $operand2Data['reference'])); $oCol = $oRow = [];> $breakNeeded = false;foreach ($oData as $oDatum) {> try {$oCR = Coordinate::coordinateFromString($oDatum); $oCol[] = Coordinate::columnIndexFromString($oCR[0]) - 1; $oRow[] = $oCR[1];> } catch (\Exception $e) { } > $stack->push('Error', Information\ExcelError::REF(), null); $cellRef = Coordinate::stringFromColumnIndex(min($oCol) + 1) . min($oRow) . ':' . Coordinate::stringFromColumnIndex(max($oCol) + 1) . max($oRow); > $breakNeeded = true; if ($pCellParent !== null) { > $cellValue = $this->extractCellRange($cellRef, $this->spreadsheet->getSheetByName($sheet1), false); > break; } else { > } return $this->raiseFormulaError('Unable to access Cell Reference'); > } } > if ($breakNeeded) { $stack->push('Cell Reference', $cellValue, $cellRef); > break;< if ($pCellParent !== null) {> if ($pCellParent !== null && $this->spreadsheet !== null) {$stack->push('Error', Functions::REF(), null);> } > $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails($cellValue));< $stack->push('Error', Functions::REF(), null);> $this->debugLog->writeDebugLog('Evaluation Result is a #REF! Error'); > $stack->push('Error', Information\ExcelError::REF(), null);break; case '+': // Addition< $result = $this->executeNumericBinaryOperation($operand1, $operand2, $token, 'plusEquals', $stack); < if (isset($storeKey)) { < $branchStore[$storeKey] = $result; < } < < break;case '-': // Subtraction< $result = $this->executeNumericBinaryOperation($operand1, $operand2, $token, 'minusEquals', $stack); < if (isset($storeKey)) { < $branchStore[$storeKey] = $result; < } < < break;case '*': // Multiplication< $result = $this->executeNumericBinaryOperation($operand1, $operand2, $token, 'arrayTimesEquals', $stack); < if (isset($storeKey)) { < $branchStore[$storeKey] = $result; < } < < break;case '/': // Division< $result = $this->executeNumericBinaryOperation($operand1, $operand2, $token, 'arrayRightDivide', $stack); < if (isset($storeKey)) { < $branchStore[$storeKey] = $result; < } < < break;case '^': // Exponential< $result = $this->executeNumericBinaryOperation($operand1, $operand2, $token, 'power', $stack);> $result = $this->executeNumericBinaryOperation($operand1, $operand2, $token, $stack);if (isset($storeKey)) { $branchStore[$storeKey] = $result; } break; case '&': // Concatenation // If either of the operands is a matrix, we need to treat them both as matrices // (converting the other operand to a matrix if need be); then perform the required // matrix operation< if (is_bool($operand1)) { < $operand1 = ($operand1) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE'];> $operand1 = self::boolToString($operand1); > $operand2 = self::boolToString($operand2); > if (is_array($operand1) || is_array($operand2)) { > if (is_string($operand1)) { > $operand1 = self::unwrapResult($operand1);}< if (is_bool($operand2)) { < $operand2 = ($operand2) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE'];> if (is_string($operand2)) { > $operand2 = self::unwrapResult($operand2);}< if ((is_array($operand1)) || (is_array($operand2))) {// Ensure that both operands are arrays/matrices< self::checkMatrixOperands($operand1, $operand2, 2);> [$rows, $columns] = self::checkMatrixOperands($operand1, $operand2, 2);< try { < // Convert operand 1 from a PHP array to a matrix < $matrix = new Shared\JAMA\Matrix($operand1); < // Perform the required operation against the operand 1 matrix, passing in operand 2 < $matrixResult = $matrix->concat($operand2); < $result = $matrixResult->getArray(); < } catch (\Exception $ex) { < $this->debugLog->writeDebugLog('JAMA Matrix Exception: ', $ex->getMessage()); < $result = '#VALUE!'; < } < } else { < $result = '"' . str_replace('""', '"', self::unwrapResult($operand1) . self::unwrapResult($operand2)) . '"';> for ($row = 0; $row < $rows; ++$row) { > for ($column = 0; $column < $columns; ++$column) { > $operand1[$row][$column] = > Shared\StringHelper::substring( > self::boolToString($operand1[$row][$column]) > . self::boolToString($operand2[$row][$column]), > 0, > DataType::MAX_STRING_LENGTH > ); > } > } > $result = $operand1; > } else { > // In theory, we should truncate here. > // But I can't figure out a formula > // using the concatenation operator > // with literals that fits in 32K, > // so I don't think we can overflow here. > $result = self::FORMULA_STRING_QUOTE . str_replace('""', self::FORMULA_STRING_QUOTE, self::unwrapResult($operand1) . self::unwrapResult($operand2)) . self::FORMULA_STRING_QUOTE;}< $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result));> $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails($result));$stack->push('Value', $result); if (isset($storeKey)) { $branchStore[$storeKey] = $result; } break;< case '|': // Intersect> case '∩': // Intersect$rowIntersect = array_intersect_key($operand1, $operand2); $cellIntersect = $oCol = $oRow = []; foreach (array_keys($rowIntersect) as $row) { $oRow[] = $row; foreach ($rowIntersect[$row] as $col => $data) { $oCol[] = Coordinate::columnIndexFromString($col) - 1; $cellIntersect[$row] = array_intersect_key($operand1[$row], $operand2[$row]); } }< $cellRef = Coordinate::stringFromColumnIndex(min($oCol) + 1) . min($oRow) . ':' . Coordinate::stringFromColumnIndex(max($oCol) + 1) . max($oRow); < $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($cellIntersect));> if (count(Functions::flattenArray($cellIntersect)) === 0) { > $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails($cellIntersect)); > $stack->push('Error', Information\ExcelError::null(), null); > } else { > $cellRef = Coordinate::stringFromColumnIndex(min($oCol) + 1) . min($oRow) . ':' . > Coordinate::stringFromColumnIndex(max($oCol) + 1) . max($oRow); > $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails($cellIntersect));$stack->push('Value', $cellIntersect, $cellRef);> }break; }< < // if the token is a unary operator, pop one value off the stack, do the operation, and push it back on} elseif (($token === '~') || ($token === '%')) {> // if the token is a unary operator, pop one value off the stack, do the operation, and push it back onif (($arg = $stack->pop()) === null) { return $this->raiseFormulaError('Internal error - Operand value missing from stack'); } $arg = $arg['value']; if ($token === '~') {< $this->debugLog->writeDebugLog('Evaluating Negation of ', $this->showValue($arg));> $this->debugLog->writeDebugLog('Evaluating Negation of %s', $this->showValue($arg));$multiplier = -1; } else {< $this->debugLog->writeDebugLog('Evaluating Percentile of ', $this->showValue($arg));> $this->debugLog->writeDebugLog('Evaluating Percentile of %s', $this->showValue($arg));$multiplier = 0.01; } if (is_array($arg)) {< self::checkMatrixOperands($arg, $multiplier, 2); < < try { < $matrix1 = new Shared\JAMA\Matrix($arg); < $matrixResult = $matrix1->arrayTimesEquals($multiplier); < $result = $matrixResult->getArray(); < } catch (\Exception $ex) { < $this->debugLog->writeDebugLog('JAMA Matrix Exception: ', $ex->getMessage()); < $result = '#VALUE!';> $operand2 = $multiplier; > $result = $arg; > [$rows, $columns] = self::checkMatrixOperands($result, $operand2, 0); > for ($row = 0; $row < $rows; ++$row) { > for ($column = 0; $column < $columns; ++$column) { > if (self::isNumericOrBool($result[$row][$column])) { > $result[$row][$column] *= $multiplier; > } else { > $result[$row][$column] = self::makeError($result[$row][$column]);}< $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result));> } > } > > $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails($result));$stack->push('Value', $result); if (isset($storeKey)) { $branchStore[$storeKey] = $result; } } else {< $this->executeNumericBinaryOperation($multiplier, $arg, '*', 'arrayTimesEquals', $stack);> $this->executeNumericBinaryOperation($multiplier, $arg, '*', $stack);}< } elseif (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $token, $matches)) {> } elseif (preg_match('/^' . self::CALCULATION_REGEXP_CELLREF . '$/i', $token ?? '', $matches)) {$cellRef = null;>if (isset($matches[8])) {< if ($pCell === null) {> if ($cell === null) {// We can't access the range, so return a REF error< $cellValue = Functions::REF();> $cellValue = Information\ExcelError::REF();} else { $cellRef = $matches[6] . $matches[7] . ':' . $matches[9] . $matches[10]; if ($matches[2] > '') { $matches[2] = trim($matches[2], "\"'"); if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) { // It's a Reference to an external spreadsheet (not currently supported) return $this->raiseFormulaError('Unable to access External Workbook'); } $matches[2] = trim($matches[2], "\"'");< $this->debugLog->writeDebugLog('Evaluating Cell Range ', $cellRef, ' in worksheet ', $matches[2]); < if ($pCellParent !== null) {> $this->debugLog->writeDebugLog('Evaluating Cell Range %s in worksheet %s', $cellRef, $matches[2]); > if ($pCellParent !== null && $this->spreadsheet !== null) {$cellValue = $this->extractCellRange($cellRef, $this->spreadsheet->getSheetByName($matches[2]), false); } else { return $this->raiseFormulaError('Unable to access Cell Reference'); }< $this->debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->showTypeDetails($cellValue));> $this->debugLog->writeDebugLog('Evaluation Result for cells %s in worksheet %s is %s', $cellRef, $matches[2], $this->showTypeDetails($cellValue));} else {< $this->debugLog->writeDebugLog('Evaluating Cell Range ', $cellRef, ' in current worksheet');> $this->debugLog->writeDebugLog('Evaluating Cell Range %s in current worksheet', $cellRef);if ($pCellParent !== null) { $cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, false); } else { return $this->raiseFormulaError('Unable to access Cell Reference'); }< $this->debugLog->writeDebugLog('Evaluation Result for cells ', $cellRef, ' is ', $this->showTypeDetails($cellValue));> $this->debugLog->writeDebugLog('Evaluation Result for cells %s is %s', $cellRef, $this->showTypeDetails($cellValue));} } } else {< if ($pCell === null) {> if ($cell === null) {// We can't access the cell, so return a REF error< $cellValue = Functions::REF();> $cellValue = Information\ExcelError::REF();} else { $cellRef = $matches[6] . $matches[7]; if ($matches[2] > '') { $matches[2] = trim($matches[2], "\"'"); if ((strpos($matches[2], '[') !== false) || (strpos($matches[2], ']') !== false)) { // It's a Reference to an external spreadsheet (not currently supported) return $this->raiseFormulaError('Unable to access External Workbook'); }< $this->debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in worksheet ', $matches[2]); < if ($pCellParent !== null) {> $this->debugLog->writeDebugLog('Evaluating Cell %s in worksheet %s', $cellRef, $matches[2]); > if ($pCellParent !== null && $this->spreadsheet !== null) {$cellSheet = $this->spreadsheet->getSheetByName($matches[2]); if ($cellSheet && $cellSheet->cellExists($cellRef)) { $cellValue = $this->extractCellRange($cellRef, $this->spreadsheet->getSheetByName($matches[2]), false);< $pCell->attach($pCellParent);> $cell->attach($pCellParent);} else {< $cellValue = null;> $cellRef = ($cellSheet !== null) ? "'{$matches[2]}'!{$cellRef}" : $cellRef; > $cellValue = ($cellSheet !== null) ? null : Information\ExcelError::REF();} } else { return $this->raiseFormulaError('Unable to access Cell Reference'); }< $this->debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' in worksheet ', $matches[2], ' is ', $this->showTypeDetails($cellValue));> $this->debugLog->writeDebugLog('Evaluation Result for cell %s in worksheet %s is %s', $cellRef, $matches[2], $this->showTypeDetails($cellValue));} else {< $this->debugLog->writeDebugLog('Evaluating Cell ', $cellRef, ' in current worksheet'); < if ($pCellParent->has($cellRef)) {> $this->debugLog->writeDebugLog('Evaluating Cell %s in current worksheet', $cellRef); > if ($pCellParent !== null && $pCellParent->has($cellRef)) {$cellValue = $this->extractCellRange($cellRef, $pCellWorksheet, false);< $pCell->attach($pCellParent);> $cell->attach($pCellParent);} else { $cellValue = null; }< $this->debugLog->writeDebugLog('Evaluation Result for cell ', $cellRef, ' is ', $this->showTypeDetails($cellValue));> $this->debugLog->writeDebugLog('Evaluation Result for cell %s is %s', $cellRef, $this->showTypeDetails($cellValue));} } }< $stack->push('Value', $cellValue, $cellRef);> > $stack->push('Cell Value', $cellValue, $cellRef);if (isset($storeKey)) { $branchStore[$storeKey] = $cellValue; }<> } elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/miu', $token ?? '', $matches)) {// if the token is a function, pop arguments off the stack, hand them to the function, and push the result back on< } elseif (preg_match('/^' . self::CALCULATION_REGEXP_FUNCTION . '$/i', $token, $matches)) { < if ($pCellParent) { < $pCell->attach($pCellParent); < } < if (($cellID == 'AC99') || (isset($pCell) && $pCell->getCoordinate() == 'AC99')) { < if (defined('RESOLVING')) { < define('RESOLVING2', true); < } else { < define('RESOLVING', true); < }> if ($cell !== null && $pCellParent !== null) { > $cell->attach($pCellParent);} $functionName = $matches[1]; $argCount = $stack->pop(); $argCount = $argCount['value'];< if ($functionName != 'MKMATRIX') { < $this->debugLog->writeDebugLog('Evaluating Function ', self::localeFunc($functionName), '() with ', (($argCount == 0) ? 'no' : $argCount), ' argument', (($argCount == 1) ? '' : 's'));> if ($functionName !== 'MKMATRIX') { > $this->debugLog->writeDebugLog('Evaluating Function %s() with %s argument%s', self::localeFunc($functionName), (($argCount == 0) ? 'no' : $argCount), (($argCount == 1) ? '' : 's'));} if ((isset(self::$phpSpreadsheetFunctions[$functionName])) || (isset(self::$controlFunctions[$functionName]))) { // function> $passByReference = false; if (isset(self::$phpSpreadsheetFunctions[$functionName])) { > $passCellReference = false; $functionCall = self::$phpSpreadsheetFunctions[$functionName]['functionCall']; > $functionCall = null;$passByReference = isset(self::$phpSpreadsheetFunctions[$functionName]['passByReference']); $passCellReference = isset(self::$phpSpreadsheetFunctions[$functionName]['passCellReference']); } elseif (isset(self::$controlFunctions[$functionName])) { $functionCall = self::$controlFunctions[$functionName]['functionCall']; $passByReference = isset(self::$controlFunctions[$functionName]['passByReference']); $passCellReference = isset(self::$controlFunctions[$functionName]['passCellReference']); }>// get the arguments for this function $args = $argArrayVals = [];> $emptyArguments = [];for ($i = 0; $i < $argCount; ++$i) { $arg = $stack->pop(); $a = $argCount - $i - 1;< if (($passByReference) &&> if ( > ($passByReference) &&(isset(self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a])) &&< (self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a])) {> (self::$phpSpreadsheetFunctions[$functionName]['passByReference'][$a]) > ) {if ($arg['reference'] === null) { $args[] = $cellID;< if ($functionName != 'MKMATRIX') {> if ($functionName !== 'MKMATRIX') {$argArrayVals[] = $this->showValue($cellID); } } else { $args[] = $arg['reference'];< if ($functionName != 'MKMATRIX') {> if ($functionName !== 'MKMATRIX') {$argArrayVals[] = $this->showValue($arg['reference']); } } } else {> $emptyArguments[] = ($arg['type'] === 'Empty Argument');$args[] = self::unwrapResult($arg['value']);< if ($functionName != 'MKMATRIX') {> if ($functionName !== 'MKMATRIX') {$argArrayVals[] = $this->showValue($arg['value']); } } } // Reverse the order of the arguments krsort($args);> krsort($emptyArguments); > if (($passByReference) && ($argCount == 0)) { > if ($argCount > 0) { $args[] = $cellID; > $args = $this->addDefaultArgumentValues($functionCall, $args, $emptyArguments); $argArrayVals[] = $this->showValue($cellID); > }}< if ($functionName != 'MKMATRIX') {> if ($functionName !== 'MKMATRIX') {if ($this->debugLog->getWriteDebugLog()) { krsort($argArrayVals);< $this->debugLog->writeDebugLog('Evaluating ', self::localeFunc($functionName), '( ', implode(self::$localeArgumentSeparator . ' ', Functions::flattenArray($argArrayVals)), ' )');> $this->debugLog->writeDebugLog('Evaluating %s ( %s )', self::localeFunc($functionName), implode(self::$localeArgumentSeparator . ' ', Functions::flattenArray($argArrayVals)));} } // Process the argument with the appropriate function call< $args = $this->addCellReference($args, $passCellReference, $functionCall, $pCell);> $args = $this->addCellReference($args, $passCellReference, $functionCall, $cell);if (!is_array($functionCall)) { foreach ($args as &$arg) { $arg = Functions::flattenSingleValue($arg); } unset($arg); } $result = call_user_func_array($functionCall, $args);< if ($functionName != 'MKMATRIX') { < $this->debugLog->writeDebugLog('Evaluation Result for ', self::localeFunc($functionName), '() function call is ', $this->showTypeDetails($result));> if ($functionName !== 'MKMATRIX') { > $this->debugLog->writeDebugLog('Evaluation Result for %s() function call is %s', self::localeFunc($functionName), $this->showTypeDetails($result));} $stack->push('Value', self::wrapResult($result)); if (isset($storeKey)) { $branchStore[$storeKey] = $result; } } } else { // if the token is a number, boolean, string or an Excel error, push it onto the stack< if (isset(self::$excelConstants[strtoupper($token)])) {> if (isset(self::$excelConstants[strtoupper($token ?? '')])) {$excelConstant = strtoupper($token); $stack->push('Constant Value', self::$excelConstants[$excelConstant]); if (isset($storeKey)) { $branchStore[$storeKey] = self::$excelConstants[$excelConstant]; }< $this->debugLog->writeDebugLog('Evaluating Constant ', $excelConstant, ' as ', $this->showTypeDetails(self::$excelConstants[$excelConstant])); < } elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token[0] == '"') || ($token[0] == '#')) { < $stack->push('Value', $token);> $this->debugLog->writeDebugLog('Evaluating Constant %s as %s', $excelConstant, $this->showTypeDetails(self::$excelConstants[$excelConstant])); > } elseif ((is_numeric($token)) || ($token === null) || (is_bool($token)) || ($token == '') || ($token[0] == self::FORMULA_STRING_QUOTE) || ($token[0] == '#')) { > $stack->push($tokenData['type'], $token, $tokenData['reference']);if (isset($storeKey)) { $branchStore[$storeKey] = $token; }< // if the token is a named range, push the named range name onto the stack < } elseif (preg_match('/^' . self::CALCULATION_REGEXP_NAMEDRANGE . '$/i', $token, $matches)) { < $namedRange = $matches[6]; < $this->debugLog->writeDebugLog('Evaluating Named Range ', $namedRange); < < $cellValue = $this->extractNamedRange($namedRange, ((null !== $pCell) ? $pCellWorksheet : null), false); < $pCell->attach($pCellParent); < $this->debugLog->writeDebugLog('Evaluation Result for named range ', $namedRange, ' is ', $this->showTypeDetails($cellValue)); < $stack->push('Named Range', $cellValue, $namedRange);> } elseif (preg_match('/^' . self::CALCULATION_REGEXP_DEFINEDNAME . '$/miu', $token, $matches)) { > // if the token is a named range or formula, evaluate it and push the result onto the stack > $definedName = $matches[6]; > if ($cell === null || $pCellWorksheet === null) { > return $this->raiseFormulaError("undefined name '$token'"); > } > > $this->debugLog->writeDebugLog('Evaluating Defined Name %s', $definedName); > $namedRange = DefinedName::resolveName($definedName, $pCellWorksheet); > if ($namedRange === null) { > return $this->raiseFormulaError("undefined name '$definedName'"); > } > > $result = $this->evaluateDefinedName($cell, $namedRange, $pCellWorksheet, $stack);if (isset($storeKey)) {< $branchStore[$storeKey] = $cellValue;> $branchStore[$storeKey] = $result;} } else {< return $this->raiseFormulaError("undefined variable '$token'");> return $this->raiseFormulaError("undefined name '$token'");} } } // when we're out of tokens, the stack should have a single element, the final result if ($stack->count() != 1) { return $this->raiseFormulaError('internal error'); } $output = $stack->pop(); $output = $output['value']; return $output; }> /** private function validateBinaryOperand(&$operand, &$stack) > * @param mixed $operand { > * @param mixed $stack if (is_array($operand)) { > * if ((count($operand, COUNT_RECURSIVE) - count($operand)) == 1) { > * @return bool do { > */$operand = array_pop($operand); } while (is_array($operand)); } } // Numbers, matrices and booleans can pass straight through, as they're already valid if (is_string($operand)) { // We only need special validations for the operand if it is a string // Start by stripping off the quotation marks we use to identify true excel string values internally< if ($operand > '' && $operand[0] == '"') {> if ($operand > '' && $operand[0] == self::FORMULA_STRING_QUOTE) {$operand = self::unwrapResult($operand); } // If the string is a numeric value, we treat it as a numeric, so no further testing if (!is_numeric($operand)) { // If not a numeric, test to see if the value is an Excel error, and so can't be used in normal binary operations if ($operand > '' && $operand[0] == '#') { $stack->push('Value', $operand);< $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($operand));> $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails($operand));return false;< } elseif (!Shared\StringHelper::convertToNumberIfFraction($operand)) { < // If not a numeric or a fraction, then it's a text string, and so can't be used in mathematical binary operations < $stack->push('Value', '#VALUE!'); < $this->debugLog->writeDebugLog('Evaluation Result is a ', $this->showTypeDetails('#VALUE!'));> } elseif (Engine\FormattedNumber::convertToNumberIfFormatted($operand) === false) { > // If not a numeric, a fraction or a percentage, then it's a text string, and so can't be used in mathematical binary operations > $stack->push('Error', '#VALUE!'); > $this->debugLog->writeDebugLog('Evaluation Result is a %s', $this->showTypeDetails('#VALUE!'));return false; } } }< // return a true if the value of the operand is one that we can use in normal binary operations> // return a true if the value of the operand is one that we can use in normal binary mathematical operationsreturn true; } /**< * @param null|string $cellID* @param mixed $operand1 * @param mixed $operand2 * @param string $operation< * @param Stack $stack < * @param bool $recursingArrays*< * @return mixed> * @return array*/< private function executeBinaryComparisonOperation($cellID, $operand1, $operand2, $operation, Stack &$stack, $recursingArrays = false)> private function executeArrayComparison($operand1, $operand2, $operation, Stack &$stack, bool $recursingArrays){< // If we're dealing with matrix operations, we want a matrix result < if ((is_array($operand1)) || (is_array($operand2))) {$result = [];< if ((is_array($operand1)) && (!is_array($operand2))) {> if (!is_array($operand2)) { > // Operand 1 is an array, Operand 2 is a scalarforeach ($operand1 as $x => $operandData) {< $this->debugLog->writeDebugLog('Evaluating Comparison ', $this->showValue($operandData), ' ', $operation, ' ', $this->showValue($operand2)); < $this->executeBinaryComparisonOperation($cellID, $operandData, $operand2, $operation, $stack);> $this->debugLog->writeDebugLog('Evaluating Comparison %s %s %s', $this->showValue($operandData), $operation, $this->showValue($operand2)); > $this->executeBinaryComparisonOperation($operandData, $operand2, $operation, $stack);$r = $stack->pop(); $result[$x] = $r['value']; }< } elseif ((!is_array($operand1)) && (is_array($operand2))) {> } elseif (!is_array($operand1)) { > // Operand 1 is a scalar, Operand 2 is an arrayforeach ($operand2 as $x => $operandData) {< $this->debugLog->writeDebugLog('Evaluating Comparison ', $this->showValue($operand1), ' ', $operation, ' ', $this->showValue($operandData)); < $this->executeBinaryComparisonOperation($cellID, $operand1, $operandData, $operation, $stack);> $this->debugLog->writeDebugLog('Evaluating Comparison %s %s %s', $this->showValue($operand1), $operation, $this->showValue($operandData)); > $this->executeBinaryComparisonOperation($operand1, $operandData, $operation, $stack);$r = $stack->pop(); $result[$x] = $r['value']; } } else {> // Operand 1 and Operand 2 are both arraysif (!$recursingArrays) { self::checkMatrixOperands($operand1, $operand2, 2); } foreach ($operand1 as $x => $operandData) {< $this->debugLog->writeDebugLog('Evaluating Comparison ', $this->showValue($operandData), ' ', $operation, ' ', $this->showValue($operand2[$x])); < $this->executeBinaryComparisonOperation($cellID, $operandData, $operand2[$x], $operation, $stack, true);> $this->debugLog->writeDebugLog('Evaluating Comparison %s %s %s', $this->showValue($operandData), $operation, $this->showValue($operand2[$x])); > $this->executeBinaryComparisonOperation($operandData, $operand2[$x], $operation, $stack, true);$r = $stack->pop(); $result[$x] = $r['value']; } } // Log the result details< $this->debugLog->writeDebugLog('Comparison Evaluation Result is ', $this->showTypeDetails($result));> $this->debugLog->writeDebugLog('Comparison Evaluation Result is %s', $this->showTypeDetails($result));// And push the result onto the stack $stack->push('Array', $result); return $result; }< // Simple validate the two operands if they are string values < if (is_string($operand1) && $operand1 > '' && $operand1[0] == '"') { < $operand1 = self::unwrapResult($operand1);> /** > * @param mixed $operand1 > * @param mixed $operand2 > * @param string $operation > * @param bool $recursingArrays > * > * @return mixed > */ > private function executeBinaryComparisonOperation($operand1, $operand2, $operation, Stack &$stack, $recursingArrays = false) > { > // If we're dealing with matrix operations, we want a matrix result > if ((is_array($operand1)) || (is_array($operand2))) { > return $this->executeArrayComparison($operand1, $operand2, $operation, $stack, $recursingArrays);}< if (is_string($operand2) && $operand2 > '' && $operand2[0] == '"') { < $operand2 = self::unwrapResult($operand2);> > $result = BinaryComparison::compare($operand1, $operand2, $operation); > > // Log the result details > $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails($result)); > // And push the result onto the stack > $stack->push('Value', $result); > > return $result;}< // Use case insensitive comparaison if not OpenOffice mode < if (Functions::getCompatibilityMode() != Functions::COMPATIBILITY_OPENOFFICE) { < if (is_string($operand1)) { < $operand1 = strtoupper($operand1);> /** > * @param mixed $operand1 > * @param mixed $operand2 > * @param string $operation > * @param Stack $stack > * > * @return bool|mixed > */ > private function executeNumericBinaryOperation($operand1, $operand2, $operation, &$stack) > { > // Validate the two operands > if ( > ($this->validateBinaryOperand($operand1, $stack) === false) || > ($this->validateBinaryOperand($operand2, $stack) === false) > ) { > return false; > } > > if ( > (Functions::getCompatibilityMode() != Functions::COMPATIBILITY_OPENOFFICE) && > ((is_string($operand1) && !is_numeric($operand1) && strlen($operand1) > 0) || > (is_string($operand2) && !is_numeric($operand2) && strlen($operand2) > 0)) > ) { > $result = Information\ExcelError::VALUE(); > } elseif (is_array($operand1) || is_array($operand2)) { > // Ensure that both operands are arrays/matrices > if (is_array($operand1)) { > foreach ($operand1 as $key => $value) { > $operand1[$key] = Functions::flattenArray($value);}< if (is_string($operand2)) { < $operand2 = strtoupper($operand2);}> if (is_array($operand2)) { } > foreach ($operand2 as $key => $value) { > $operand2[$key] = Functions::flattenArray($value);$useLowercaseFirstComparison = is_string($operand1) && is_string($operand2) && Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE;> } > [$rows, $columns] = self::checkMatrixOperands($operand1, $operand2, 2);< $useLowercaseFirstComparison = is_string($operand1) && is_string($operand2) && Functions::getCompatibilityMode() == Functions::COMPATIBILITY_OPENOFFICE;> for ($row = 0; $row < $rows; ++$row) { > for ($column = 0; $column < $columns; ++$column) { > if ($operand1[$row][$column] === null) { > $operand1[$row][$column] = 0; > } elseif (!self::isNumericOrBool($operand1[$row][$column])) { > $operand1[$row][$column] = self::makeError($operand1[$row][$column]);< // execute the necessary operation < switch ($operation) { < // Greater than < case '>': < if ($useLowercaseFirstComparison) { < $result = $this->strcmpLowercaseFirst($operand1, $operand2) > 0; < } else { < $result = ($operand1 > $operand2);> continue;> if ($operand2[$row][$column] === null) { break; > $operand2[$row][$column] = 0; // Less than > } elseif (!self::isNumericOrBool($operand2[$row][$column])) { case '<': > $operand1[$row][$column] = self::makeError($operand2[$row][$column]);< break; < // Less than < case '<': < if ($useLowercaseFirstComparison) { < $result = $this->strcmpLowercaseFirst($operand1, $operand2) < 0; < } else { < $result = ($operand1 < $operand2);> continue;// Equality> switch ($operation) { case '=': > case '+': if (is_numeric($operand1) && is_numeric($operand2)) { > $operand1[$row][$column] += $operand2[$row][$column];< // Equality < case '=': < if (is_numeric($operand1) && is_numeric($operand2)) { < $result = (abs($operand1 - $operand2) < $this->delta); < } else { < $result = strcmp($operand1, $operand2) == 0; < }> case '-': > $operand1[$row][$column] -= $operand2[$row][$column];< // Greater than or equal < case '>=': < if (is_numeric($operand1) && is_numeric($operand2)) { < $result = ((abs($operand1 - $operand2) < $this->delta) || ($operand1 > $operand2)); < } elseif ($useLowercaseFirstComparison) { < $result = $this->strcmpLowercaseFirst($operand1, $operand2) >= 0; < } else { < $result = strcmp($operand1, $operand2) >= 0; < }> case '*': > $operand1[$row][$column] *= $operand2[$row][$column];break;< // Less than or equal < case '<=': < if (is_numeric($operand1) && is_numeric($operand2)) { < $result = ((abs($operand1 - $operand2) < $this->delta) || ($operand1 < $operand2)); < } elseif ($useLowercaseFirstComparison) { < $result = $this->strcmpLowercaseFirst($operand1, $operand2) <= 0;> case '/': > if ($operand2[$row][$column] == 0) { > $operand1[$row][$column] = Information\ExcelError::DIV0();} else {< $result = strcmp($operand1, $operand2) <= 0;> $operand1[$row][$column] /= $operand2[$row][$column];} break;< // Inequality < case '<>': < if (is_numeric($operand1) && is_numeric($operand2)) { < $result = (abs($operand1 - $operand2) > 1E-14); < } else { < $result = strcmp($operand1, $operand2) != 0; < }> case '^': > $operand1[$row][$column] = $operand1[$row][$column] ** $operand2[$row][$column];break;< } < < // Log the result details < $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result)); < // And push the result onto the stack < $stack->push('Value', $result);< return $result;> default: > throw new Exception('Unsupported numeric binary operation');}< < /** < * Compare two strings in the same way as strcmp() except that lowercase come before uppercase letters. < * < * @param string $str1 First string value for the comparison < * @param string $str2 Second string value for the comparison < * < * @return int < */ < private function strcmpLowercaseFirst($str1, $str2) < { < $inversedStr1 = Shared\StringHelper::strCaseReverse($str1); < $inversedStr2 = Shared\StringHelper::strCaseReverse($str2); < < return strcmp($inversedStr1, $inversedStr2); < } < < /** < * @param mixed $operand1 < * @param mixed $operand2 < * @param mixed $operation < * @param string $matrixFunction < * @param mixed $stack < * < * @return bool|mixed < */ < private function executeNumericBinaryOperation($operand1, $operand2, $operation, $matrixFunction, &$stack) < { < // Validate the two operands < if (!$this->validateBinaryOperand($operand1, $stack)) { < return false;}< if (!$this->validateBinaryOperand($operand2, $stack)) { < return false;}< < // If either of the operands is a matrix, we need to treat them both as matrices < // (converting the other operand to a matrix if need be); then perform the required < // matrix operation < if ((is_array($operand1)) || (is_array($operand2))) { < // Ensure that both operands are arrays/matrices of the same size < self::checkMatrixOperands($operand1, $operand2, 2); < < try { < // Convert operand 1 from a PHP array to a matrix < $matrix = new Shared\JAMA\Matrix($operand1); < // Perform the required operation against the operand 1 matrix, passing in operand 2 < $matrixResult = $matrix->$matrixFunction($operand2); < $result = $matrixResult->getArray(); < } catch (\Exception $ex) { < $this->debugLog->writeDebugLog('JAMA Matrix Exception: ', $ex->getMessage()); < $result = '#VALUE!'; < } < } else { < if ((Functions::getCompatibilityMode() != Functions::COMPATIBILITY_OPENOFFICE) && < ((is_string($operand1) && !is_numeric($operand1) && strlen($operand1) > 0) || < (is_string($operand2) && !is_numeric($operand2) && strlen($operand2) > 0))) { < $result = Functions::VALUE();> $result = $operand1;} else { // If we're dealing with non-matrix operations, execute the necessary operation switch ($operation) { // Addition case '+': $result = $operand1 + $operand2; break; // Subtraction case '-': $result = $operand1 - $operand2; break; // Multiplication case '*': $result = $operand1 * $operand2; break; // Division case '/': if ($operand2 == 0) { // Trap for Divide by Zero error< $stack->push('Value', '#DIV/0!'); < $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails('#DIV/0!'));> $stack->push('Error', Information\ExcelError::DIV0()); > $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails(Information\ExcelError::DIV0()));return false; } $result = $operand1 / $operand2; break; // Power case '^':< $result = pow($operand1, $operand2);> $result = $operand1 ** $operand2;break;< }> > default: > throw new Exception('Unsupported numeric binary operation');} } // Log the result details< $this->debugLog->writeDebugLog('Evaluation Result is ', $this->showTypeDetails($result));> $this->debugLog->writeDebugLog('Evaluation Result is %s', $this->showTypeDetails($result));// And push the result onto the stack $stack->push('Value', $result); return $result; }< // trigger an error, but nicely, if need be < protected function raiseFormulaError($errorMessage)> /** > * Trigger an error, but nicely, if need be. > * > * @return false > */ > protected function raiseFormulaError(string $errorMessage, int $code = 0, ?Throwable $exception = null){ $this->formulaError = $errorMessage; $this->cyclicReferenceStack->clear();< if (!$this->suppressFormulaErrors) { < throw new Exception($errorMessage);> $suppress = /** @scrutinizer ignore-deprecated */ $this->suppressFormulaErrors ?? $this->suppressFormulaErrorsNew; > if (!$suppress) { > throw new Exception($errorMessage, $code, $exception);}< trigger_error($errorMessage, E_USER_ERROR);return false; } /** * Extract range values. *< * @param string &$pRange String based range representation < * @param Worksheet $pSheet Worksheet> * @param string $range String based range representation > * @param Worksheet $worksheet Worksheet* @param bool $resetLog Flag indicating whether calculation log should be reset or not * * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. */< public function extractCellRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true)> public function extractCellRange(&$range = 'A1', ?Worksheet $worksheet = null, $resetLog = true){ // Return value $returnValue = [];< if ($pSheet !== null) { < $pSheetName = $pSheet->getTitle(); < if (strpos($pRange, '!') !== false) { < [$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true); < $pSheet = $this->spreadsheet->getSheetByName($pSheetName);> if ($worksheet !== null) { > $worksheetName = $worksheet->getTitle(); > > if (strpos($range, '!') !== false) { > [$worksheetName, $range] = Worksheet::extractSheetTitle($range, true); > $worksheet = ($this->spreadsheet === null) ? null : $this->spreadsheet->getSheetByName($worksheetName);} // Extract range< $aReferences = Coordinate::extractAllCellReferencesInRange($pRange); < $pRange = $pSheetName . '!' . $pRange; < if (!isset($aReferences[1])) {> $aReferences = Coordinate::extractAllCellReferencesInRange($range); > $range = "'" . $worksheetName . "'" . '!' . $range;$currentCol = ''; $currentRow = 0;> if (!isset($aReferences[1])) {// Single cell in range sscanf($aReferences[0], '%[A-Z]%d', $currentCol, $currentRow);< if ($pSheet->cellExists($aReferences[0])) { < $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);> if ($worksheet !== null && $worksheet->cellExists($aReferences[0])) { > $returnValue[$currentRow][$currentCol] = $worksheet->getCell($aReferences[0])->getCalculatedValue($resetLog);} else { $returnValue[$currentRow][$currentCol] = null; } } else { // Extract cell data for all cells in the range foreach ($aReferences as $reference) {< $currentCol = ''; < $currentRow = 0;// Extract range sscanf($reference, '%[A-Z]%d', $currentCol, $currentRow);< if ($pSheet->cellExists($reference)) { < $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);> if ($worksheet !== null && $worksheet->cellExists($reference)) { > $returnValue[$currentRow][$currentCol] = $worksheet->getCell($reference)->getCalculatedValue($resetLog);} else { $returnValue[$currentRow][$currentCol] = null; } } } } return $returnValue; } /** * Extract range values. *< * @param string &$pRange String based range representation < * @param Worksheet $pSheet Worksheet> * @param string $range String based range representation > * @param null|Worksheet $worksheet Worksheet* @param bool $resetLog Flag indicating whether calculation log should be reset or not * * @return mixed Array of values in range if range contains more than one element. Otherwise, a single value is returned. */< public function extractNamedRange(&$pRange = 'A1', Worksheet $pSheet = null, $resetLog = true)> public function extractNamedRange(string &$range = 'A1', ?Worksheet $worksheet = null, $resetLog = true){ // Return value $returnValue = [];< if ($pSheet !== null) { < $pSheetName = $pSheet->getTitle(); < if (strpos($pRange, '!') !== false) { < [$pSheetName, $pRange] = Worksheet::extractSheetTitle($pRange, true); < $pSheet = $this->spreadsheet->getSheetByName($pSheetName);> if ($worksheet !== null) { > if (strpos($range, '!') !== false) { > [$worksheetName, $range] = Worksheet::extractSheetTitle($range, true); > $worksheet = ($this->spreadsheet === null) ? null : $this->spreadsheet->getSheetByName($worksheetName);} // Named range?< $namedRange = NamedRange::resolveRange($pRange, $pSheet); < if ($namedRange !== null) { < $pSheet = $namedRange->getWorksheet(); < $pRange = $namedRange->getRange(); < $splitRange = Coordinate::splitRange($pRange); < // Convert row and column references < if (ctype_alpha($splitRange[0][0])) { < $pRange = $splitRange[0][0] . '1:' . $splitRange[0][1] . $namedRange->getWorksheet()->getHighestRow(); < } elseif (ctype_digit($splitRange[0][0])) { < $pRange = 'A' . $splitRange[0][0] . ':' . $namedRange->getWorksheet()->getHighestColumn() . $splitRange[0][1];> $namedRange = ($worksheet === null) ? null : DefinedName::resolveName($range, $worksheet); > if ($namedRange === null) { > return Information\ExcelError::REF();}< } else { < return Functions::REF();> > $worksheet = $namedRange->getWorksheet(); > $range = $namedRange->getValue(); > $splitRange = Coordinate::splitRange($range); > // Convert row and column references > if ($worksheet !== null && ctype_alpha($splitRange[0][0])) { > $range = $splitRange[0][0] . '1:' . $splitRange[0][1] . $worksheet->getHighestRow(); > } elseif ($worksheet !== null && ctype_digit($splitRange[0][0])) { > $range = 'A' . $splitRange[0][0] . ':' . $worksheet->getHighestColumn() . $splitRange[0][1];} // Extract range< $aReferences = Coordinate::extractAllCellReferencesInRange($pRange);> $aReferences = Coordinate::extractAllCellReferencesInRange($range);if (!isset($aReferences[1])) { // Single cell (or single column or row) in range [$currentCol, $currentRow] = Coordinate::coordinateFromString($aReferences[0]);< if ($pSheet->cellExists($aReferences[0])) { < $returnValue[$currentRow][$currentCol] = $pSheet->getCell($aReferences[0])->getCalculatedValue($resetLog);> if ($worksheet !== null && $worksheet->cellExists($aReferences[0])) { > $returnValue[$currentRow][$currentCol] = $worksheet->getCell($aReferences[0])->getCalculatedValue($resetLog);} else { $returnValue[$currentRow][$currentCol] = null; } } else { // Extract cell data for all cells in the range foreach ($aReferences as $reference) { // Extract range [$currentCol, $currentRow] = Coordinate::coordinateFromString($reference);< if ($pSheet->cellExists($reference)) { < $returnValue[$currentRow][$currentCol] = $pSheet->getCell($reference)->getCalculatedValue($resetLog);> if ($worksheet !== null && $worksheet->cellExists($reference)) { > $returnValue[$currentRow][$currentCol] = $worksheet->getCell($reference)->getCalculatedValue($resetLog);} else { $returnValue[$currentRow][$currentCol] = null; } } } } return $returnValue; } /** * Is a specific function implemented? *< * @param string $pFunction Function Name> * @param string $function Function Name* * @return bool */< public function isImplemented($pFunction)> public function isImplemented($function){< $pFunction = strtoupper($pFunction); < $notImplemented = !isset(self::$phpSpreadsheetFunctions[$pFunction]) || (is_array(self::$phpSpreadsheetFunctions[$pFunction]['functionCall']) && self::$phpSpreadsheetFunctions[$pFunction]['functionCall'][1] === 'DUMMY');> $function = strtoupper($function); > $notImplemented = !isset(self::$phpSpreadsheetFunctions[$function]) || (is_array(self::$phpSpreadsheetFunctions[$function]['functionCall']) && self::$phpSpreadsheetFunctions[$function]['functionCall'][1] === 'DUMMY');return !$notImplemented; } /** * Get a list of all implemented functions as an array of function objects.< * < * @return array of Category*/< public function getFunctions()> public static function getFunctions(): array{ return self::$phpSpreadsheetFunctions; } /** * Get a list of implemented Excel function names. * * @return array */ public function getImplementedFunctionNames() { $returnValue = []; foreach (self::$phpSpreadsheetFunctions as $functionName => $function) { if ($this->isImplemented($functionName)) { $returnValue[] = $functionName; } } return $returnValue; }> private function addDefaultArgumentValues(array $functionCall, array $args, array $emptyArguments): array /** > { * Add cell reference if needed while making sure that it is the last argument. > $reflector = new ReflectionMethod(implode('::', $functionCall)); * > $methodArguments = $reflector->getParameters(); * @param array $args > * @param bool $passCellReference > if (count($methodArguments) > 0) { * @param array|string $functionCall > // Apply any defaults for empty argument values * @param null|Cell $pCell > foreach ($emptyArguments as $argumentId => $isArgumentEmpty) { * > if ($isArgumentEmpty === true) { * @return array > $reflectedArgumentId = count($args) - (int) $argumentId - 1; */ > if ( private function addCellReference(array $args, $passCellReference, $functionCall, Cell $pCell = null) > !array_key_exists($reflectedArgumentId, $methodArguments) || { > $methodArguments[$reflectedArgumentId]->isVariadic() if ($passCellReference) { > ) { if (is_array($functionCall)) { > break; $className = $functionCall[0]; > } $methodName = $functionCall[1]; > > $args[$argumentId] = $this->getArgumentDefaultValue($methodArguments[$reflectedArgumentId]); $reflectionMethod = new \ReflectionMethod($className, $methodName); > } $argumentCount = count($reflectionMethod->getParameters()); > } while (count($args) < $argumentCount - 1) { > } $args[] = null; > } > return $args; } > } > $args[] = $pCell; > /** } > * @return null|mixed > */ return $args; > private function getArgumentDefaultValue(ReflectionParameter $methodArgument) } > { > $defaultValue = null; private function getUnusedBranchStoreKey() > { > if ($methodArgument->isDefaultValueAvailable()) { $storeKeyValue = 'storeKey-' . $this->branchStoreKeyCounter; > $defaultValue = $methodArgument->getDefaultValue(); ++$this->branchStoreKeyCounter; > if ($methodArgument->isDefaultValueConstant()) { > $constantName = $methodArgument->getDefaultValueConstantName() ?? ''; return $storeKeyValue; > // read constant value } > if (strpos($constantName, '::') !== false) { > [$className, $constantName] = explode('::', $constantName); private function getTokensAsString($tokens) > $constantReflector = new ReflectionClassConstant($className, $constantName); { > $tokensStr = array_map(function ($token) { > return $constantReflector->getValue(); $value = $token['value'] ?? 'no value'; > } while (is_array($value)) { > $value = array_pop($value); > return constant($constantName); } > } > } return $value; > }, $tokens); > return $defaultValue; > } return '[ ' . implode(' | ', $tokensStr) . ' ]'; >< * @param array $args< * @param null|Cell $pCell< private function addCellReference(array $args, $passCellReference, $functionCall, Cell $pCell = null)> private function addCellReference(array $args, $passCellReference, $functionCall, ?Cell $cell = null)< $reflectionMethod = new \ReflectionMethod($className, $methodName);> $reflectionMethod = new ReflectionMethod($className, $methodName);< $args[] = $pCell;> $args[] = $cell;< private function getUnusedBranchStoreKey()> /** > * @return mixed|string > */ > private function evaluateDefinedName(Cell $cell, DefinedName $namedRange, Worksheet $cellWorksheet, Stack $stack) > { > $definedNameScope = $namedRange->getScope(); > if ($definedNameScope !== null && $definedNameScope !== $cellWorksheet) { > // The defined name isn't in our current scope, so #REF > $result = Information\ExcelError::REF(); > $stack->push('Error', $result, $namedRange->getName()); > > return $result; > } > > $definedNameValue = $namedRange->getValue(); > $definedNameType = $namedRange->isFormula() ? 'Formula' : 'Range'; > $definedNameWorksheet = $namedRange->getWorksheet(); > > if ($definedNameValue[0] !== '=') { > $definedNameValue = '=' . $definedNameValue; > } > > $this->debugLog->writeDebugLog('Defined Name is a %s with a value of %s', $definedNameType, $definedNameValue); > > $recursiveCalculationCell = ($definedNameWorksheet !== null && $definedNameWorksheet !== $cellWorksheet) > ? $definedNameWorksheet->getCell('A1') > : $cell; > $recursiveCalculationCellAddress = $recursiveCalculationCell->getCoordinate(); > > // Adjust relative references in ranges and formulae so that we execute the calculation for the correct rows and columns > $definedNameValue = self::$referenceHelper->updateFormulaReferencesAnyWorksheet( > $definedNameValue, > Coordinate::columnIndexFromString($cell->getColumn()) - 1, > $cell->getRow() - 1 > ); > > $this->debugLog->writeDebugLog('Value adjusted for relative references is %s', $definedNameValue); > > $recursiveCalculator = new self($this->spreadsheet); > $recursiveCalculator->getDebugLog()->setWriteDebugLog($this->getDebugLog()->getWriteDebugLog()); > $recursiveCalculator->getDebugLog()->setEchoDebugLog($this->getDebugLog()->getEchoDebugLog()); > $result = $recursiveCalculator->_calculateFormulaValue($definedNameValue, $recursiveCalculationCellAddress, $recursiveCalculationCell, true); > > if ($this->getDebugLog()->getWriteDebugLog()) { > $this->debugLog->mergeDebugLog(array_slice($recursiveCalculator->getDebugLog()->getLog(), 3)); > $this->debugLog->writeDebugLog('Evaluation Result for Named %s %s is %s', $definedNameType, $namedRange->getName(), $this->showTypeDetails($result)); > } > > $stack->push('Defined Name', $result, $namedRange->getName()); > > return $result; > } > > public function setSuppressFormulaErrors(bool $suppressFormulaErrors): void< $storeKeyValue = 'storeKey-' . $this->branchStoreKeyCounter; < ++$this->branchStoreKeyCounter;> $this->suppressFormulaErrorsNew = $suppressFormulaErrors; > }< return $storeKeyValue;> public function getSuppressFormulaErrors(): bool > { > return $this->suppressFormulaErrorsNew;< private function getTokensAsString($tokens)> /** @param mixed $arg */ > private static function doNothing($arg): bool< $tokensStr = array_map(function ($token) { < $value = $token['value'] ?? 'no value'; < while (is_array($value)) { < $value = array_pop($value);> return (bool) $arg;< return $value; < }, $tokens);> /** > * @param mixed $operand1 > * > * @return mixed > */ > private static function boolToString($operand1) > { > if (is_bool($operand1)) { > $operand1 = ($operand1) ? self::$localeBoolean['TRUE'] : self::$localeBoolean['FALSE']; > } elseif ($operand1 === null) { > $operand1 = ''; > } > > return $operand1; > }< return '[ ' . implode(' | ', $tokensStr) . ' ]';> /** @param mixed $operand */ > private static function isNumericOrBool($operand): bool > { > return is_numeric($operand) || is_bool($operand); > } > > /** @param mixed $operand */ > private static function makeError($operand = ''): string > { > return Information\ErrorValue::isError($operand) ? $operand : Information\ExcelError::VALUE();