You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`analyzeReDoS()` returns a `ReDoSAnalysis` with the severity, score, vulnerable substring (if any), and recommendations. `isSafe()` simply calls `analyzeReDoS()` and returns `true` only for severities considered safe/low (or below the optional threshold you pass in).
370
+
354
371
You choose what to tolerate:
355
372
356
373
```php
@@ -445,6 +462,7 @@ final readonly class Regex
445
462
public static function create(array $options = []): self;
446
463
447
464
public function parse(string $regex): Node\RegexNode;
465
+
public function parsePattern(string $pattern, string $delimiter = '/', string $flags = ''): Node\RegexNode;
448
466
449
467
public function parseTolerant(string $regex): TolerantParseResult;
450
468
@@ -460,7 +478,7 @@ final readonly class Regex
460
478
461
479
public function analyzeReDoS(string $regex): ReDoS\ReDoSAnalysis;
462
480
463
-
public function isSafe(string $regex, ReDoS\ReDoSSeverity $threshold): bool;
481
+
public function isSafe(string $regex, ?ReDoS\ReDoSSeverity $threshold = null): bool;
464
482
465
483
public function getLexer(): Lexer;
466
484
public function getParser(): Parser;
@@ -471,25 +489,33 @@ Return types like `ValidationResult`, `LiteralSet`, `ReDoSAnalysis` are small, w
471
489
472
490
---
473
491
474
-
## Versioning & BC Policy
492
+
## Exceptions
475
493
476
-
RegexParser follows **Semantic Versioning**:
494
+
- `Regex::create()` throws `InvalidRegexOptionException` for unknown/invalid options.
495
+
- `parse()` / `parsePattern()` can throw `LexerException`, `SyntaxErrorException` (syntax/structure), `RecursionLimitException` (too deep), and `ResourceLimitException` (pattern too long).
496
+
- `parseTolerant()` wraps those errors into `TolerantParseResult` instead of throwing.
497
+
- `validate()` converts parser/lexer errors into a `ValidationResult` (no exception on invalid input).
498
+
- `analyzeReDoS()` / `isSafe()` share the same parsing exceptions as `parse()`; `isSafe()` is a boolean wrapper around `analyzeReDoS()`.
477
499
478
-
* **1.0.0** — Initial stable release.
479
-
* **1.x** — No breaking changes to:
500
+
Generic runtime errors (e.g., wrong argument types) are not part of the stable API surface.
480
501
481
-
* public methods of `Regex`,
482
-
* AST node constructors & properties,
483
-
* `NodeVisitorInterface`,
484
-
* ReDoS public API.
502
+
---
503
+
504
+
## Versioning & BC Policy
505
+
506
+
RegexParser follows **Semantic Versioning**:
485
507
486
-
We reserve the right to:
508
+
* **Stable for 1.x** (API surface we commit to keep compatible):
509
+
* Public methods and signatures on `Regex`.
510
+
* Value objects: `ValidationResult`, `TolerantParseResult`, `LiteralSet`, `ReDoS\ReDoSAnalysis`.
511
+
* Main exception interfaces/classes: `RegexParserExceptionInterface`, parser/lexer exceptions, `InvalidRegexOptionException`.
512
+
* Supported option keys for `Regex::create()` / `RegexOptions`.
487
513
488
-
* Add new methods (with sensible defaults).
489
-
* Add new node types in minor versions (without changing existing ones).
490
-
* Improve analysis heuristics and error messages.
514
+
* **Best-effort, may evolve within 1.x**:
515
+
* AST node classes and `NodeVisitorInterface` (new node types/visit methods can be added).
516
+
* Built-in visitors and analysis heuristics.
491
517
492
-
Breaking changes will be released as **2.0**.
518
+
If you maintain custom visitors, plan to adjust them when new nodes appear. Breaking changes beyond this policy land in **2.0.0**.
0 commit comments