Last active
August 29, 2015 14:04
-
-
Save saksmt/f1e64fa618612761acf7 to your computer and use it in GitHub Desktop.
Ubershitcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foreach($users as $key => $user) // <--- $user is used only (1), $key is used only for indexing in array | |
{ | |
$id = $user['id']; // <--- (1)here | |
if($id == $currentUserId) | |
unset($users[$key]); | |
if($tags != null) // not strict comparison with null, (2) | |
{ | |
$tmpTags = $tagsRepo->createQueryAllByUserId($id)->getResult(); // <--- WAT?! | |
$userTags = []; | |
foreach($tmpTags as $obj) | |
{ | |
$userTags[] = $obj['tag']; | |
} | |
// Original comment goes below | |
if( count(array_intersect($tags, $userTags)) != count($tags) )//Check if all tags typed by in search are in list of searched user's tags | |
{ // Why can't we use array_diff? Religion doesn't allow? | |
unset($users[$key]); // Oh shit... array modification when using foreach, which uses pointers | |
} // Why he modified array, why he checks array then, why don't he just make a copy of variable? | |
} | |
if(isset($users[$key])) // <--- (2) HE KNEW ABOUT ISSET AND USED UNSTRICT COMPARISON WITH NULL!!! | |
{ | |
$resultData[] = ['user' => $users[$key], | |
'isFriend' => $friendshipRepo->findSentRequest($this->getUser()->getId(), $id) != null ? true : false // <--- No comments, this is too much even for me... | |
]; | |
} | |
} // Pain, only pain in my eyes and brain... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment