From 27bc8d4f7bb907699dbb974e8159f75bead831c9 Mon Sep 17 00:00:00 2001 From: marc tobias Date: Thu, 22 Mar 2018 12:36:24 +0100 Subject: [PATCH] replace PHP sizeof() with either count() or empty() --- lib/Geocode.php | 28 +++++++-------- lib/ParameterParser.php | 2 +- lib/Phrase.php | 4 +-- lib/PlaceLookup.php | 6 ++-- lib/SearchDescription.php | 58 +++++++++++++++--------------- lib/cmd.php | 2 +- lib/lib.php | 2 +- lib/template/address-json.php | 2 +- lib/template/address-xml.php | 2 +- lib/template/details-html.php | 4 +-- lib/template/search-batch-json.php | 2 +- lib/template/search-html.php | 2 +- lib/template/search-json.php | 2 +- phpcs.xml | 7 ++++ utils/importWikipedia.php | 6 ++-- website/hierarchy.php | 6 ++-- website/polygons.php | 4 +-- website/reverse.php | 2 +- website/search.php | 2 +- 19 files changed, 75 insertions(+), 68 deletions(-) diff --git a/lib/Geocode.php b/lib/Geocode.php index 26fafb73..9daaff84 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -303,7 +303,7 @@ class Geocode $this->loadStructuredAddressElement($sPostalCode, 'postalcode', 5, 11, array(5, 11)); $this->loadStructuredAddressElement($sCountry, 'country', 4, 4, false); - if (sizeof($this->aStructuredQuery) > 0) { + if (!empty($this->aStructuredQuery)) { $this->sQuery = join(', ', $this->aStructuredQuery); if ($this->iMaxAddressRank < 30) { $this->sAllowedTypesSQLList = '(\'place\',\'boundary\')'; @@ -317,7 +317,7 @@ class Geocode $aParams = $this->aStructuredQuery; - if (sizeof($aParams) == 1) return false; + if (count($aParams) == 1) return false; $aOrderToFallback = array('postalcode', 'street', 'city', 'county', 'state'); @@ -375,8 +375,8 @@ class Geocode $sPhraseType, $iToken == 0 && $iPhrase == 0, $iPhrase == 0, - $iToken + 1 == sizeof($aWordset) - && $iPhrase + 1 == sizeof($aPhrases) + $iToken + 1 == count($aWordset) + && $iPhrase + 1 == count($aPhrases) ); foreach ($aNewSearches as $oSearch) { @@ -411,7 +411,7 @@ class Geocode usort($aNewWordsetSearches, array('Nominatim\SearchDescription', 'bySearchRank')); $aWordsetSearches = array_slice($aNewWordsetSearches, 0, 50); } - //var_Dump('
',sizeof($aWordsetSearches)); exit; + //var_Dump('
',count($aWordsetSearches)); exit; $aNewPhraseSearches = array_merge($aNewPhraseSearches, $aNewWordsetSearches); usort($aNewPhraseSearches, array('Nominatim\SearchDescription', 'bySearchRank')); @@ -442,7 +442,7 @@ class Geocode $iSearchCount = 0; $aSearches = array(); foreach ($aGroupedSearches as $iScore => $aNewSearches) { - $iSearchCount += sizeof($aNewSearches); + $iSearchCount += count($aNewSearches); $aSearches = array_merge($aSearches, $aNewSearches); if ($iSearchCount > 50) break; } @@ -627,7 +627,7 @@ class Geocode } } - if (sizeof($aTokens)) { + if (!empty($aTokens)) { // Check which tokens we have, get the ID numbers $sSQL = 'SELECT word_id, word_token, word, class, type, country_code, operator, search_name_count'; $sSQL .= ' FROM word '; @@ -702,8 +702,8 @@ class Geocode // because order in the address doesn't matter. $aPhrases = array_reverse($aPhrases); $aPhrases[0]->invertWordSets(); - if (sizeof($aPhrases) > 1) { - $aPhrases[sizeof($aPhrases)-1]->invertWordSets(); + if (count($aPhrases) > 1) { + $aPhrases[count($aPhrases)-1]->invertWordSets(); } $aReverseGroupedSearches = $this->getGroupedSearches($aSearches, $aPhrases, $aValidTokens, false); @@ -738,7 +738,7 @@ class Geocode $sHash = serialize($aSearch); if (isset($aSearchHash[$sHash])) { unset($aGroupedSearches[$iGroup][$iSearch]); - if (sizeof($aGroupedSearches[$iGroup]) == 0) unset($aGroupedSearches[$iGroup]); + if (empty($aGroupedSearches[$iGroup])) unset($aGroupedSearches[$iGroup]); } else { $aSearchHash[$sHash] = 1; } @@ -771,7 +771,7 @@ class Geocode if ($iQueryLoop > 20) break; } - if (sizeof($aResults) && ($this->iMinAddressRank != 0 || $this->iMaxAddressRank != 30)) { + if (!empty($aResults) && ($this->iMinAddressRank != 0 || $this->iMaxAddressRank != 30)) { // Need to verify passes rank limits before dropping out of the loop (yuk!) // reduces the number of place ids, like a filter // rank_address is 30 for interpolated housenumbers @@ -824,7 +824,7 @@ class Geocode $aResults = $tempIDs; } - if (sizeof($aResults)) break; + if (!empty($aResults)) break; if ($iGroupLoop > 4) break; if ($iQueryLoop > 30) break; } @@ -843,7 +843,7 @@ class Geocode } // No results? Done - if (!sizeof($aResults)) { + if (empty($aResults)) { if ($this->bFallback) { if ($this->fallbackStructuredQuery()) { return $this->lookup(); @@ -982,7 +982,7 @@ class Geocode } // Absolute limit on number of results - if (sizeof($aSearchResults) >= $this->iFinalLimit) break; + if (count($aSearchResults) >= $this->iFinalLimit) break; } if (CONST_Debug) var_dump($aSearchResults); diff --git a/lib/ParameterParser.php b/lib/ParameterParser.php index c9a97c25..26b648bb 100644 --- a/lib/ParameterParser.php +++ b/lib/ParameterParser.php @@ -99,7 +99,7 @@ class ParameterParser arsort($aLanguages); } } - if (!sizeof($aLanguages) && CONST_Default_Language) { + if (empty($aLanguages) && CONST_Default_Language) { $aLanguages[CONST_Default_Language] = 1; } diff --git a/lib/Phrase.php b/lib/Phrase.php index b39079d9..e8b31234 100644 --- a/lib/Phrase.php +++ b/lib/Phrase.php @@ -83,7 +83,7 @@ class Phrase $aResult = array(array(join(' ', $aWords))); $sFirstToken = ''; if ($iDepth < Phrase::MAX_DEPTH) { - while (sizeof($aWords) > 1) { + while (count($aWords) > 1) { $sWord = array_shift($aWords); $sFirstToken .= ($sFirstToken?' ':'').$sWord; $aRest = $this->createWordSets($aWords, $iDepth + 1); @@ -101,7 +101,7 @@ class Phrase $aResult = array(array(join(' ', $aWords))); $sFirstToken = ''; if ($iDepth < Phrase::MAX_DEPTH) { - while (sizeof($aWords) > 1) { + while (count($aWords) > 1) { $sWord = array_pop($aWords); $sFirstToken = $sWord.($sFirstToken?' ':'').$sFirstToken; $aRest = $this->createInverseWordSets($aWords, $iDepth + 1); diff --git a/lib/PlaceLookup.php b/lib/PlaceLookup.php index 41fdea89..bd6fa171 100644 --- a/lib/PlaceLookup.php +++ b/lib/PlaceLookup.php @@ -164,12 +164,12 @@ class PlaceLookup $aResults = $this->lookup(array($iPlaceID => new Result($iPlaceID))); - return sizeof($aResults) ? reset($aResults) : null; + return empty($aResults) ? null : reset($aResults); } public function lookup($aResults, $iMinRank = 0, $iMaxRank = 30) { - if (!sizeof($aResults)) { + if (empty($aResults)) { return array(); } $aSubSelects = array(); @@ -408,7 +408,7 @@ class PlaceLookup if (CONST_Debug) var_dump($aSubSelects); - if (!sizeof($aSubSelects)) { + if (empty($aSubSelects)) { return array(); } diff --git a/lib/SearchDescription.php b/lib/SearchDescription.php index 2e72decc..c4f05a0e 100644 --- a/lib/SearchDescription.php +++ b/lib/SearchDescription.php @@ -94,8 +94,8 @@ class SearchDescription */ public function looksLikeFullAddress() { - return sizeof($this->aName) - && (sizeof($this->aAddress || $this->sCountryCode)) + return (!empty($this->aName)) + && (!empty($this->aAddress) || $this->sCountryCode) && preg_match('/[0-9]+/', $this->sHouseNumber); } @@ -147,7 +147,7 @@ class SearchDescription */ public function isValidSearch() { - if (!sizeof($this->aName)) { + if (empty($this->aName)) { if ($this->sHouseNumber) { return false; } @@ -223,7 +223,7 @@ class SearchDescription // If we have a structured search or this is not the first term, // add the postcode as an addendum. if ($this->iOperator != Operator::POSTCODE - && ($sPhraseType == 'postalcode' || sizeof($this->aName)) + && ($sPhraseType == 'postalcode' || !empty($this->aName)) ) { $oSearch = clone $this; $oSearch->iSearchRank++; @@ -247,8 +247,8 @@ class SearchDescription $oSearch->iSearchRank++; } // also must not appear in the middle of the address - if (sizeof($this->aAddress) - || sizeof($this->aAddressNonSearch) + if (!empty($this->aAddress) + || (!empty($this->aAddressNonSearch)) || $this->sPostcode ) { $oSearch->iSearchRank++; @@ -262,7 +262,7 @@ class SearchDescription $iOp = Operator::NEAR; // near == in for the moment if ($aSearchTerm['operator'] == '') { - if (sizeof($this->aName) || $this->oContext->isBoundedSearch()) { + if (!empty($this->aName) || $this->oContext->isBoundedSearch()) { $iOp = Operator::NAME; } $oSearch->iSearchRank += 2; @@ -280,7 +280,7 @@ class SearchDescription // of the phrase. In structured search the name must forcably in // the first phrase. In unstructured search it may be in a later // phrase when the first phrase is a house number. - if (sizeof($this->aName) || !($bFirstPhrase || $sPhraseType == '')) { + if (!empty($this->aName) || !($bFirstPhrase || $sPhraseType == '')) { if (($sPhraseType == '' || !$bFirstPhrase) && !$bHasPartial) { $oSearch = clone $this; $oSearch->iSearchRank++; @@ -322,7 +322,7 @@ class SearchDescription $iWordID = $aSearchTerm['word_id']; if ((!$bStructuredPhrases || $iPhrase > 0) - && sizeof($this->aName) + && (!empty($this->aName)) && strpos($aSearchTerm['word_token'], ' ') === false ) { if ($aSearchTerm['search_name_count'] + 1 < CONST_Max_Word_Frequency) { @@ -337,7 +337,7 @@ class SearchDescription if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) { $oSearch->iSearchRank += 2; } - if (sizeof($aFullTokens)) { + if (!empty($aFullTokens)) { $oSearch->iSearchRank++; } $aNewSearches[] = $oSearch; @@ -358,11 +358,11 @@ class SearchDescription } if ((!$this->sPostcode && !$this->aAddress && !$this->aAddressNonSearch) - && (!sizeof($this->aName) || $this->iNamePhrase == $iPhrase) + && (empty($this->aName) || $this->iNamePhrase == $iPhrase) ) { $oSearch = clone $this; $oSearch->iSearchRank += 2; - if (!sizeof($this->aName)) { + if (empty($this->aName)) { $oSearch->iSearchRank += 1; } if (preg_match('#^[0-9]+$#', $aSearchTerm['word_token'])) { @@ -405,7 +405,7 @@ class SearchDescription $iHousenumber = -1; if ($this->sCountryCode - && !sizeof($this->aName) + && empty($this->aName) && !$this->iOperator && !$this->sClass && !$this->oContext->hasNearPoint() @@ -414,7 +414,7 @@ class SearchDescription if (4 >= $iMinRank && 4 <= $iMaxRank) { $aResults = $this->queryCountry($oDB); } - } elseif (!sizeof($this->aName) && !sizeof($this->aAddress)) { + } elseif (empty($this->aName) && empty($this->aAddress)) { // Neither name nor address? Then we must be // looking for a POI in a geographic area. if ($this->oContext->isBoundedSearch()) { @@ -435,17 +435,17 @@ class SearchDescription ); //now search for housenumber, if housenumber provided - if ($this->sHouseNumber && sizeof($aResults)) { + if ($this->sHouseNumber && !empty($aResults)) { $aNamedPlaceIDs = $aResults; $aResults = $this->queryHouseNumber($oDB, $aNamedPlaceIDs, $iLimit); - if (!sizeof($aResults) && $this->looksLikeFullAddress()) { + if (empty($aResults) && $this->looksLikeFullAddress()) { $aResults = $aNamedPlaceIDs; } } // finally get POIs if requested - if ($this->sClass && sizeof($aResults)) { + if ($this->sClass && !empty($aResults)) { $aResults = $this->queryPoiByOperator($oDB, $aResults, $iLimit); } } @@ -455,7 +455,7 @@ class SearchDescription var_dump(array_keys($aResults)); } - if (sizeof($aResults) && $this->sPostcode) { + if (!empty($aResults) && $this->sPostcode) { $sPlaceIds = Result::joinIdsByTable($aResults, Result::TABLE_PLACEX); if ($sPlaceIds) { $sSQL = 'SELECT place_id FROM placex'; @@ -562,7 +562,7 @@ class SearchDescription { $sSQL = 'SELECT p.place_id FROM location_postcode p '; - if (sizeof($this->aAddress)) { + if (!empty($this->aAddress)) { $sSQL .= ', search_name s '; $sSQL .= 'WHERE s.place_id = p.parent_place_id '; $sSQL .= 'AND array_cat(s.nameaddress_vector, s.name_vector)'; @@ -591,7 +591,7 @@ class SearchDescription $aTerms = array(); $aOrder = array(); - if ($this->sHouseNumber && sizeof($this->aAddress)) { + if ($this->sHouseNumber && !empty($this->aAddress)) { $sHouseNumberRegex = '\\\\m'.$this->sHouseNumber.'\\\\M'; $aOrder[] = ' ('; $aOrder[0] .= 'EXISTS('; @@ -617,13 +617,13 @@ class SearchDescription $aOrder[0] .= ') DESC'; } - if (sizeof($this->aName)) { + if (!empty($this->aName)) { $aTerms[] = 'name_vector @> '.getArraySQL($this->aName); } - if (sizeof($this->aAddress)) { + if (!empty($this->aAddress)) { // For infrequent name terms disable index usage for address if (CONST_Search_NameOnlySearchFrequencyThreshold - && sizeof($this->aName) == 1 + && count($this->aName) == 1 && $aWordFrequencyScores[$this->aName[reset($this->aName)]] < CONST_Search_NameOnlySearchFrequencyThreshold ) { @@ -653,7 +653,7 @@ class SearchDescription $aTerms[] = $this->oContext->withinSQL('centroid'); $aOrder[] = $this->oContext->distanceSQL('centroid'); } elseif ($this->sPostcode) { - if (!sizeof($this->aAddress)) { + if (empty($this->aAddress)) { $aTerms[] = "EXISTS(SELECT place_id FROM location_postcode p WHERE p.postcode = '".$this->sPostcode."' AND ST_DWithin(search_name.centroid, p.geometry, 0.1))"; } else { $aOrder[] = "(SELECT min(ST_Distance(search_name.centroid, p.geometry)) FROM location_postcode p WHERE p.postcode = '".$this->sPostcode."')"; @@ -681,7 +681,7 @@ class SearchDescription $sImportanceSQL .= $this->oContext->viewboxImportanceSQL('centroid'); $aOrder[] = "$sImportanceSQL DESC"; - if (sizeof($this->aFullNameAddress)) { + if (!empty($this->aFullNameAddress)) { $sExactMatchSQL = ' ( '; $sExactMatchSQL .= ' SELECT count(*) FROM ( '; $sExactMatchSQL .= ' SELECT unnest('.getArraySQL($this->aFullNameAddress).')'; @@ -700,7 +700,7 @@ class SearchDescription $aResults = array(); - if (sizeof($aTerms)) { + if (!empty($aTerms)) { $sSQL = 'SELECT place_id,'.$sExactMatchSQL; $sSQL .= ' FROM search_name'; $sSQL .= ' WHERE '.join(' and ', $aTerms); @@ -749,7 +749,7 @@ class SearchDescription $bIsIntHouseNumber= (bool) preg_match('/[0-9]+/', $this->sHouseNumber); $iHousenumber = intval($this->sHouseNumber); - if ($bIsIntHouseNumber && !sizeof($aResults)) { + if ($bIsIntHouseNumber && empty($aResults)) { // if nothing found, search in the interpolation line table $sSQL = 'SELECT distinct place_id FROM location_property_osmline'; $sSQL .= ' WHERE startnumber is not NULL'; @@ -778,7 +778,7 @@ class SearchDescription } // If nothing found try the aux fallback table - if (CONST_Use_Aux_Location_data && !sizeof($aResults)) { + if (CONST_Use_Aux_Location_data && empty($aResults)) { $sSQL = 'SELECT place_id FROM location_property_aux'; $sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.')'; $sSQL .= " AND housenumber = '".$this->sHouseNumber."'"; @@ -793,7 +793,7 @@ class SearchDescription } // If nothing found then search in Tiger data (location_property_tiger) - if (CONST_Use_US_Tiger_Data && $bIsIntHouseNumber && !sizeof($aResults)) { + if (CONST_Use_US_Tiger_Data && $bIsIntHouseNumber && empty($aResults)) { $sSQL = 'SELECT place_id FROM location_property_tiger'; $sSQL .= ' WHERE parent_place_id in ('.$sPlaceIDs.') and ('; if ($iHousenumber % 2 == 0) { diff --git a/lib/cmd.php b/lib/cmd.php index a1084938..1edf5dfd 100644 --- a/lib/cmd.php +++ b/lib/cmd.php @@ -16,7 +16,7 @@ function getCmdOpt($aArg, $aSpec, &$aResult, $bExitOnError = false, $bExitOnUnkn $aResult = array(); $bUnknown = false; - $iSize = sizeof($aArg); + $iSize = count($aArg); for ($i = 1; $i < $iSize; $i++) { if (isset($aQuick[$aArg[$i]])) { $aLine = $aQuick[$aArg[$i]]; diff --git a/lib/lib.php b/lib/lib.php index e283e836..3c70d1de 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -14,7 +14,7 @@ function getProcessorCount() { $sCPU = file_get_contents('/proc/cpuinfo'); preg_match_all('#processor\s+: [0-9]+#', $sCPU, $aMatches); - return sizeof($aMatches[0]); + return count($aMatches[0]); } diff --git a/lib/template/address-json.php b/lib/template/address-json.php index 85f6fe8e..4f0d024f 100644 --- a/lib/template/address-json.php +++ b/lib/template/address-json.php @@ -2,7 +2,7 @@ $aFilteredPlaces = array(); -if (!sizeof($aPlace)) { +if (empty($aPlace)) { if (isset($sError)) $aFilteredPlaces['error'] = $sError; else $aFilteredPlaces['error'] = 'Unable to geocode'; diff --git a/lib/template/address-xml.php b/lib/template/address-xml.php index 6183b284..5eddfa3e 100644 --- a/lib/template/address-xml.php +++ b/lib/template/address-xml.php @@ -11,7 +11,7 @@ echo " attribution='Data © OpenStreetMap contributors, ODbL 1.0. http://www.ope echo " querystring='".htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES)."'"; echo ">\n"; -if (!sizeof($aPlace)) { +if (empty($aPlace)) { if (isset($sError)) echo "$sError"; else echo 'Unable to geocode'; diff --git a/lib/template/details-html.php b/lib/template/details-html.php index dedf52f3..ef7d9248 100644 --- a/lib/template/details-html.php +++ b/lib/template/details-html.php @@ -199,7 +199,7 @@ } } - if (sizeof($aParentOfLines)) + if (!empty($aParentOfLines)) { headline('Parent Of'); @@ -223,7 +223,7 @@ _one_row($aAddressLine); } } - if (sizeof($aParentOfLines) >= 500) { + if (count($aParentOfLines) >= 500) { echo '

There are more child objects which are not shown.

'; } } diff --git a/lib/template/search-batch-json.php b/lib/template/search-batch-json.php index 09ea48b6..513f3c2b 100644 --- a/lib/template/search-batch-json.php +++ b/lib/template/search-batch-json.php @@ -49,7 +49,7 @@ foreach ($aBatchResults as $aSearchResults) { $aPlace['icon'] = $aPointDetails['icon']; } - if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])>0) { + if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) { $aPlace['address'] = $aPointDetails['address']; } diff --git a/lib/template/search-html.php b/lib/template/search-html.php index 37a6ce4a..53c6c88c 100644 --- a/lib/template/search-html.php +++ b/lib/template/search-html.php @@ -57,7 +57,7 @@ echo ''; $i = $i+1; } - if (sizeof($aSearchResults) && $sMoreURL) + if (!empty($aSearchResults) && $sMoreURL) { echo '
Search for more results
'; } diff --git a/lib/template/search-json.php b/lib/template/search-json.php index 774b5be0..7c87f636 100644 --- a/lib/template/search-json.php +++ b/lib/template/search-json.php @@ -43,7 +43,7 @@ foreach ($aSearchResults as $iResNum => $aPointDetails) { $aPlace['icon'] = $aPointDetails['icon']; } - if (isset($aPointDetails['address']) && sizeof($aPointDetails['address'])) { + if (isset($aPointDetails['address']) && !empty($aPointDetails['address'])) { $aPlace['address'] = $aPointDetails['address']; } diff --git a/phpcs.xml b/phpcs.xml index a48b5c3e..6b4abc39 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -32,6 +32,13 @@ + + + + + + + diff --git a/utils/importWikipedia.php b/utils/importWikipedia.php index 5a6e6e04..90477b81 100755 --- a/utils/importWikipedia.php +++ b/utils/importWikipedia.php @@ -241,7 +241,7 @@ function _templatesToProperties($aTemplates) } // Assume the first template with lots of params is the type (fallback for infobox) - if (!isset($aPageProperties['sPossibleInfoboxType']) && sizeof($aParams) > 10) { + if (!isset($aPageProperties['sPossibleInfoboxType']) && count($aParams) > 10) { $aPageProperties['sPossibleInfoboxType'] = trim($aTemplate[0]); // $aPageProperties['aInfoboxParams'] = $aParams; } @@ -495,7 +495,7 @@ if (isset($aCMDResult['link'])) { if (!isset($aNominatRecords[0])) { $aNameParts = preg_split('#[(,]#', $aRecord['name']); - if (sizeof($aNameParts) > 1) { + if (count($aNameParts) > 1) { $sNameURL = $sURL.'&q='.urlencode(trim($aNameParts[0])); var_Dump($sNameURL); $sXML = file_get_contents($sNameURL); @@ -509,7 +509,7 @@ if (isset($aCMDResult['link'])) { } // assume first is best/right - for ($i = 0; $i < sizeof($aNominatRecords); $i++) { + for ($i = 0; $i < count($aNominatRecords); $i++) { $fDiff = ($aRecord['lat']-$aNominatRecords[$i]['LAT']) * ($aRecord['lat']-$aNominatRecords[$i]['LAT']); $fDiff += ($aRecord['lon']-$aNominatRecords[$i]['LON']) * ($aRecord['lon']-$aNominatRecords[$i]['LON']); $fDiff = sqrt($fDiff); diff --git a/website/hierarchy.php b/website/hierarchy.php index 8f2f5237..9b488f83 100755 --- a/website/hierarchy.php +++ b/website/hierarchy.php @@ -62,7 +62,7 @@ $oPlaceLookup->setIncludeAddressDetails(true); $aPlaceAddress = array_reverse($oPlaceLookup->getAddressDetails($iPlaceID)); -if (!sizeof($aPlaceAddress)) userError('Unknown place id.'); +if (empty($aPlaceAddress)) userError('Unknown place id.'); $aBreadcrums = array(); foreach ($aPlaceAddress as $i => $aPlace) { @@ -100,7 +100,7 @@ $sSQL .= ' where parent_place_id in ('.join(',', $aRelatedPlaceIDs).') and name $sSQL .= ' order by rank_address asc,rank_search asc,localname,class, type,housenumber'; $aParentOfLines = chksql($oDB->getAll($sSQL)); -if (sizeof($aParentOfLines)) { +if (!empty($aParentOfLines)) { echo '

Parent Of:

'; $aClassType = getClassTypesWithImportance(); $aGroupedAddressLines = array(); @@ -136,7 +136,7 @@ if (sizeof($aParentOfLines)) { echo ''; } } - if (sizeof($aParentOfLines) >= 500) { + if (count($aParentOfLines) >= 500) { echo '

There are more child objects which are not shown.

'; } echo ''; diff --git a/website/polygons.php b/website/polygons.php index 4c1401ef..0f49183f 100755 --- a/website/polygons.php +++ b/website/polygons.php @@ -18,7 +18,7 @@ $oDB =& getDB(); $iTotalBroken = (int) chksql($oDB->getOne('select count(*) from import_polygon_error')); $aPolygons = array(); -while ($iTotalBroken && !sizeof($aPolygons)) { +while ($iTotalBroken && empty($aPolygons)) { $sSQL = 'select osm_type as "type",osm_id as "id",class as "key",type as "value",name->\'name\' as "name",'; $sSQL .= 'country_code as "country",errormessage as "error message",updated'; $sSQL .= ' from import_polygon_error'; @@ -32,7 +32,7 @@ while ($iTotalBroken && !sizeof($aPolygons)) { if ($bReduced) $aWhere[] = "errormessage like 'Area reduced%'"; if ($sClass) $sWhere[] = "class = '".pg_escape_string($sClass)."'"; - if (sizeof($aWhere)) { + if (!empty($aWhere)) { $sSQL .= ' where '.join(' and ', $aWhere); } diff --git a/website/reverse.php b/website/reverse.php index 2f1e31ee..4ce5833f 100755 --- a/website/reverse.php +++ b/website/reverse.php @@ -41,7 +41,7 @@ if ($sOsmType && $iOsmId > 0) { if ($oLookup) { $aPlaces = $oPlaceLookup->lookup(array($oLookup->iId => $oLookup)); - if (sizeof($aPlaces)) { + if (!empty($aPlaces)) { $aPlace = reset($aPlaces); } } diff --git a/website/search.php b/website/search.php index 0dddacce..6dc44335 100755 --- a/website/search.php +++ b/website/search.php @@ -68,7 +68,7 @@ $aSearchResults = $oGeocode->lookup(); if ($sOutputFormat=='html') { $sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1")); } -logEnd($oDB, $hLog, sizeof($aSearchResults)); +logEnd($oDB, $hLog, count($aSearchResults)); $sQuery = $oGeocode->getQueryString(); -- 2.39.5