$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('', $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('', $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 '
$firstTitle | ".PHP_EOL; echo "$secondTitle | ".PHP_EOL; echo '
---|---|
'.PHP_EOL.PHP_EOL; echo " $first".PHP_EOL.PHP_EOL; echo ' | '.PHP_EOL; echo ''.PHP_EOL.PHP_EOL; echo " $second".PHP_EOL.PHP_EOL; echo ' | '.PHP_EOL; echo '
Foo
{
}
]]>
Foo
{
}
class Foo
{
}
]]>
%; }
]]>
%; }
]]>
];
]]>
,];
]]>
var foo = 5;
]]>
foo = 5;
]]>
Handle strange case
if ($test) {
$var = 1;
}
]]>
FIXME: This needs to be fixed!
if ($test) {
$var = 1;
}
]]>
Handle strange case
if ($test) {
$var = 1;
}
]]>
TODO: This needs to be fixed!
if ($test) {
$var = 1;
}
]]>
$i++) {
for ($j = 0; $j < 10; $j++) {
}
}
]]>
$i++) {
for ($j = 0; $j < 10; $i++) {
}
}
]]>
$a + $b + $c;
}
]]>
$a + $b;
}
]]>
{
$var = 1;
}
]]>
// do nothing
}
]]>
$i = 0; $i < 10; $i++) {
echo "{$i}\n";
}
]]>
;$test;) {
$test = doSomething();
}
]]>
$end = count($foo);
for ($i = 0; $i < $end; $i++) {
echo $foo[$i]."\n";
}
]]>
count($foo); $i++) {
echo $foo[$i]."\n";
}
]]>
$test) {
$var = 1;
}
]]>
true) {
$var = 1;
}
]]>
$test) {
$var = 1;
}
]]>
false) {
$var = 1;
}
]]>
final function bar()
{
}
}
]]>
$this->doSomethingElse();
}
}
]]>
parent::bar();
}
}
]]>
some string here
class Foo
{
}
]]>
class Foo
{
}
class Bar
{
}
]]>
interface Foo
{
}
]]>
interface Foo
{
}
interface Bar
{
}
]]>
= (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;
]]>
1;
]]>
1;
]]>
1;
]]>
&$bar)
{
$bar++;
}
$baz = 1;
foo($baz);
]]>
&$baz);
]]>
$baz)
{
}
]]>
$baz)
{
}
]]>
= true)
{
}
]]>
=true)
{
}
]]>
{
...
}
]]>
{
...
}
]]>
{
...
}
]]>
{
...
}
]]>
doSomething()
{
}
]]>
do_something()
{
}
]]>
__construct()
{
}
}
]]>
Foo()
{
}
}
]]>
FOO_CONSTANT', 'foo');
class FooClass
{
const FOO_CONSTANT = 'foo';
}
]]>
Foo_Constant', 'foo');
class FooClass
{
const foo_constant = 'foo';
}
]]>
Beginning content
echo 'Foo';
?>
]]>
echo 'Foo';
]]>
explode('a', $bar);
]]>
split('a', $bar);
]]>
count($bar);
]]>
sizeof($bar);
]]>
false || $var === null) {
$var = true;
}
]]>
FALSE || $var === NULL) {
$var = TRUE;
}
]]>
array();
]]>
Array();
]]>
isset($foo) && $foo) {
echo "Hello\n";
}
]]>
@$foo) {
echo "Hello\n";
}
]]>
PHP_SAPI === 'cli') {
echo "Hello, CLI user.";
}
]]>
php_sapi_name() === 'cli') {
echo "Hello, CLI user.";
}
]]>
FALSE || $var === NULL) {
$var = TRUE;
}
]]>
false || $var === null) {
$var = true;
}
]]>
$var = 1;
}
]]>
$var = 1;
}
]]>
* stmt {
* // foo
* }
* stmt (conditions) {
* // foo
* }
*
*
* @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