Skip to content

Added possibility to dump backtrace #174

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
Aug 16, 2019

Conversation

norberttech
Copy link
Member

Debugging php-matcher is not an easy task, especially when working with complex values/patterns.
Backtrace should simplify this process, below example of backtrace for simple match:

$matcher->match('100', '@string@')
echo (string) $matcher->backtrace();
#1 Matcher Coduo\PHPMatcher\Matcher matching value "100" with "@string@" pattern
#2 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (all) matching value "100" with "@string@" pattern
#3 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) can match pattern "@string@"
#4 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) matching value "100" with "@string@" pattern
#5 Matcher Coduo\PHPMatcher\Matcher\CallbackMatcher can't match pattern "@string@"
#6 Matcher Coduo\PHPMatcher\Matcher\ExpressionMatcher can't match pattern "@string@"
#7 Matcher Coduo\PHPMatcher\Matcher\NullMatcher can't match pattern "@string@"
#8 Matcher Coduo\PHPMatcher\Matcher\StringMatcher can match pattern "@string@"
#9 Matcher Coduo\PHPMatcher\Matcher\StringMatcher matching value "100" with "@string@" pattern
#10 Matcher Coduo\PHPMatcher\Matcher\StringMatcher successfully matched value "100" with "@string@" pattern
#11 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (scalars) successfully matched value "100" with "@string@" pattern
#12 Matcher Coduo\PHPMatcher\Matcher\ChainMatcher (all) successfully matched value "100" with "@string@" pattern
#13 Matcher Coduo\PHPMatcher\Matcher successfully matched value "100" with "@string@" pattern

More complex matchers will generate huge backtraces but when going through them step by step it's easy to track all mistakes.

@norberttech norberttech added this to the 4.0.0 milestone Aug 15, 2019
@norberttech norberttech merged commit 6f46fe0 into coduo:master Aug 16, 2019
@norberttech norberttech deleted the feature/backtrace branch August 16, 2019 18:07
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant