{"record":{"id":"bf3b7b70751bcd10","repo":"PHPOffice/PhpSpreadsheet","slug":"invalid-operator-for-cell-value-cf-rule-wizard","errorCode":null,"errorMessage":"Invalid Operator for Cell Value CF Rule Wizard","messagePattern":"Invalid Operator for Cell Value CF Rule Wizard","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php","lineNumber":173,"sourceCode":"    }\n\n    /**\n     * @param mixed[] $arguments\n     */\n    public function __call(string $methodName, array $arguments): self\n    {\n        if ($methodName === 'and') {\n            if (!isset(self::RANGE_OPERATORS[$this->operator])) {\n                throw new Exception('AND Value is only appropriate for range operators');\n            }\n\n            $this->operand(1, ...$arguments);\n\n            return $this;\n        }\n\n        if (!isset(self::MAGIC_OPERATIONS[$methodName])) {\n            throw new Exception('Invalid Operator for Cell Value CF Rule Wizard');\n        }\n\n        $this->operator(self::MAGIC_OPERATIONS[$methodName]);\n        //$this->operand(0, ...$arguments);\n        if (count($arguments) < 2) {\n            $this->operand(0, $arguments[0]);\n        } else {\n            /** @var string */\n            $arg1 = $arguments[1];\n            $this->operand(0, $arguments[0], $arg1);\n        }\n\n        return $this;\n    }\n\n    /** @internal */\n    public static function compareKeys(): bool\n    {","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php#L155-L191","documentation":"CellValue exposes its comparison operators through __call against a MAGIC_OPERATIONS map containing exactly: equals, notEquals, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, between, notBetween (plus the special-cased and). Any other method name throws - the most common case being a typo such as greaterThen, or a method that belongs to a different wizard (contains, today, isBlank) invoked on a CellValue instance.","triggerScenarios":"->greaterThen(5) (typo); guessed names like ->above(5) or ->below(5); pasting operator chains from TextValue or DateValue wizards onto a CellValue rule; dynamic method names from configuration.","commonSituations":"IDE autocompletion across similar wizard classes; refactoring a rule from one wizard type to another without updating the operator calls; building fluent chains from user input.","solutions":["Use exactly the documented operators: equals, notEquals, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, between, notBetween","Check dynamic method names against that list before invoking","Rely on the @method docblock annotations for autocompletion instead of guessing names","Catch PhpSpreadsheetException around dynamic fluent calls"],"exampleFix":"// before\n$wizard = (new Wizard('A1:E10'))->newRule(Wizard::CELL_VALUE);\n$wizard->greaterThen(100);   // typo: throws Invalid Operator\n\n// after\n$wizard->greaterThan(100);","handlingStrategy":"validation","validationCode":"$allowed = ['equals', 'notEquals', 'greaterThan', 'greaterThanOrEqual',\n    'lessThan', 'lessThanOrEqual', 'between', 'notBetween', 'and'];\n$method = $config['operator'];\nif (!in_array($method, $allowed, true)) {\n    throw new InvalidArgumentException('Unknown CellValue operator: ' . $method);\n}\n$wizard->$method($value);","typeGuard":null,"tryCatchPattern":"use PhpOffice\\PhpSpreadsheet\\Exception as PhpSpreadsheetException;\n\ntry {\n    $wizard->greaterThan($value);\n} catch (PhpSpreadsheetException $e) {\n    throw new InvalidArgumentException('Invalid CellValue operator call', 0, $e);\n}","preventionTips":["Use exactly: equals, notEquals, greaterThan, greaterThanOrEqual, lessThan, lessThanOrEqual, between, notBetween","Beware the greaterThen typo - it is the most common trigger","Use IDE autocompletion from the @method annotations rather than guessing","Whitelist operator names when they come from config or user input"],"tags":["php","phpspreadsheet","conditional-formatting","wizard","cell-value","magic-methods","typo"],"backgroundTag":"invalid-fluent-builder-method","analyzedSha":"65b080eef4d9fd11a5796135ab145883e5c3d6a6","analyzedAt":"2026-08-17T05:40:41.646Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}