← All changes
|
libraries/vendor/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php
+19
-6
3.3.1
→
3.4
View file →
| @@ -53,9 +53,10 @@ | ||
| 53 | 53 | |
| 54 | 54 | protected function operator(string $operator): void |
| 55 | 55 | { |
| 56 | 56 | if ((!isset(self::SINGLE_OPERATORS[$operator])) && (!isset(self::RANGE_OPERATORS[$operator]))) { |
| 57 | - throw new Exception('Invalid Operator for Cell Value CF Rule Wizard'); | |
| 57 | + // should not happen - compareKeys confirms | |
| 58 | + throw new Exception('Invalid Operator for Cell Value CF Rule Wizard 1'); // @codeCoverageIgnore | |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | 61 | $this->operator = $operator; |
| 61 | 62 | } |
| @@ -68,9 +69,9 @@ | ||
| 68 | 69 | if (is_string($operand)) { |
| 69 | 70 | $operand = $this->validateOperand($operand, $operandValueType); |
| 70 | 71 | } |
| 71 | 72 | |
| 72 | - $this->operand[$index] = $operand; //* @phpstan-ignore-line | |
| 73 | + $this->operand[$index] = $operand; //* @phpstan-ignore assign.propertyType (I don't know what is needed) | |
| 73 | 74 | $this->operandValueType[$index] = $operandValueType; |
| 74 | 75 | } |
| 75 | 76 | |
| 76 | 77 | /** |
| @@ -162,12 +163,8 @@ | ||
| 162 | 163 | * @param mixed[] $arguments |
| 163 | 164 | */ |
| 164 | 165 | public function __call(string $methodName, array $arguments): self |
| 165 | 166 | { |
| 166 | - if (!isset(self::MAGIC_OPERATIONS[$methodName]) && $methodName !== 'and') { | |
| 167 | - throw new Exception('Invalid Operator for Cell Value CF Rule Wizard'); | |
| 168 | - } | |
| 169 | - | |
| 170 | 167 | if ($methodName === 'and') { |
| 171 | 168 | if (!isset(self::RANGE_OPERATORS[$this->operator])) { |
| 172 | 169 | throw new Exception('AND Value is only appropriate for range operators'); |
| 173 | 170 | } |
| @@ -176,8 +173,12 @@ | ||
| 176 | 173 | |
| 177 | 174 | return $this; |
| 178 | 175 | } |
| 179 | 176 | |
| 177 | + if (!isset(self::MAGIC_OPERATIONS[$methodName])) { | |
| 178 | + throw new Exception('Invalid Operator for Cell Value CF Rule Wizard'); | |
| 179 | + } | |
| 180 | + | |
| 180 | 181 | $this->operator(self::MAGIC_OPERATIONS[$methodName]); |
| 181 | 182 | //$this->operand(0, ...$arguments); |
| 182 | 183 | if (count($arguments) < 2) { |
| 183 | 184 | $this->operand(0, $arguments[0]); |
| @@ -187,6 +188,18 @@ | ||
| 187 | 188 | $this->operand(0, $arguments[0], $arg1); |
| 188 | 189 | } |
| 189 | 190 | |
| 190 | 191 | return $this; |
| 192 | + } | |
| 193 | + | |
| 194 | + /** @internal */ | |
| 195 | + public static function compareKeys(): bool | |
| 196 | + { | |
| 197 | + $retVal = true; | |
| 198 | + $array = array_merge(array_keys(self::SINGLE_OPERATORS), array_keys(self::RANGE_OPERATORS)); | |
| 199 | + foreach ($array as $value) { | |
| 200 | + $retVal = $retVal && in_array($value, self::MAGIC_OPERATIONS, true); | |
| 201 | + } | |
| 202 | + | |
| 203 | + return $retVal; | |
| 191 | 204 | } |
| 192 | 205 | } |