Conversation
When parseText() is called with an empty or whitespace-only string, similarity matching against templates via similar_text() produces undefined/meaningless scores and brute-force matching wastes cycles. Return early with an empty ParseResult and log a warning instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Template variables like {%my-var%} or {%123abc%} produce invalid PCRE
named capture groups, causing silent regex failures and empty results.
Validate each variable name against /^[a-zA-Z_][a-zA-Z0-9_]*$/ in
TemplatesHelper::prepareTemplate() and throw
InvalidTemplateVariableNameException with a clear message on violation.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
User-provided regex patterns in template variables (e.g. {%id:[0-9+%})
could silently produce broken PCRE and return empty results with no
indication of the root cause. After building the final pattern, run a
dummy preg_match() and throw InvalidTemplateSyntaxException with the
PCRE error message when the pattern is invalid, enabling fast failure
instead of silent data loss.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Each call to parseText() previously triggered a file_get_contents() + full regex compilation pass for every template in the directory. Add an in-memory cache (keyed by file path) on the TemplatesHelper instance so that subsequent parseText() calls on the same parser reuse the compiled patterns, cutting redundant I/O and regex compilation to zero. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Users previously had to call getParsedRawData() to iterate over results or countResults() for counting. ParseResult now implements \IteratorAggregate and \Countable so it can be used directly in foreach loops and with count(), reducing boilerplate in consumer code. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
get(\$key, true) works but requires reading the boolean argument at every call site to understand its intent. getOrFail() expresses the strict contract directly in its name and returns a non-nullable string, giving callers a cleaner type signature without requiring an assertion or null-coalesce at the call site. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tch outcome Previous log messages showed only raw JSON of extracted data and a bare template path, making it hard to debug parsing issues in production. Log messages now include: file path and byte size in parseFileContent(), text length and template count with similarity mode in parseText(), template basename on each attempt, key count on a successful match, and an explicit no-match info log when no template fits. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Exception classes had no direct tests, so their inheritance chain, message propagation, and newly added classes (InvalidTemplateSyntaxException, InvalidTemplateVariableNameException) were unverified. ExceptionTest covers all exception classes for correct base-class inheritance and message preservation. Also remove the src/Exception coverage exclusion from phpunit.xml so exception code is now tracked in the coverage report. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ripts PHPStan at level 8 (the strictest) is added as a dev dependency with a phpstan.neon targeting the src/ directory. Two new composer scripts make common quality tasks discoverable without reading docs: `composer analyse` runs static analysis and `composer lint` checks PHP syntax across src/ and tests/. This catches type errors, dead code, and unsafe operations before they reach CI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
composer.lock is not appropriate for libraries as it is ignored by consumers and gives a false sense of reproducibility. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
b707c90 to
14c3379
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
v3.1.0-enhancementsWhat changed?