Menu

[r236]: / trunk / test / bad_other_17.php  Maximize  Restore  History

Download this file

106 lines (82 with data), 1.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
<?php
/**
* This file is an exemple of PHP file containing various warnings.
* This file should generate 2 warnings with the default config.
*/
class Other {
/**
* Prohibited functions.
*
* @param String $a
* @param String $b
* @param String $c
*/
function testAlCapone($a, $b = "c", $c) {
// 1 - defaultValuesOrder
$a = @count($c); // 2 - checkSilencedError
$c = "this is $a test"; // 3-4 - encapsedVariablesInsideString
$b++;
}
/**
* Fooooo.
*
* @param String $var (by reference)
*/
function foo(&$var) {
// 5 - avoidPassingReferences
// 6 - TODO Show todos
$var++;
$a = $var;; // 7 - checkEmptyStatement (;;)
if ($a AND $var) {
// 8 - useBooleanOperators
// 9 - checkEmptyBlock
}
// 10 - checkHeredoc
$a = <<<EOT
heredoc
EOT;
if ($a) echo $a; // 11 - needBraces with "if"
while ($a == true) echo $a; // 12 - needBraces with "while"
}
/**
* switch.
*
* @param String $a
*/
function aswitch($a) {
switch ($a) {
case "a":
break;
case "b":
break;
case "c":
break;
// 13 - switchNeedDefault
}
switch ($a) {
default: // 14 - switchDefaultOrder
break;
case "c":
break;
}
}
/**
* unary.
*
* @param String $a
*/
function unary($a) {
if ($a++) {
// 15 - checkUnaryOperator
while ($a = "1") {
// 16 - checkInnerAssignment
echo $a;
}
}
}
}
/**
* Other class inside the same file
*/
class Other2 { // 17 - oneClassPerFile
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.