-
-
Notifications
You must be signed in to change notification settings - Fork 86
Closed
Labels
Description
Hello,
I noticed a weird behavior when the matching pattern contains an array with a trailing comma after the final element as seen in the example and it's output below.
I'd expect the trailing comma to be ignored in the "First" test below and not throw an error.
But take a look at the "Second" test, where the error is incorrectly about the @null@ formatter.
<?php
use Coduo\PHPMatcher\Factory\SimpleFactory;
$factory = new SimpleFactory();
$matcher = $factory->createMatcher();
$match = $matcher->match(
'{"ids": [1, 2]}',
'{"ids": [@integer@, @integer@,]}'
);
if (!$match) {
echo "First: " . $matcher->getError() . "\n";
}
$match = $matcher->match(
'{"value": null, "ids": [1, 2]}',
'{"value": @null@, "ids": [@integer@, @integer@,]}'
);
if (!$match) {
echo "Second: " . $matcher->getError() . "\n";
}
Output:
First: "{"ids": [1, 2]}" does not match "{"ids": [@integer@, @integer@,]}" pattern
Second: Type pattern "@null@" is not supported by TextMatcher.