Umherirrender has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/402402 )

Change subject: Change global function to closure in usort
......................................................................

Change global function to closure in usort

Change-Id: Ib9f08a60ad3a34524c94b535a11e7247458b9fed
---
M .phpcs.xml
M CollectionProposals.php
2 files changed, 13 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection 
refs/changes/02/402402/1

diff --git a/.phpcs.xml b/.phpcs.xml
index 2e20643..3f98d46 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -16,11 +16,6 @@
        <rule ref="Squiz.WhiteSpace.ScopeClosingBrace">
                <exclude-pattern>*/templates/*\.php</exclude-pattern>
        </rule>
-       <rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions">
-               <properties>
-                       <property name="ignoreList" type="array" 
value="wgCollectionCompareProps" />
-               </properties>
-       </rule>
        <file>.</file>
        <arg name="extensions" value="php,php5,inc"/>
        <arg name="encoding" value="UTF-8"/>
diff --git a/CollectionProposals.php b/CollectionProposals.php
index 42d7d77..177a285 100644
--- a/CollectionProposals.php
+++ b/CollectionProposals.php
@@ -333,7 +333,19 @@
                                }
                        }
                }
-               usort( $prop, "wgCollectionCompareProps" );
+               usort(
+                       $prop,
+                       function ( $a, $b ) {
+                               if ( $a['val'] == $b['val'] ) {
+                                       return strcmp( $a['name'], $b['name'] );
+                               }
+                               if ( $a['val'] < $b['val'] ) {
+                                       return 1;
+                               } else {
+                                       return -1;
+                               }
+                       }
+               );
                $this->mPropList = [];
                $have_real_weights = false;
                foreach ( $prop as $p ) {
@@ -391,30 +403,5 @@
         */
        private function getPropCount() {
                return count( $this->mPropList );
-       }
-}
-
-/**
- * sort $mPropList by the entries values
- * sort alphabetically by equal values
- *
- * @param array $a array that contain two entries
- *                the keys: 'name' & 'val'
- *                'name': an articlename
- *                'val' : a value from 1 to 1.5
- * @param array $b array that contain two entries
- *                the keys: 'name' & 'val'
- *                'name': an articlename
- *                'val' : a value from 1 to 1.5
- * @return int 1 -1 or 0
- */
-function wgCollectionCompareProps( $a, $b ) {
-       if ( $a['val'] == $b['val'] ) {
-               return strcmp( $a['name'], $b['name'] );
-       }
-       if ( $a['val'] < $b['val'] ) {
-               return 1;
-       } else {
-               return - 1;
        }
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/402402
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib9f08a60ad3a34524c94b535a11e7247458b9fed
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Collection
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to