X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FfindHooks.php;h=6d5dda1bfca5b51dfe2c3c9ea7fd9041a2d943de;hb=62991fcb7a5027b1eceb5656829c1c65bf9f98cb;hp=ebb1f26c17f8aab04375dc2193fedd0edb04d34a;hpb=e2f61aa44095d56af0d4b25a59e25b55a6c297bc;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/findHooks.php b/maintenance/findHooks.php index ebb1f26c17..6d5dda1bfc 100644 --- a/maintenance/findHooks.php +++ b/maintenance/findHooks.php @@ -5,12 +5,12 @@ * * This script assumes that: * - hooks names in hooks.txt are at the beginning of a line and single quoted. - * - hooks names in code are the first parameter of wfRunHooks. + * - hooks names in code are the first parameter of Hooks::run. * * if --online option is passed, the script will compare the hooks in the code * with the ones at https://www.mediawiki.org/wiki/Manual:Hooks * - * Any instance of wfRunHooks that doesn't meet these parameters will be noted. + * Any instance of Hooks::run that doesn't meet these requirements will be noted. * * Copyright © Antoine Musso * @@ -34,6 +34,8 @@ * @author Antoine Musso */ +use MediaWiki\MediaWikiServices; + require_once __DIR__ . '/Maintenance.php'; /** @@ -80,7 +82,7 @@ class FindHooks extends Maintenance { "$IP/", ]; $extraFiles = [ - "$IP/tests/phpunit/MediaWikiTestCase.php", + "$IP/tests/phpunit/MediaWikiIntegrationTestCase.php", ]; foreach ( $recurseDirs as $dir ) { @@ -216,7 +218,7 @@ class FindHooks extends Maintenance { $retval = []; while ( true ) { - $json = Http::get( + $json = MediaWikiServices::getInstance()->getHttpRequestFactory()->get( wfAppendQuery( 'https://www.mediawiki.org/w/api.php', $params ), [], __METHOD__ @@ -245,7 +247,7 @@ class FindHooks extends Maintenance { $m = []; preg_match_all( // All functions which runs hooks - '/(?:wfRunHooks|Hooks\:\:run|Hooks\:\:runWithoutAbort)\s*\(\s*' . + '/(?:Hooks\:\:run|Hooks\:\:runWithoutAbort)\s*\(\s*' . // First argument is the hook name as string '([\'"])(.*?)\1' . // Comma for second argument @@ -287,13 +289,12 @@ class FindHooks extends Maintenance { /** * Get bad hooks (where the hook name could not be determined) from a PHP file * @param string $filePath Full filename to the PHP file. - * @return array Array of bad wfRunHooks() lines + * @return array Array of source code lines */ private function getBadHooksFromFile( $filePath ) { $content = file_get_contents( $filePath ); $m = []; - // We want to skip the "function wfRunHooks()" one. :) - preg_match_all( '/(? hook name; value => array of arguments or string 'unknown' */ private function getHooksFromDir( $dir, $recurse = 0 ) { @@ -321,6 +322,7 @@ class FindHooks extends Maintenance { $iterator = new DirectoryIterator( $dir ); } + /** @var SplFileInfo $info */ foreach ( $iterator as $info ) { // Ignore directories, work only on php files, if ( $info->isFile() && in_array( $info->getExtension(), [ 'php', 'inc' ] )