diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2024-10-15 17:41:25 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2024-10-15 17:41:25 +0000 |
commit | 346bf0c8ee58bcf4ef8c3b9ccd03f02d6caf6430 (patch) | |
tree | cec56ef8ee87726138c91c0fd4ea5b421a8b6b90 /maintenance | |
parent | 7a1bc97c09511d0e9415a4b6fd8673e20382ceea (diff) | |
parent | e2b6281d6d5616de9dc71529f98f613e9390da7d (diff) | |
download | mediawikicore-346bf0c8ee58bcf4ef8c3b9ccd03f02d6caf6430.tar.gz mediawikicore-346bf0c8ee58bcf4ef8c3b9ccd03f02d6caf6430.zip |
Merge "Test findDeprecated.php"
Diffstat (limited to 'maintenance')
-rw-r--r-- | maintenance/findDeprecated.php | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/maintenance/findDeprecated.php b/maintenance/findDeprecated.php index 0abd5311b114..9fc4e8579354 100644 --- a/maintenance/findDeprecated.php +++ b/maintenance/findDeprecated.php @@ -83,10 +83,14 @@ class DeprecatedInterfaceFinder extends FileAwareNodeVisitor { return false; } foreach ( $node->stmts as $stmt ) { - if ( - $stmt instanceof PhpParser\Node\Expr\FuncCall - && $stmt->name->toString() === 'wfDeprecated' - ) { + $functionExpression = null; + if ( $stmt instanceof PhpParser\Node\Expr\FuncCall ) { + $functionExpression = $stmt; + } + if ( isset( $stmt->expr ) && $stmt->expr instanceof PhpParser\Node\Expr\FuncCall ) { + $functionExpression = $stmt->expr; + } + if ( $functionExpression && $functionExpression->name->toString() === 'wfDeprecated' ) { return true; } return false; @@ -139,12 +143,17 @@ class FindDeprecated extends Maintenance { } /** + * @return string The installation path of MediaWiki. This method is mocked in PHPUnit tests. + */ + protected function getMwInstallPath() { + return MW_INSTALL_PATH; + } + + /** * @return SplFileInfo[] */ public function getFiles() { - global $IP; - - $files = new RecursiveDirectoryIterator( $IP . '/includes' ); + $files = new RecursiveDirectoryIterator( $this->getMwInstallPath() . '/includes' ); $files = new RecursiveIteratorIterator( $files ); $files = new RegexIterator( $files, '/\.php$/' ); return iterator_to_array( $files, false ); @@ -163,6 +172,8 @@ class FindDeprecated extends Maintenance { $fileCount = count( $files ); + $outputProgress = !defined( 'MW_PHPUNIT_TEST' ); + for ( $i = 0; $i < $fileCount; $i++ ) { $file = $files[$i]; $code = file_get_contents( $file ); @@ -177,11 +188,15 @@ class FindDeprecated extends Maintenance { if ( $i % $chunkSize === 0 ) { $percentDone = 100 * $i / $fileCount; - fprintf( STDERR, "\r[%-72s] %d%%", str_repeat( '#', $i / $chunkSize ), $percentDone ); + if ( $outputProgress ) { + fprintf( STDERR, "\r[%-72s] %d%%", str_repeat( '#', $i / $chunkSize ), $percentDone ); + } } } - fprintf( STDERR, "\r[%'#-72s] 100%%\n", '' ); + if ( $outputProgress ) { + fprintf( STDERR, "\r[%'#-72s] 100%%\n", '' ); + } // Colorize output if STDOUT is an interactive terminal. if ( posix_isatty( STDOUT ) ) { |