3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class ProfileRepository extends EntityRepository{ public function getProfilesExperimental($searchString, $isMapSearch = false){ $searchString = strtolower($searchString); $em = $this->getEntityManager(); $cit = $em->getRepository('LunnarBundle:City')->findAll(); $cat = $em->getRepository('LunnarBundle:Profilecategory')->findAll(); $bra = $em->getRepository('LunnarBundle:Brand')->findAll(); $cities = array(); $profilecategories = array(); $brands = array(); foreach($cit as $city){ array_push($cities, strtolower($city->getName())); } foreach($cat as $category){ array_push($profilecategories, strtolower($category->getName())); } foreach($bra as $brand){ array_push($brands, strtolower($brand->getName())); } $parameters = array(); //'var' => '%'.$searchString.'%', $searchQuerySelectJoin = "SELECT p FROM LunnarBundle:Profile p LEFT JOIN p.divisions d "; $searchQueryWhere = ""; ////////////////////////// $searchStringArray = explode(" ", $searchString); // Remove í, á and við $removeWords = array('í','á','við'); //Find city, category, brand and save for later, and remove them from $searchStringArray $searchStringArray = array_diff($searchStringArray, $removeWords); $city = array_intersect($searchStringArray, $cities); $searchStringArray = array_diff($searchStringArray, $city); $category = array_intersect($searchStringArray, $profilecategories); $searchStringArray = array_diff($searchStringArray, $category); $brand = array_intersect($searchStringArray, $brands); $searchStringArray = array_diff($searchStringArray, $brand); //// PRINTS print_r($searchStringArray); echo '<br/>'; //print_r($city); //print_r($profilecategory); //print_r($brand); $first = true; $searchTerms = " "; if (sizeof($searchStringArray)>0){ $searchTerms = current($searchStringArray); $parameters['var'] = "%".$searchTerms."%"; $searchQueryWhere = "WHERE ( p.name LIKE :var ".$searchQueryWhere; $first = false; } elseif (sizeof($searchStringArray)==0){ $searchQueryWhere = " WHERE ( ".$searchQueryWhere; } if ($category){ $parameters['category'] = $category; $searchQuerySelectJoin .= " LEFT JOIN p.profilecategory pc "; if (!$first){ $searchQueryWhere .= " AND pc.name = :category "; }else { $first = false; $searchQueryWhere .= " pc.name = :category "; } } if ($brand){ $parameters['brand'] = $brand; $searchQuerySelectJoin .= " LEFT JOIN p.brand b "; if (!$first){ $searchQueryWhere .= " AND b.name = :brand "; }else { $first = false; $searchQueryWhere .= " b.name = :brand "; } } if ($city){ $parameters['city'] = $city; $searchQuerySelectJoin .= " LEFT JOIN d.city c "; if (!$first){ $searchQueryWhere .= " AND c.name = :city "; }else { $first = false; $searchQueryWhere .= " c.name = :city "; } } ////////////////////////// if($isMapSearch == true){ $searchQuery .= "AND d.latitude IS NOT NULL "; } $searchQuery = $searchQuerySelectJoin.$searchQueryWhere." ) ORDER BY p.name ASC"; echo $searchQuery; $query = $this->getEntityManager() ->createQuery( $searchQuery )->setParameters($parameters); return $query->getResult(); } }
based on gndpb
Output for 5.0.0 - 5.4.3, 5.4.5 - 7.1.0
Fatal error: Class 'EntityRepository' not found in /in/IUQt1 on line 3
Process exited with code 255.
Output for 5.4.4

Process exited with code 137.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/IUQt1 on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/IUQt1 on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/IUQt1 on line 5
Process exited with code 255.