Follow-up 6281b0a: LookupElement is still not in core
[lhc/web/wiklou.git] / maintenance / findHooks.php
index 1cf818e..60bdf29 100644 (file)
@@ -45,7 +45,7 @@ class FindHooks extends Maintenance {
        /*
         * Hooks that are ignored
         */
-       protected static $ignore = array( 'testRunLegacyHooks' );
+       protected static $ignore = [ 'testRunLegacyHooks' ];
 
        public function __construct() {
                parent::__construct();
@@ -61,11 +61,11 @@ class FindHooks extends Maintenance {
                global $IP;
 
                $documentedHooks = $this->getHooksFromDoc( $IP . '/docs/hooks.txt' );
-               $potentialHooks = array();
-               $bad = array();
+               $potentialHooks = [];
+               $bad = [];
 
                // TODO: Don't hardcode the list of directories
-               $pathinc = array(
+               $pathinc = [
                        $IP . '/',
                        $IP . '/includes/',
                        $IP . '/includes/actions/',
@@ -82,12 +82,14 @@ class FindHooks extends Maintenance {
                        $IP . '/includes/deferred/',
                        $IP . '/includes/diff/',
                        $IP . '/includes/exception/',
+                       $IP . '/includes/export/',
                        $IP . '/includes/externalstore/',
                        $IP . '/includes/filebackend/',
                        $IP . '/includes/filerepo/',
                        $IP . '/includes/filerepo/file/',
                        $IP . '/includes/gallery/',
                        $IP . '/includes/htmlform/',
+                       $IP . '/includes/import/',
                        $IP . '/includes/installer/',
                        $IP . '/includes/interwiki/',
                        $IP . '/includes/jobqueue/',
@@ -102,11 +104,13 @@ class FindHooks extends Maintenance {
                        $IP . '/includes/resourceloader/',
                        $IP . '/includes/revisiondelete/',
                        $IP . '/includes/search/',
+                       $IP . '/includes/session/',
                        $IP . '/includes/site/',
                        $IP . '/includes/skins/',
                        $IP . '/includes/specialpage/',
                        $IP . '/includes/specials/',
                        $IP . '/includes/upload/',
+                       $IP . '/includes/user/',
                        $IP . '/includes/utils/',
                        $IP . '/languages/',
                        $IP . '/maintenance/',
@@ -114,7 +118,7 @@ class FindHooks extends Maintenance {
                        $IP . '/tests/',
                        $IP . '/tests/parser/',
                        $IP . '/tests/phpunit/suites/',
-               );
+               ];
 
                foreach ( $pathinc as $dir ) {
                        $potentialHooks = array_merge( $potentialHooks, $this->getHooksFromPath( $dir ) );
@@ -129,7 +133,7 @@ class FindHooks extends Maintenance {
                $deprecated = array_diff( $documented, $potential, self::$ignore );
 
                // Check parameter count and references
-               $badParameterCount = $badParameterReference = array();
+               $badParameterCount = $badParameterReference = [];
                foreach ( $potentialHooks as $hook => $args ) {
                        if ( !isset( $documentedHooks[$hook] ) ) {
                                // Not documented, but that will also be in $todo
@@ -189,7 +193,7 @@ class FindHooks extends Maintenance {
         * @return array Array: key => hook name; value => array of arguments or string 'unknown'
         */
        private function getHooksFromLocalDoc( $doc ) {
-               $m = array();
+               $m = [];
                $content = file_get_contents( $doc );
                preg_match_all(
                        "/\n'(.*?)':.*((?:\n.+)*)/",
@@ -199,11 +203,11 @@ class FindHooks extends Maintenance {
                );
 
                // Extract the documented parameter
-               $hooks = array();
+               $hooks = [];
                foreach ( $m as $match ) {
-                       $args = array();
+                       $args = [];
                        if ( isset( $match[2] ) ) {
-                               $n = array();
+                               $n = [];
                                if ( preg_match_all( "/\n(&?\\$\w+):.+/", $match[2], $n ) ) {
                                        $args = $n[1];
                                }
@@ -228,20 +232,20 @@ class FindHooks extends Maintenance {
         * @return array
         */
        private function getHooksFromOnlineDocCategory( $title ) {
-               $params = array(
+               $params = [
                        'action' => 'query',
                        'list' => 'categorymembers',
                        'cmtitle' => "Category:$title",
                        'cmlimit' => 500,
                        'format' => 'json',
                        'continue' => '',
-               );
+               ];
 
-               $retval = array();
+               $retval = [];
                while ( true ) {
                        $json = Http::get(
                                wfAppendQuery( 'http://www.mediawiki.org/w/api.php', $params ),
-                               array(),
+                               [],
                                __METHOD__
                        );
                        $data = FormatJson::decode( $json, true );
@@ -265,7 +269,7 @@ class FindHooks extends Maintenance {
         */
        private function getHooksFromFile( $file ) {
                $content = file_get_contents( $file );
-               $m = array();
+               $m = [];
                preg_match_all(
                        // All functions which runs hooks
                        '/(?:wfRunHooks|Hooks\:\:run|ContentHandler\:\:runLegacyHooks)\s*\(\s*' .
@@ -285,11 +289,11 @@ class FindHooks extends Maintenance {
                );
 
                // Extract parameter
-               $hooks = array();
+               $hooks = [];
                foreach ( $m as $match ) {
-                       $args = array();
+                       $args = [];
                        if ( isset( $match[4] ) ) {
-                               $n = array();
+                               $n = [];
                                if ( preg_match_all( '/((?:[^,\(\)]|\([^\(\)]*\))+)/', $match[4], $n ) ) {
                                        $args = array_map( 'trim', $n[1] );
                                }
@@ -311,7 +315,7 @@ class FindHooks extends Maintenance {
         * @return array Array: key => hook name; value => array of arguments or string 'unknown'
         */
        private function getHooksFromPath( $path ) {
-               $hooks = array();
+               $hooks = [];
                $dh = opendir( $path );
                if ( $dh ) {
                        while ( ( $file = readdir( $dh ) ) !== false ) {
@@ -332,10 +336,10 @@ class FindHooks extends Maintenance {
         */
        private function getBadHooksFromFile( $file ) {
                $content = file_get_contents( $file );
-               $m = array();
+               $m = [];
                # We want to skip the "function wfRunHooks()" one.  :)
                preg_match_all( '/(?<!function )wfRunHooks\(\s*[^\s\'"].*/', $content, $m );
-               $list = array();
+               $list = [];
                foreach ( $m[0] as $match ) {
                        $list[] = $match . "(" . $file . ")";
                }
@@ -349,7 +353,7 @@ class FindHooks extends Maintenance {
         * @return array Array of bad wfRunHooks() lines
         */
        private function getBadHooksFromPath( $path ) {
-               $hooks = array();
+               $hooks = [];
                $dh = opendir( $path );
                if ( $dh ) {
                        while ( ( $file = readdir( $dh ) ) !== false ) {