X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=inline;f=maintenance%2FfindHooks.php;h=81e18c993b08d677ee9146c2124a18f1e571cd5f;hb=1ff8d105f22baeae6ea0daa7fe4d06319e62f084;hp=d44581cd342eb27bcecb980bf8213cfbc7888d77;hpb=c340c41b37b5079ba90489f6b212bb8e4642031a;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/findHooks.php b/maintenance/findHooks.php index d44581cd34..81e18c993b 100644 --- a/maintenance/findHooks.php +++ b/maintenance/findHooks.php @@ -8,7 +8,7 @@ * - hooks names in code are the first parameter of wfRunHooks. * * if --online option is passed, the script will compare the hooks in the code - * with the ones at http://www.mediawiki.org/wiki/Manual:Hooks + * with the ones at https://www.mediawiki.org/wiki/Manual:Hooks * * Any instance of wfRunHooks that doesn't meet these parameters will be noted. * @@ -48,7 +48,7 @@ class FindHooks extends Maintenance { /* * Hooks that are ignored */ - protected static $ignore = [ 'testRunLegacyHooks', 'Test' ]; + protected static $ignore = [ 'Test' ]; public function __construct() { parent::__construct(); @@ -238,17 +238,17 @@ class FindHooks extends Maintenance { $m = []; preg_match_all( // All functions which runs hooks - '/(?:wfRunHooks|Hooks\:\:run|ContentHandler\:\:runLegacyHooks)\s*\(\s*' . + '/(?:wfRunHooks|Hooks\:\:run)\s*\(\s*' . // First argument is the hook name as string '([\'"])(.*?)\1' . // Comma for second argument '(?:\s*(,))?' . // Second argument must start with array to be processed - '(?:\s*array\s*\(' . + '(?:\s*(?:array\s*\(|\[)' . // Matching inside array - allows one deep of brackets - '((?:[^\(\)]|\([^\(\)]*\))*)' . + '((?:[^\(\)\[\]]|\((?-1)\)|\[(?-1)\])*)' . // End - '\))?/', + '[\)\]])?/', $content, $m, PREG_SET_ORDER @@ -305,17 +305,16 @@ class FindHooks extends Maintenance { if ( $recurse === self::FIND_RECURSIVE ) { $iterator = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator( $dir ), - RecursiveIteratorIterator::SELF_FIRST | RecursiveDirectoryIterator::SKIP_DOTS + new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ), + RecursiveIteratorIterator::SELF_FIRST ); } else { $iterator = new DirectoryIterator( $dir ); } foreach ( $iterator as $info ) { - // Ignore directories, ignore json (installer and api i18n), - // ignore extension-less files like HISTORY - if ( $info->isFile() && $info->getExtension() !== 'json' && $info->getExtension() + // Ignore directories, work only on php files, + if ( $info->isFile() && in_array( $info->getExtension(), [ 'php', 'inc' ] ) // Skip this file as it contains text that looks like a bad wfRunHooks() call && $info->getRealPath() !== __FILE__ ) { @@ -328,15 +327,12 @@ class FindHooks extends Maintenance { } /** - * Nicely output the array + * Nicely sort an print an array * @param string $msg A message to show before the value * @param array $arr - * @param bool $sort Whether to sort the array (Default: true) */ - private function printArray( $msg, $arr, $sort = true ) { - if ( $sort ) { - asort( $arr ); - } + private function printArray( $msg, $arr ) { + asort( $arr ); foreach ( $arr as $v ) { $this->output( "$msg: $v\n" );