foreach
loop found70 $ch = $server->connection->getStatement($sql);
71 $ch->execute(array($chid, $session->account->account_id));
72 $chr = $ch->fetchAll();
73 foreach($chr as $char) {74 }75 }
76} else {
77 $this->redirect($this->url('servicedesk','index'));
foreach
loop found213 $ah = $server->connection->getStatement("SELECT * FROM {$server->loginDatabase}.login WHERE account_id = $aid");
214 $ah->execute();
215 $ar = $ah->fetchAll();
216 foreach($ar as $ticketaccount) {217 }218 }
219
220} else {
foreach
loop found206 $ch = $server->connection->getStatement($sql);
207 $ch->execute();
208 $chr = $ch->fetchAll();
209 foreach($chr as $char) {210 }211
212 $aid=$trow->account_id;
213 $ah = $server->connection->getStatement("SELECT * FROM {$server->loginDatabase}.login WHERE account_id = $aid");
foreach
loop found 12if(!$staff){
13 $session->setMessageData('!!!Error!!! Account not in Staff Settings table! Please submit your prefered name before using the Service Desk.'); $this->redirect($this->url('servicedesk','staffsettings'));
14} else {
15 foreach($staff as $staffsess){} 16}
17
18if(isset($_POST['postreply']) && $_POST['postreply'] == 'gogolol'){
foreach
loop found 9$sth->execute(array($session->account->account_id));
10$staff = $sth->fetchAll();
11if($staff){
12 foreach($staff as $staffsess){}13}
14
15if(isset($option) && $option == 'delete'){
An empty block is considered as dead code as it doesn't do anything. The issue is raised when loops, conditionals, or other statements contains empty body which implies some piece of code is missing.
It is advised to remove the empty block since keeping them in the codebase wastes computation time and memory.
// Bad practice
foreach ($users as $user) {
}
if ($isUserActive) {
}
// Recommended
foreach ($users as $user) {
echo $user->getName();
}
if ($isUserActive) {
echo $user->getName();
}