Make WordPress Core


Ignore:
Timestamp:
11/28/2017 04:23:11 AM (7 years ago)
Author:
pento
Message:

General: Add inline PHPCS options to leave regex indentation.

We have a handful of super long regexen that are written over multiple lines, as a collection of strings concatenated together. Each string is indented appropriately for the regex, but PHPCS doesn't recognised this, so defaults to removing the extra whitespace.

Disabling the Squiz.Strings.ConcatenationSpacing.PaddingFound rule for these blocks stops the extra whitespace from being removed.

See #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/shortcodes.php

    r42228 r42249  
    236236    // WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcode_tag()
    237237    // Also, see shortcode_unautop() and shortcode.js.
     238
     239    // phpcs:disable Squiz.Strings.ConcatenationSpacing.PaddingFound -- don't remove regex indentation
    238240    return
    239         '\\['                              // Opening bracket
     241        '\\['                                // Opening bracket
    240242        . '(\\[?)'                           // 1: Optional second opening bracket for escaping shortcodes: [[tag]]
    241243        . "($tagregexp)"                     // 2: Shortcode name
     
    265267        . ')'
    266268        . '(\\]?)';                          // 6: Optional second closing brocket for escaping shortcodes: [[tag]]
     269    // phpcs:enable
    267270}
    268271
Note: See TracChangeset for help on using the changeset viewer.