-/**
- * Get hooks from the source code.
- * @param $path Directory where the include files can be found
- * @return array of hooks found.
- */
-function getHooksFromPath( $path ) {
- $hooks = array();
- if( $dh = opendir($path) ) {
- while(($file = readdir($dh)) !== false) {
- if( filetype($path.$file) == 'file' ) {
- $hooks = array_merge( $hooks, getHooksFromFile($path.$file) );
+ $potential = array_unique( $potential );
+ $bad = array_unique( $bad );
+ $todo = array_diff( $potential, $documented );
+ $deprecated = array_diff( $documented, $potential );
+
+ // let's show the results:
+ $this->printArray( 'Undocumented', $todo );
+ $this->printArray( 'Documented and not found', $deprecated );
+ $this->printArray( 'Unclear hook calls', $bad );
+
+ if ( count( $todo ) == 0 && count( $deprecated ) == 0 && count( $bad ) == 0 )
+ $this->output( "Looks good!\n" );
+ }
+
+ /**
+ * Get the hook documentation, either locally or from mediawiki.org
+ * @return array of documented hooks
+ */
+ private function getHooksFromDoc( $doc ) {
+ if ( $this->hasOption( 'online' ) ) {
+ // All hooks
+ $allhookdata = Http::get( 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:MediaWiki_hooks&cmlimit=500&format=php' );
+ $allhookdata = unserialize( $allhookdata );
+ $allhooks = array();
+ foreach ( $allhookdata['query']['categorymembers'] as $page ) {
+ $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches );
+ if ( $found ) {
+ $hook = str_replace( ' ', '_', $matches[1] );
+ $allhooks[] = $hook;
+ }
+ }
+ // Removed hooks
+ $oldhookdata = Http::get( 'http://www.mediawiki.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Removed_hooks&cmlimit=500&format=php' );
+ $oldhookdata = unserialize( $oldhookdata );
+ $removed = array();
+ foreach ( $oldhookdata['query']['categorymembers'] as $page ) {
+ $found = preg_match( '/Manual\:Hooks\/([a-zA-Z0-9- :]+)/', $page['title'], $matches );
+ if ( $found ) {
+ $hook = str_replace( ' ', '_', $matches[1] );
+ $removed[] = $hook;
+ }