You are here

function coder_postprocessor_if_curly_braces in Coder 6.2

Same name and namespace in other branches
  1. 5.2 scripts/coder_format/coder_format.inc \coder_postprocessor_if_curly_braces()
  2. 5 scripts/coder_format/coder_format.inc \coder_postprocessor_if_curly_braces()
  3. 6 scripts/coder_format/coder_format.inc \coder_postprocessor_if_curly_braces()
  4. 7.2 scripts/coder_format/coder_format.inc \coder_postprocessor_if_curly_braces()
  5. 7 scripts/coder_format/coder_format.inc \coder_postprocessor_if_curly_braces()

Related topics

File

scripts/coder_format/coder_format.inc, line 1383
Coder format helper functions.

Code

function coder_postprocessor_if_curly_braces() {

  // This post-processor relies on the fact that coder_format already
  // re-formatted if statements without curly braces to be on one line.
  return array(
    '#title' => 'Use curly braces even in situations where they are technically optional.',
    '#search' => '@
      (\\s*)           # match leading white-space, including newline
      (if\\ \\(.+\\)\\ )  # match if statement
      ([^\\{].+;)      # match conditional executed code not starting with a curly brace, delimited by a semicolon.
      @x',
    '#replace' => '$1$2{$1  $3$1}',
  );
}