Newer
Older
Doug Green
committed
/**
* @file
* This include file implements tests for the Drupal Standards as defined
* at http://drupal.org/coding-standards
*
* It is never actually called by the coder code, but is read when running
Doug Green
committed
* admin/coder/coder.
Doug Green
committed
// Tab in comment - is this ok?
$var = 'tab in quote'; // Is this ok?
$var = 'tab error';
}
function coder_test_stdclass() {
Doug Green
committed
$var = new stdClass(); // This is ok.
$var = new StdClass(); // This is not.
$var = new stdclassToo(); // Should be camelcase rule.
Doug Green
committed
$camelCaseVar = 'whatever'; // Camel case functions and vars not allowed.
$var = $obj->camelCase; // But camel case objects elements are.
new camcelCase(); // Is ok.
}
function coder_test_two_errors_on_same_line() {
Doug Green
committed
if('test=' . $test == 'test='){ // There are 3 errors on this line.
}
}
function coder_test_embedded_php() {
?>This is embedded php and should Not trigger a camelCase error.<?php
?>This second embedded php and should Not trigger
a camelCase error.<?php
}
function coder_hex_number() {
Doug Green
committed
$var = 0xFF; // Should NOT be camelcase.
Doug Green
committed
function coder_multiline_quote() { // From Drupal5 block.module.
return t('<p>Blocks are boxes of content that may be rendered into certain regions of your web pages, for example, into sidebars. They are usually generated automatically by modules, but administrators can create blocks manually.</p>
<p>Only enabled blocks are shown. You can position blocks by specifying which area of the page they should appear in (e.g., a sidebar). Highlighted labels on this page show the regions into which blocks can be rendered. You can specify where within a region a block will appear by adjusting its weight.</p>
<p>If you want certain blocks to disable themselves temporarily during high server loads, check the "Throttle" box. You can configure the auto-throttle on the <a href="@throttle">throttle configuration page</a> after having enabled the throttle module.</p>
<p>You can configure the behaviour of each block (for example, specifying on which pages and for what users it will appear) by clicking the "configure" link for each block.</p>', array('@throttle' => url('admin/settings/throttle')));
}
function coder_break() {
Doug Green
committed
print '<br>'; // Should generate an error, and will throw performance warning.
?><br><?php // Should also generate an error.
}
function coder_heredoc() {
$var = <<< __EOD__
<br><!-- a php error and not a camelCase error -->
<B><!-- an uppercase XHTML error -->
__EOD__;
$var = <<<__EOD__
<br><!-- and again -->
function coder_dot() {
Doug Green
committed
if ($file = file_check_upload($fieldname . '_upload')) { // Not ok.
Doug Green
committed
$v .= 'bugger'; // Ok.
$a = $v .'bugger'; // Ok.
$a = $v ."bugger"; // Ok, but will throw performance warning.
$a = $v.'bugger'; // Not ok.
$a = $some_func().'bugger'; // Not ok.
$a = 1.0 * .1 * 1. * (0.1) * (1.) * (.1) * (1.0); // Ok.
function coder_array_indexes() {
$a[hello] = 'this is bad';
$a['hello'] = 'this is no';
}
function coder_trailing_spaces() {
Stella Power
committed
$left = 'this is bad';
$left = 'this is ok';
}
function coder_control_structures() {
if($a == 1){ }
if ($a == 1) {
}else {
}
if ($a == 1) { $b = 2;
}
if ($a == 1) {$b = 2;
}
}
Doug Green
committed
// Should generate an error about the trailing php close.