You are here

function coder_preprocessor_ml_array_add_comma in Coder 5

Related topics

File

scripts/coder_format/coder_format.inc, line 827

Code

function coder_preprocessor_ml_array_add_comma() {

  // @bug coder.module:1010
  return array(
    '#title' => 'Append a comma to the last value of multiline arrays.',
    // ^[\040\t]*(?!\*|\/\/)[^\*\/\n]*? matches anything in front of array, but not comments
    // \sarray\( prevents matching of in_array() and function calls
    // (\n|(?X>!\);).+?,?\n) matches a line break or the first array item
    // (.*?[^,;]) matches the rest array items
    // ,?(\n\s*)\); matches the end of multiline array, optionally including a comma
    '#search' => '/(^[\\040\\t]*(?!\\*|\\/\\/)[^\\*\\/\\n]*?\\sarray\\()(\\n|(?>!\\);).+?,?\\n)(.*?[^,;]),?(\\n\\s*\\);)/ism',
    '#replace' => '$1$2$3,$4',
  );
}