/
InlineControlStructureUnitTest.inc
194 lines (158 loc) · 3.28 KB
/
InlineControlStructureUnitTest.inc
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
if ($something) echo 'hello';
if ($something) {
echo 'hello';
} else echo 'hi';
if ($something) {
echo 'hello';
} else if ($else) echo 'hi';
foreach ($something as $thing) echo 'hello';
for ($i; $i > 0; $i--) echo 'hello';
while ($something) echo 'hello';
do {
$i--;
} while ($something);
if(true)
$someObject->{$name};
if (true) :
$foo = true;
endif;
while (true) :
$foo = true;
endwhile;
for ($i; $i > 0; $i--) :
echo 'hello';
endfor;
foreach ($array as $element) :
echo 'hello';
endforeach;
while (!$this->readLine($tokens, $tag));
while (!$this->readLine($tokens, $tag)); //skip to end of file
foreach ($cookies as $cookie)
if ($cookie->match($uri, $matchSessionCookies, $now))
$ret[] = $cookie;
foreach ($stringParade as $hit)
$hitParade[] = $hit + 0; //cast to integer
if ($foo) :
echo 'true';
elseif ($something) :
echo 'foo';
else:
echo 'false';
endif;
function test()
{
if ($a)
$a.=' '.($b ? 'b' : ($c ? ($d ? 'd' : 'c') : ''));
}
if ($a)
foreach ($b as $c) {
if ($d) {
$e=$f;
$g=$h;
} elseif ($i==0) {
$j=$k;
}
}
?>
<div style="text-align: right;">
<?php if ($model->scenario == 'simple') $widget->renderPager() ?>
</div>
<?php
switch ($this->error):
case Shop_Customer :: ERROR_INVALID_GENDER: ?>
Ungültiges Geschlecht!
<?php break;
case Shop_Customer :: ERROR_EMAIL_IN_USE: ?>
Die eingetragene E-Mail-Adresse ist bereits registriert.
<?php break;
endswitch;
if ($this->allowShopping !== true):
if ($this->status != Shop_Cart :: OK):
switch ($this->status):
case Shop_Cart :: NOT_FOUND:
echo 'foo';
endswitch;
endif;
else:
echo 'foo';
endif;
// ELSE IF split over multiple lines (not inline)
if ($test) {
} else
if ($test) {
} else {
}
switch($response = \Bar::baz('bat', function ($foo) {
return 'bar';
})) {
case 1:
return 'test';
case 2:
return 'other';
}
$stuff = [1,2,3];
foreach($stuff as $num)
if ($num %2 ) {
echo "even";
} else {
echo "odd";
}
$i = 0;
foreach($stuff as $num)
do {
echo $i;
$i++;
} while ($i < 5);
foreach($stuff as $num)
if (true) {
echo "true1\n";
}
if (true) {
echo "true2\n";
}
if ($foo) echo 'foo';
elseif ($bar) echo 'bar';
else echo 'baz';
switch ($type) {
case 1:
if ($foo) {
return true;
} elseif ($baz)
return true;
else {
echo 'else';
}
break;
}
foreach ($sql as $s)
if (!$this->execute) echo "<pre>",$s.";\n</pre>";
else {
$ok = $this->connDest->Execute($s);
if (!$ok)
if ($this->neverAbort) $ret = false;
else return false;
}
if ($bar)
if ($foo) echo 'hi'; // lol
if ($level == 'district')
\DB::update(<<<EOD
some
text
here
EOD
);
if ($level == 'district')
$var = <<<EOD
some
text
here
EOD;
if ($a && $a === Foo::VARIABLE && ($a === Foo::METHOD || $a === Foo::FUNCTION))
echo 'hi';
$out = array_map(function ($test) { if ($test) return 1; else return 2; }, $input); // comment
if (true)
try {
}
catch(Exception $e) {
}