166 $chunkSize = (int)ceil( count( $files ) / 72 );
168 $parser = (
new PhpParser\ParserFactory )->createForVersion( PhpParser\PhpVersion::fromComponents( 7, 0 ) );
169 $traverser =
new PhpParser\NodeTraverser;
171 $traverser->addVisitor( $finder );
173 $fileCount = count( $files );
175 $outputProgress = !defined(
'MW_PHPUNIT_TEST' );
177 for ( $i = 0; $i < $fileCount; $i++ ) {
179 $code = file_get_contents( $file );
181 if ( !str_contains( $code,
'@deprecated' ) ) {
185 $finder->setCurrentFile( substr( $file->getPathname(), strlen(
$IP ) + 1 ) );
186 $nodes = $parser->parse( $code );
187 $traverser->traverse( $nodes );
189 if ( $i % $chunkSize === 0 ) {
190 $percentDone = 100 * $i / $fileCount;
191 if ( $outputProgress ) {
192 fprintf( STDERR,
"\r[%-72s] %d%%", str_repeat(
'#', $i / $chunkSize ), $percentDone );
197 if ( $outputProgress ) {
198 fprintf( STDERR,
"\r[%'#-72s] 100%%\n",
'' );
202 if ( parent::posix_isatty( STDOUT ) ) {
203 $versionFmt =
"\n* Deprecated since \033[37;1m%s\033[0m:\n";
204 $entryFmt =
" %s \033[33;1m%s\033[0m (%s:%d)\n";
206 $versionFmt =
"\n* Deprecated since %s:\n";
207 $entryFmt =
" %s %s (%s:%d)\n";
210 foreach ( $finder->getFoundNodes() as $version => $nodes ) {
211 printf( $versionFmt, $version );
212 foreach ( $nodes as $node ) {
215 $node[
'hard'] ?
'+' :
'-',
222 printf(
"\nlegend:\n -: soft-deprecated\n +: hard-deprecated (via wfDeprecated())\n" );