Verified Commit 08fa3c2e authored by Dave Long's avatar Dave Long
Browse files

Issue #3173103 by TolstoyDotCom, aludescher, smustgrave, J., jonathan1055, TR:...

Issue #3173103 by TolstoyDotCom, aludescher, smustgrave, J., jonathan1055, TR: False positives when identifying what is a placeholder, for deprecation error

(cherry picked from commit e1a599be)
parent ca113255
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -241,8 +241,10 @@ protected static function placeholderFormat($string, array $args) {
          break;

        default:
          // Warn for random variables that won't be replaced.
          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);
          }
          // No replacement possible therefore we can discard the argument.
          unset($args[$key]);
          break;
+4 −4
Original line number Diff line number Diff line
@@ -117,12 +117,12 @@ public function testUnexpectedPlaceholder($string, $arguments, $error_number, $e
   */
  public function providerTestUnexpectedPlaceholder() {
    return [
      ['Non alpha starting character: ~placeholder', ['~placeholder' => 'replaced'], E_USER_WARNING, 'Invalid placeholder (~placeholder) with string: "Non alpha starting character: ~placeholder"'],
      ['Alpha starting character: placeholder', ['placeholder' => 'replaced'], E_USER_WARNING, 'Invalid placeholder (placeholder) with string: "Alpha starting character: placeholder"'],
      ['Non alpha, non-allowed starting character: ~placeholder', ['~placeholder' => 'replaced'], E_USER_WARNING, '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.
      ['placeholder', ['placeholder' => 'replaced'], E_USER_WARNING, 'Invalid placeholder (placeholder) with string: "placeholder"'],
      ['No replacements', ['foo' => 'bar'], E_USER_WARNING, 'Invalid placeholder (foo) with string: "No replacements"'],
      ['placeholder', ['placeholder' => 'replaced'], NULL, ''],
      ['No replacements', ['foo' => 'bar'], NULL, ''],
    ];
  }