Skip to content

[3.0] Fix bad encoding in Repeat expander #114

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Matcher/Pattern/Expander/Repeat.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private function matchScalar(array $values, Matcher $matcher) : bool
$match = $matcher->match($value, $this->pattern);

if (!$match) {
$this->error = sprintf("Repeat expander, entry n%d, find error : %s", $index, $matcher->getError());
$this->error = sprintf("Repeat expander, entry n°%d, find error : %s", $index, $matcher->getError());
return false;
}
}
Expand Down Expand Up @@ -131,14 +131,14 @@ private function matchJson(array $values, Matcher $matcher) : bool

foreach ($patternKeys as $key) {
if (!array_key_exists($key, $value)) {
$this->error = sprintf("Repeat expander, entry n%d, require \"array\" to have key \"%s\".", $index, $key);
$this->error = sprintf("Repeat expander, entry n°%d, require \"array\" to have key \"%s\".", $index, $key);
return false;
}

$match = $matcher->match($value[$key], $this->pattern[$key]);

if (!$match) {
$this->error = sprintf("Repeat expander, entry n%d, key \"%s\", find error : %s", $index, $key, $matcher->getError());
$this->error = sprintf("Repeat expander, entry n°%d, key \"%s\", find error : %s", $index, $key, $matcher->getError());
return false;
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Matcher/Pattern/Expander/RepeatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public static function invalidCasesProvider()
];

return [
[$pattern, $valueTest, 'Repeat expander, entry n0, key "name", find error : integer "1" is not a valid string.'],
[$pattern, $keyTest, 'Repeat expander, entry n0, require "array" to have key "name".'],
[$pattern, $valueTest, 'Repeat expander, entry n°0, key "name", find error : integer "1" is not a valid string.'],
[$pattern, $keyTest, 'Repeat expander, entry n°0, require "array" to have key "name".'],
[$pattern, $strictTest, 'Repeat expander expect to have 2 keys in array but get : 3'],
[$pattern, "", 'Repeat expander require "array", got "".']
];
Expand Down