Issue #3392200 by jeremy_p, joachim, hdnag, yepa: Invalid placeholder error message should say what's wrong with it

merge-requests/4895/head
Lauri Eskola 2023-11-20 11:30:04 +02:00
parent 4f47df39cc
commit 8abb2835b6
No known key found for this signature in database
GPG Key ID: 382FC0F5B0DF53F8
2 changed files with 2 additions and 2 deletions

View File

@ -244,7 +244,7 @@ class FormattableMarkup implements MarkupInterface, \Countable {
default:
if (!ctype_alnum($key[0])) {
// Warn for random placeholders that won't be replaced.
trigger_error(sprintf('Invalid placeholder (%s) with string: "%s"', $key, $string), E_USER_WARNING);
trigger_error(sprintf('Placeholders must begin with one of the following "@", ":" or "%%", invalid placeholder (%s) with string: "%s"', $key, $string), E_USER_WARNING);
}
// No replacement possible therefore we can discard the argument.
unset($args[$key]);

View File

@ -117,7 +117,7 @@ class FormattableMarkupTest extends TestCase {
*/
public function providerTestUnexpectedPlaceholder() {
return [
['Non alpha, non-allowed starting character: ~placeholder', ['~placeholder' => 'replaced'], E_USER_WARNING, 'Invalid placeholder (~placeholder) with string: "Non alpha, non-allowed starting character: ~placeholder"'],
['Non alpha, non-allowed starting character: ~placeholder', ['~placeholder' => 'replaced'], E_USER_WARNING, 'Placeholders must begin with one of the following "@", ":" or "%", invalid placeholder (~placeholder) with string: "Non alpha, non-allowed starting character: ~placeholder"'],
['Alpha starting character: placeholder', ['placeholder' => 'replaced'], NULL, ''],
// Ensure that where the placeholder is located in the string is
// irrelevant.