Skip to content

Commit 7b99dc8

Browse files
committed
Ensure TextParser returns array<string, string> for type safety
- Cast numeric values (INTERVAL, COUNT, BYMONTH) to strings - Update type annotations to match Rule constructor expectations - Maintain null safety checks for symbol array access
1 parent e9e6660 commit 7b99dc8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Recurr/TextParser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class TextParser
4949
private bool $done = true;
5050

5151
/**
52-
* @var array<string, mixed>
52+
* @var array<string, string>
5353
*/
5454
private array $options = [];
5555

@@ -63,7 +63,7 @@ public function __construct()
6363
*
6464
* @param string $text Natural language text describing recurrence
6565
*
66-
* @return array<string, mixed>|null Options array suitable for Rule constructor
66+
* @return array<string, string>|null Options array suitable for Rule constructor
6767
*/
6868
public function parseText(string $text): ?array
6969
{
@@ -248,7 +248,7 @@ private function parseStatement(): void
248248
$this->expect('every');
249249
$n = $this->acceptNumber();
250250
if ($n) {
251-
$this->options['INTERVAL'] = intval($n[0]);
251+
$this->options['INTERVAL'] = (string) intval($n[0]);
252252
}
253253

254254
if ($this->isDone()) {
@@ -334,7 +334,7 @@ private function parseStatement(): void
334334
'september' => 9, 'october' => 10, 'november' => 11, 'december' => 12
335335
];
336336
if ($this->symbol !== null && isset($monthMap[$this->symbol])) {
337-
$this->options['BYMONTH'] = $monthMap[$this->symbol];
337+
$this->options['BYMONTH'] = (string) $monthMap[$this->symbol];
338338
}
339339
$this->nextSymbol();
340340
break;
@@ -348,7 +348,7 @@ private function parseStatement(): void
348348
$this->nextSymbol();
349349
$count = $this->acceptNumber();
350350
if ($count) {
351-
$this->options['COUNT'] = intval($count[0]);
351+
$this->options['COUNT'] = (string) intval($count[0]);
352352
$this->accept('times'); // optional "times" after number
353353
}
354354
} elseif ($this->symbol === 'until') {

0 commit comments

Comments
 (0)