function coder_trim_php in Coder 6
Same name and namespace in other branches
- 5.2 scripts/coder_format/coder_format.inc \coder_trim_php()
- 5 scripts/coder_format/coder_format.inc \coder_trim_php()
- 6.2 scripts/coder_format/coder_format.inc \coder_trim_php()
- 7.2 scripts/coder_format/coder_format.inc \coder_trim_php()
- 7 scripts/coder_format/coder_format.inc \coder_trim_php()
Trim overall code.
Strips whitespace at the beginning and end of code, removes the closing PHP tag and appends two empty lines.
1 call to coder_trim_php()
- coder_format_string_all in scripts/
coder_format/ coder_format.inc - Formats source code according to Drupal conventions, also using post and pre-processors.
File
- scripts/
coder_format/ coder_format.inc, line 1048
Code
function coder_trim_php($code) {
// Remove surrounding whitespace.
$code = trim($code);
// Insert CVS keyword Id.
// Search in the very first 1000 chars, insert only one instance.
if (strpos(substr($code, 0, 1000), '$Id') === false) {
$code = preg_replace('/<\\?php\\n/', "<?php\n// \$Id\$\n\n", $code, 1);
}
// Remove closing PHP tag.
if (substr($code, -2) == '?>') {
$code = rtrim($code, '?>');
}
// Append two empty lines.
$code .= str_repeat(chr(10), 2);
return $code;
}