168 $chunkSize = (int)ceil( count( $files ) / 72 );
170 $parser = (
new PhpParser\ParserFactory )->createForVersion( PhpParser\PhpVersion::fromComponents( 7, 0 ) );
171 $traverser =
new PhpParser\NodeTraverser;
173 $traverser->addVisitor( $finder );
175 $fileCount = count( $files );
177 $outputProgress = !defined(
'MW_PHPUNIT_TEST' );
179 for ( $i = 0; $i < $fileCount; $i++ ) {
181 $code = file_get_contents( $file );
183 if ( !str_contains( $code,
'@deprecated' ) ) {
187 $finder->setCurrentFile( substr( $file->getPathname(), strlen(
$IP ) + 1 ) );
188 $nodes = $parser->parse( $code );
189 $traverser->traverse( $nodes );
191 if ( $i % $chunkSize === 0 ) {
192 $percentDone = 100 * $i / $fileCount;
193 if ( $outputProgress ) {
194 fprintf( STDERR,
"\r[%-72s] %d%%", str_repeat(
'#', $i / $chunkSize ), $percentDone );
199 if ( $outputProgress ) {
200 fprintf( STDERR,
"\r[%'#-72s] 100%%\n",
'' );
203 foreach ( $finder->getFoundNodes() as $version => $nodes ) {
204 echo
"\n* Deprecated since $version:\n";
205 foreach ( $nodes as $node ) {
208 $node[
'hard'] ?
'+' :
'-',
215 printf(
"\nlegend:\n -: soft-deprecated\n +: hard-deprecated (via wfDeprecated())\n" );