* protected function getSubElements()
* {
* return array(
* 'type',
* 'variable',
* 'comment',
* );
* }
*
*
* The processSubElement will be called for each of the sub elements to allow
* the extending class to process them. So for the parameter element we would
* have:
*
*
* protected function processSubElement($name, $content, $whitespaceBefore)
* {
* if ($name === 'type') {
* echo 'The name of the variable was '.$content;
* }
* // Process other tags.
* }
*
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood
* /** <--this is the start of the comment.
* * This is a short comment description
* *
* * This is a long comment description
* * <-- this is the end of the comment
* * @return something
* {@/}
*
*
* Note that the sentence before two newlines is assumed
* the short comment description.
*
* @category PHP
* @package PHP_CodeSniffer
* @author Greg Sherwood $content
".PHP_EOL; }//end printTextBlock() /** * Print a code comparison block found in a standard. * * @param DOMNode $node The DOMNode object for the code comparison block. * * @return void */ protected function printCodeComparisonBlock($node) { $codeBlocks = $node->getElementsByTagName('code'); $firstTitle = $codeBlocks->item(0)->getAttribute('title'); $first = trim($codeBlocks->item(0)->nodeValue); $first = str_replace("\n", '', $first); $first = str_replace(' ', ' ', $first); $first = str_replace('', '', $first); $first = str_replace('', '', $first); $secondTitle = $codeBlocks->item(1)->getAttribute('title'); $second = trim($codeBlocks->item(1)->nodeValue); $second = str_replace("\n", '', $second); $second = str_replace(' ', ' ', $second); $second = str_replace('', '', $second); $second = str_replace('', '', $second); echo '$firstTitle | ".PHP_EOL; echo "$secondTitle | ".PHP_EOL; echo '
$first | ".PHP_EOL; echo "$second | ".PHP_EOL; echo '
= (1 + 2);
$veryLongVarName = 'string';
$var = foo($bar, $baz, $quux);
]]>
= (1 + 2);
$veryLongVarName = 'string';
$var = foo($bar, $baz, $quux);
]]>
+= 1;
$veryLongVarName = 1;
]]>
+= 1;
$veryLongVarName = 1;
]]>
= 1;
$veryLongVarName -= 1;
]]>
= 1;
$veryLongVarName -= 1;
]]>
{
...
}
]]>
{
...
}
]]>
{
...
}
]]>
{
...
}
]]>
FOO_CONSTANT', 'foo');
class FooClass
{
const FOO_CONSTANT = 'foo';
}
]]>
Foo_Constant', 'foo');
class FooClass
{
const foo_constant = 'foo';
}
]]>
false || $var === null) {
$var = true;
}
]]>
FALSE || $var === NULL) {
$var = TRUE;
}
]]>
FALSE || $var === NULL) {
$var = TRUE;
}
]]>
false || $var === null) {
$var = true;
}
]]>
* stmt {
* // foo
* }
* stmt (conditions) {
* // foo
* }
*
*
* Statements covered by this sniff are catch, do, else,
* elsif, for, foreach, if, switch, try
* and while.
*
* @category PHP
* @package PHP_CodeSniffer
* @author Manuel Pichler
* class Foo
* {
* public function bar($x)
* {
* for (;true;) true; // No Init or Update part, may as well be: while (true)
* }
* }
*
*
* @category PHP
* @package PHP_CodeSniffer
* @author Manuel Pichler
* class Foo
* {
* public function bar($x)
* {
* $a = array(1, 2, 3, 4);
* for ($i = 0; $i < count($a); $i++) {
* $a[$i] *= $i;
* }
* }
* }
*
*
* @category PHP
* @package PHP_CodeSniffer
* @author Manuel Pichler
* class Foo
* {
* public function bar($x)
* {
* for ($i = 0; $i < 10; $i++)
* {
* for ($k = 0; $k < 20; $i++)
* {
* echo 'Hello';
* }
* }
* }
* }
*
*
* @category PHP
* @package PHP_CodeSniffer
* @author Manuel Pichler
* class Foo
* {
* public function close()
* {
* if (true)
* {
* // ...
* }
* }
* }
*
*
* @category PHP
* @package PHP_CodeSniffer
* @author Manuel Pichler
* final class Foo
* {
* public final function bar()
* {
* }
* }
*
*
* @category PHP
* @package PHP_CodeSniffer
* @author Manuel Pichler
* class FooBar {
* public function __construct($a, $b) {
* parent::__construct($a, $b);
* }
* }
*
*
* @category PHP
* @package PHP_CodeSniffer
* @author Manuel Pichler
* if (@in_array($array, $needle))
* {
* doSomething();
* }
*
*
* @category PHP
* @package PHP_CodeSniffer
* @author Andy Brockhurst