]> git.openstreetmap.org Git - nominatim.git/commitdiff
replace PHP sizeof() with either count() or empty()
authormarc tobias <mtmail@gmx.net>
Thu, 22 Mar 2018 11:36:24 +0000 (12:36 +0100)
committermarc tobias <mtmail@gmx.net>
Thu, 22 Mar 2018 11:36:24 +0000 (12:36 +0100)
19 files changed:
lib/Geocode.php
lib/ParameterParser.php
lib/Phrase.php
lib/PlaceLookup.php
lib/SearchDescription.php
lib/cmd.php
lib/lib.php
lib/template/address-json.php
lib/template/address-xml.php
lib/template/details-html.php
lib/template/search-batch-json.php
lib/template/search-html.php
lib/template/search-json.php
phpcs.xml
utils/importWikipedia.php
website/hierarchy.php
website/polygons.php
website/reverse.php
website/search.php

index 26fafb734fa93d2d0beddbff4e52557537d3fad4..9daaff84df73a04026c77cc8d95d67c30a5663fa 100644 (file)
@@ -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('<hr>',sizeof($aWordsetSearches)); exit;
+                //var_Dump('<hr>',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);
index c9a97c25c5f6b0f29f0e9cb3b139b32e8f9d2841..26b648bb2865165d8b9ee897263b2ebed17016f1 100644 (file)
@@ -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;
         }
 
index b39079d94eafc38ddf11f08a1d2732053d5fd455..e8b31234bb21be37763e6e3c236f42e8476600bd 100644 (file)
@@ -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);
index 41fdea89ebdc9b99fdae011ff0788f650eadd661..bd6fa171d22cf2eaac3bdd7f0e010b5fef0f9f0a 100644 (file)
@@ -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();
         }
 
index 2e72deccc4792908b8067c9cdd30f0a8762a60ad..c4f05a0eb6840e510e8dac88f9100676cc053a94 100644 (file)
@@ -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) {
index a1084938e5ecef9709a800cfa65ef69ba450f337..1edf5dfd5c53d077b03453cfcf5192b0ac54b4a8 100644 (file)
@@ -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]];
index e283e8369ee7dbe19ddf5b984f496964da0adb64..3c70d1de7c822d0c6b15e7a6d7cec29be2fda1df 100644 (file)
@@ -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]);
 }
 
 
index 85f6fe8eb7c5fb7cdfe04fb29fd2ef3e4c9fd83a..4f0d024ff4b7bf40afd141c97081d5f8d386b174 100644 (file)
@@ -2,7 +2,7 @@
 
 $aFilteredPlaces = array();
 
-if (!sizeof($aPlace)) {
+if (empty($aPlace)) {
     if (isset($sError))
         $aFilteredPlaces['error'] = $sError;
     else $aFilteredPlaces['error'] = 'Unable to geocode';
index 6183b284dbc3e8df471ffc719e438e1de83dd17a..5eddfa3e2410a262d74d02655e4f4537bdf0bfdc 100644 (file)
@@ -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 "<error>$sError</error>";
     else echo '<error>Unable to geocode</error>';
index dedf52f3503e0a37227ad3aba0ef28ccfefd025e..ef7d9248dae658438a0e9ad2fed689f02b787af1 100644 (file)
         }
     }
     
-    if (sizeof($aParentOfLines))
+    if (!empty($aParentOfLines))
     {
         headline('Parent Of');
 
                 _one_row($aAddressLine);
             }
         }
-        if (sizeof($aParentOfLines) >= 500) {
+        if (count($aParentOfLines) >= 500) {
             echo '<p>There are more child objects which are not shown.</p>';
         }
     }
index 09ea48b63bdbc2a964ac4134de5fcd0d43084dfb..513f3c2b8833a8ea6a20617aa9e961ca47ea6ea2 100644 (file)
@@ -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'];
         }
 
index 37a6ce4a8b8e85916f9a0a3fa375e3a9fb89c013..53c6c88cfa88552134a4ffff5dbb2523cf936641 100644 (file)
@@ -57,7 +57,7 @@
                 echo '</div>';
                 $i = $i+1;
             }
-            if (sizeof($aSearchResults) && $sMoreURL)
+            if (!empty($aSearchResults) && $sMoreURL)
             {
                 echo '<div class="more"><a class="btn btn-primary" href="'.htmlentities($sMoreURL).'">Search for more results</a></div>';
             }
index 774b5be08b3e6bca7db863ab6584542986416cbc..7c87f6366ceb8876b492250c29b24c6dfa916e28 100644 (file)
@@ -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'];
     }
 
index a48b5c3e608db00b6ad24a4e3d979af7537e581d..6b4abc392a8279971f43e6a382708f6b7e6c2aed 100644 (file)
--- a/phpcs.xml
+++ b/phpcs.xml
 
 
 
+  <!-- eval, system, etc -->
+  <rule ref="Generic.PHP.ForbiddenFunctions">
+    <properties>
+      <property name="forbiddenFunctions" type="array" value="sizeof=>count,delete=>unset,print=>echo,create_function=>null,eval=>null"/>
+    </properties>
+  </rule>
+
   <!-- **************************************************************
        DOCUMENTATION
        ************************************************************** -->
index 5a6e6e0422b7d4197d3ae96f6476182173388171..90477b81e742857ab84a945f55e505ea8af8b780 100755 (executable)
@@ -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);
index 8f2f5237e6ccada5de2e97168733569089fa4539..9b488f8352b5fae1df0d4df3d13a3a8f0e1b4f97 100755 (executable)
@@ -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 '<h2>Parent Of:</h2>';
     $aClassType = getClassTypesWithImportance();
     $aGroupedAddressLines = array();
@@ -136,7 +136,7 @@ if (sizeof($aParentOfLines)) {
             echo '</div>';
         }
     }
-    if (sizeof($aParentOfLines) >= 500) {
+    if (count($aParentOfLines) >= 500) {
         echo '<p>There are more child objects which are not shown.</p>';
     }
     echo '</div>';
index 4c1401efdfbe5f3a366d35f36fba4840ffd8b540..0f49183f50b649a6cf1f3d9e34639afb065c715b 100755 (executable)
@@ -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);
     }
 
index 2f1e31eeb369cbfa1a1f7c892194f01db2e4fd1d..4ce5833f6129bb9a884a5ae6ee0708e7ac29f2fd 100755 (executable)
@@ -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);
         }
     }
index 0dddaccec9cf2dc2a2cec98236bea128b16b4dcd..6dc443359c78706a79098cb985875d5de873111f 100755 (executable)
@@ -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();